$Id: apache_php.php 298 2009-12-30 01:53:00Z gjb $
Apache + PHP
This document assumes you have a recent
ports tree.
By default, building
lang/php* with the Apache module will automatically install
www/apache13. If you want a 2.X version of Apache, you must build it first:
cd /usr/ports/www/apache22
make config-recursive && make fetch-recursive
make install
Assuming you want to install
lang/php5, enable the Apache module and build:
cd /usr/ports/lang/php5
make fetch-recursive
make -DWITH_APACHE install
Edit
/usr/local/etc/apache22/httpd.conf so Apache knows what to do with
.php files:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
If you plan to host your site with
index.php pages, you need to change the
DirectoryIndex directive in
/usr/local/etc/apache22/httpd.conf:
DirectoryIndex index.php index.html
Before attempting to start apache, ensure your hostname is resolvable:
ping -c1 -t1 `hostname` >/dev/null \
&& echo "resolvable" \
|| echo "add `hostname` to /etc/hosts"
Add the
ServerName directive to
/usr/local/etc/apache22/httpd.conf
echo "ServerName `hostname`" >> /usr/local/etc/apache22/httpd.conf
Add the
rcvar for Apache22 to
/etc/rc.conf
echo `/usr/local/etc/rc.d/apache22 rcvar | grep enable` >> /etc/rc.conf
Start apache using the rc script
/usr/local/etc/rc.d/apache22 start