Guide on how to install Apache 2.2 With Php 5 On FreeBSD
Yes yet another guide on how to install Apache 2.2 with Php 5 on FreeBSD. There are many ways to do this. And I’m not saying my way better. But I can confirm this method has worked fine on all systems I’ve installed Apache 2.2 with php5 on.
When the configuration screen pops up just accept the default values unless you have very specific needs. Note if you need “mod_security” you will not find it in this listing.
Once the installation is done we need to add apache to rc.conf so it will launch at startup.
Add the following to /etc/rc.conf
If you don’t feel like editing the file manually you can append it to /etc/rc.conf like this.
We can now try and start apache
After starting apache 22 you will most likely get an error saying something like below
In order to fix this add the following to your loader.conf accf_http_load="YES" you can do it like this
Either reboot or load the module manually. In order to load the module manually type the following
And then restart apache like this
Before you proceed and install Php5 take the time and adjust the httpd.conf file to reflect your minimum needs and test if the installation works. Doing this saves you the time of doing troubleshooting 2 places PHP and or Apache if something fails.
This is quite easy and straight forward we will install Php5 from ports.
Before we begin I would like to point out that if you intend to run Squirrelmail you will need to enable “Track-Vars” when compiling Php5.
To be honest I haven’t checked lately if Squirrelmail still requires it, but there is absolutely no harm done in enabling it. Enabling track-vars is not listed in the option screen when we run “make install clean” so we need to edit the “Makefile” before we install Php5.
Add the following line:
Now that everything is in place we are ready to install Php5
Accept the default values [Screenshot] and be sure to also check the following:
Build Apache Module
Enable Sohusin protection system
Enable Zend multibyte support
Once done we need to make sure that Pph5 is Added as a Type in apaches httpd.conf file. Add the the lines shown below to the httpd.conf file just below the line that says “#AddType application/x-gzip .tgz”
We need a php.ini configuration file for php to work with. We’ll use one of the defaults that came with the installation.
Restart apache for the changes to take affect.
Now we just need to test if things are running as intended. We will need create a php test file for this.
Test if things are running as intended by launching phptest.php in a browser.
With Php5 installed a lot of your old Php proggies will probably do a lot of complaining and show a lot of warnings on your Php pages even though they’re working. Displaying this should be disabled for security reasons. So let’s do this
Find the following line
Next you will see php5 spamming your log files with a timezone warning we need to fix this as well.
Remove the ; and add the correct timezone. I use Europe Copenhagen here cause this is where this server is located.
Restart apache for the changes to take affect.