Thursday, February 23, 2012 - 04:54
FeedBurner  RSS 2.0 Feed  Follow Me On Twitter  Save On Delicious

Installing Apache 1.3 With Php 5

Guide on how to install Apache 1.3 with Php 5 on FreeBSD

Yes yet another guide on how to install Apache 1.3 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 1.3 with php5 on.

Now we are not going to install apache ourself instead we are going to let the Php installation run the apache compilation. So therefor we are going to install Php5 first.

Apache will not prompt you for any configuration options since Php is running the installation for us. So if we want some extra options, modules etc. compiled into apache, we need to do it now by modifying apaches “Makefile” before starting the Php5 installation. So let’s add a few modules to apache now.

We will add following modules to the apache compilation “Headers, Rewrite, and Expires”

As root
cd /usr/ports/www/apache13
vi Makefile

Find the following lines
--prefix=${PREFIX} \
--server-uid=www \
--server-gid=www \
--with-perl=${PERL} \
--with-layout=FreeBSD \
--datadir=${DATADIR} \
--htdocsdir=${DOCUMENT_ROOT} \
--cgidir=${CGIBIN_ROOT} \
--without-confadjust \
--enable-module=most \
--enable-module=auth_db \
--enable-module=mmap_static \
--disable-module=auth_dbm \
--enable-shared=max \

Add the following 3 lines to the bottom of the above lines:

Add the following lines
--enable-module=headers \
--enable-module=expires \
--enable-module=rewrite \

They should now look like this
--prefix=${PREFIX} \
--server-uid=www \
--server-gid=www \
--with-perl=${PERL} \
--with-layout=FreeBSD \
--datadir=${DATADIR} \
--htdocsdir=${DOCUMENT_ROOT} \
--cgidir=${CGIBIN_ROOT} \
--without-confadjust \
--enable-module=most \
--enable-module=auth_db \
--enable-module=mmap_static \
--disable-module=auth_dbm \
--enable-shared=max \
--enable-module=headers \
--enable-module=expires \
--enable-module=rewrite \

If you want more modules compiled into apache this is the time to do it and add them to the “Makefile”

Back to Php remember Php5 is going to launch the apache compilation this is done by checking the “Build Apache Module” once the option screen for Php5 pops up.

Actually we are ready to begin, but 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 done in the same way as we added modules to the apache Makefile.

As root
cd /usr/ports/lang/php5
vi Makefile

Find the following lines
--with-layout=GNU \
--with-config-file-scan-dir=${PREFIX}/etc/php \
--disable-all \
--enable-libxml \
--with-libxml-dir=${LOCALBASE} \
--program-prefix=”"

Add the following lines
--enable-track-vars \

They should now look like this
--with-layout=GNU \
--with-config-file-scan-dir=${PREFIX}/etc/php \
--disable-all \
--enable-libxml \
--enable-track-vars \
--with-libxml-dir=${LOCALBASE} \
--program-prefix=”"

Now that everything is in place it’s time to install all of this.

As root
cd /usr/ports/lang/php5
make install clean

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 the installation is complete add the following to /etc/rc.conf so that apache starts up after reboot.

As root
apache_enable="YES"

If you don’t feel like editing the file manually you can append it to /etc/rc.conf like this.

As root
echo apache_enable=\"YES\" >> /etc/rc.conf

We need a php.ini file for php to work we will use one of the defaults that came with the installation.

As root
cd /usr/local/etc
cp php.ini-development php.ini

It’s time to put it to a test. Let’s create a phpinfo page. This is 1 line of code and can be applied like this.

As root
echo -e "<?php \nphpinfo();\n?>" > /usr/local/www/data/phptest.php

Start up apache and launch phptest.php in a browser like this http://xx.xx.xx.xx/phptest.php where xx is your IP number. Once you see the phpinfo page you know things are working it’s time to adjust your httpd.conf file.

As root
/usr/local/sbin/apachectl start
Related Guides  Links  Requirements