Installing PHP5 for Apache 2.2 on FreeBSD 6.2

Things to note. Installed minimal FreeBSD 6.2, and MySQL 5.1 and Apache 2.2. Now I will install PHP5 for Apache.

I. Install PHP5

Install the PHP5. If you need to reconfigure the
settings again, you can edit it by typing make config.

root@freebsd:/usr/ports/lang/php5# cd /usr/ports/lang/php5
root@freebsd:/usr/ports/lang/php5# make install
 +--------------------------------------------------+
¦                     Options for php5 5.2.1_3                       ¦
¦ +----------------------------------------------------------------+ ¦
¦  [ ] CLI        Build CLI version                              ¦ ¦
¦  [ ] CGI        Build CGI version                              ¦ ¦
¦  [X] APACHE     Build Apache module                            ¦ ¦
¦  [ ] DEBUG      Enable debug                                   ¦ ¦
¦  [X] SUHOSIN    Enable Suhosin protection system               ¦ ¦
¦  [X] MULTIBYTE  Enable zend multibyte support                  ¦ ¦
¦  [X] IPV6       Enable ipv6 support                            ¦ ¦
¦  [ ] MAILHEAD   Enable mail header patch                       ¦ ¦
¦  [ ] REDIRECT   Enable force-cgi-redirect support (CGI only)   ¦ ¦
¦  [ ] DISCARD    Enable discard-path support (CGI only)         ¦ ¦
¦  [ ] FASTCGI    Enable fastcgi support (CGI only)              ¦ ¦
¦  [ ] PATHINFO   Enable path-info-check support (CGI only)      ¦ ¦
+----------------------------------------------------------------+-¦
¦                       [  OK  ]       Cancel                        ¦
+----------------------------------------------------+
 
root@freebsd:/usr/ports/lang/php5#
cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini 

II. Configure PHP5 for Apache

Add support for PHP to the Apache.

 
root@freebsd:/usr/local/etc/apache22#
cd /usr/local/etc/apache22
root@freebsd:/usr/local/etc/apache22#
 vi httpd.conf
# This line should have been added by the PHP5 installation,
 #if you had Apache22 installed
 LoadModule php5_module libexec/apache22/libphp5.so
# Then I edited the DirectoryIndex and added index.php
     <IfModule dir_module>
          DirectoryIndex index.php index.html
     </IfModule>
# And also added this to the <IfModule mime_module> section
     AddType application/x-httpd-php .php
     AddType application/x-httpd-php-source .phps

Create a test page.

root@freebsd:/usr/local/etc/apache22#
 echo <? phpinfo(); ?> >
 /usr/local/www/www.aminonline.com/test.php
root@freebsd:/usr/local/etc/apache22#
 apachectl configtest
         Syntax OK
root@freebsd:/usr/local/etc/apache22#
 apachectl restart
 

Now I point my browser to http://www.aminonline.com/test.php
and I should see a page showing details of my PHP configuration.
You should see a page similiar to this:

Post a Comment