Fiber Hosting

Affordable Professional Dedicated and Co-Location Services

Documentation and Tutorials by Fiber-Hosting LLC

Created for the novice server administrator of unix and linux powered servers.

 

How to: PHP 5 install on FreeBSD

PHP (PHP: Hypertext Preprocessor) is a computer scripting language, originally designed for producing dynamic web pages. It is mainly used in server-side scripting, but can be used from a command line interface or in standalone graphical applications. -definition taken from Wikipedia

  •  Installing the PHP Port
cd /usr/ports/lang/php5make configmake install

When you run make config you will be shown a list of options to choose from. To use PHP with Apache make sure the Apache Module box has a “X”.

  •  Adding the PHP 5 module to Apache

Apache needs the following lines in the httpd.conf file for php to work. These lines should already be added by the port but if you have problems you should double check your httpd.conf file.

Apache 1.3.x

LoadModule php5_module        libexec/apache/libphp5.soAddModule mod_php5.c

Apache 2.x

LoadModule php5_module        libexec/apache/libphp5.so

If you installed using the port and had Apache installed already the LoadModules should have been added during port install.

Next find your DirectoryIndex section in your httpd.conf file. Apache may be setup for PHP 4, but not PHP 5 currently so you will need to change your DirectoryIndex to look like this:

<IfModule mod_dir.c>

<IfModule mod_php3.c>

<IfModule mod_php5.c>

DirectoryIndex index.php index.php3 index.html

</IfModule>

<IfModule !mod_php4.c>

DirectoryIndex index.php3 index.html

</IfModule>

</IfModule>

<IfModule !mod_php3.c>

<IfModule mod_php5.c>

DirectoryIndex index.php index.html index.htm

</IfModule>

<IfModule !mod_php4.c>

DirectoryIndex index.html

</IfModule>

</IfModule>

</IfModule>

Setting HTTPD to read index.php first.

DirectoryIndex index.php index.html index.htm

Now apache just needs to know what it should parse the PHP files with. These two lines should be added to the httpd.conf file, and can be put at the bottom if needed.

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

If want to use PHP code inside of .htm files you can just add on those extensions.

AddType application/x-httpd-php .php .htm .html
Share this guide with a friend. These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Slashdot
  • SphereIt
  • StumbleUpon
  • Technorati

Tags: , ,

Comments are closed.


Warning: include(/usr/home/admin/domains/fiber-hosting.com/public_html/includes/quotes.php) [function.include]: failed to open stream: No such file or directory in /home/fiber/public_html/docs/wp-content/themes/default/footer.php on line 3

Warning: include() [function.include]: Failed opening '/usr/home/admin/domains/fiber-hosting.com/public_html/includes/quotes.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fiber/public_html/docs/wp-content/themes/default/footer.php on line 3


Entries (RSS) and Comments (RSS).