2010年3月9日 星期二

安裝php5 on FreeBSD8

In the past there were several ports for PHP such as /www/mod-php5, /lang/php5-cli, and /lang/php5. Since the release of PHP 5.1.14 there is now only /lang/php5 This port now allows you to choose if you want to install the CLI, CGI, and Apache module.

# cd /usr/ports/lang/php5
# make config
# make install


Once php has installed you will need to install the extra modules for things such as MySQL. These modules are all located in the ports. Some of the most common modules are
/usr/ports/databases/php5-mysql - MySQL Database
/usr/ports/www/php5-session - Sessions
/usr/ports/graphics/php5-gd - Graphics Library

Adding the PHP 5 module to Apache

Apache needs the following lines in the httpd.conf file to use php. These lines should already be added by the port but if you have problems you should double check your httpd.conf file. Note that Apache 2.x does not need the AddModule line.
# Apache 1.3.x
LoadModule php5_module        libexec/apache/libphp5.so
AddModule mod_php5.c
# Apache 2.x
LoadModule php5_module        libexec/apache/libphp5.so
If you installed using the port and had apache installed already it should do this automatically for you.
Next find your DirectoryIndex section in your httpd.conf file. Apache is set up for PHP 4, but not PHP 5 currently so you will need to modify it and change the 4s to 5s like this.

You can change the order as you wish. Or if you just wanted to skip it you could simply add the following line to the httpd.conf file since you know you are going to have php 5.
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

Configuring PHP

Settings for PHP are stored in /usr/local/etc/php.ini You will need to create this file by copying it from /usr/local/etc/php.ini-dist
# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini In this file you can set the memory limit for programs. Turn on global variables if you must, set the max file upload size, and everything else you need.

From:http://www.freebsdmadeeasy.com/tutorials/web-server/install-php-5-for-web-hosting.php

2 則留言:

nIce 提到...
作者已經移除這則留言。
nIce 提到...

If you want change your php5 options,
you can "make config" ....

example:
# cd /usr/ports/lang/php5
# make config
# make install

熱門文章