User Tools

Site Tools


archive:freebsd_install_apache_24_with_php72

How To Install Apache 2.4 with Php 7.2 On FreeBSD

cd /usr/ports/www/apache24 && make install clean BATCH=yes

Enable apache to start after boot. Add the following to /etc/rc.conf

apache24_enable="YES"

We need to edit some parameters in loader.conf. Change the following.

vi /boot/defaults/loader.conf

Find the following lines.

accf_data_load="NO"             # Wait for data accept filter
accf_dns_load="NO"              # Wait for full DNS request accept filter   
accf_http_load="NO"             # Wait for full HTTP request accept filter

Change them to look like this.

accf_data_load="YES"            # Wait for data accept filter
accf_dns_load="NO"              # Wait for full DNS request accept filter   
accf_http_load="YES"            # Wait for full HTTP request accept filter

Now depending on the load we expect to get adjust sysctl.conf accordingly.

vi /etc/sysctl.conf

Add the following line. Depending on your expected number of requests this should perhaps be 2048

kern.ipc.somaxconn=1024

Add some default directories. And populate the default directory with an empty file.

mkdir /var/log/www
mkdir /usr/local/www/cgi-bin
:> /usr/local/www/apache24/data/index.html

Check if things are working as expected.

apachectl configtest

Note: The above command may result in a warning similar to the one below because httpd.conf is not configured yet.

Could not determine the server's fully qualified domain name, using domain.xyz. Set the 'ServerName' directive globally to suppress this message

Now either start apache manually or restart your machine.

Note: Regarding Php5x. The first thing to do is to enable track vars, I have no clue wether this is still used by some applications or not, but I enable it anyway just to be safe. If you are sure you won't be needing track vars you kan skip this step.

Optional enable track vars start

cd /usr/ports/lang/php72
vi Makefile

Modify the Makefile in the configure_args section by addig the following line.

--enable-track-vars \

Optional enable track vars stop

Install Php72

cd /usr/ports/www/mod_php72 && make install clean BATCH=yes

Next let's get the configuration file in place.

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
chmod 444 /usr/local/etc/php.ini
apachectl restart

Create a php test page showing info about our php installation This will not work until you are done adjusting your httpd configuration file.

echo -e "<?php phpinfo(); ?>" > /usr/local/www/apache24/data/phptest.php

The last thing is to get your apache configuration files done. Since this is very individual this wiki does not cover this part of the apache installation.

Notes on FreeBSD Apache 2.4 and Php72 installation A list of usefull tools and utilities to accompany the FreeBSD Apache 2.4 and Php72 installation Usefull Tools And Applications

Configuring SSL on Apache 2.4 can be found here: Enable SSL On Apache

archive/freebsd_install_apache_24_with_php72.txt · Last modified: 24/11/2023 12:29 by Allan