Building PHP Environment
PHP almost supports all popular databases, almost all system platforms, mixed with C Java Perl and other syntax and custom syntax, is the server-side HTML embedded script
1. Install the PHP package
1. Unzip and release the downloaded PHP source pack into the/usr/src/directory and switch into the expanded source folder
[Root@www ~]# tar zxvf php-5.2.6.tar.gz-c/usr/src
[Root@www ~]# cd/usr/src/php-5.2.6/
2. Pre-configuring compile-time parameters
[Root@www php-5.2.6]#./configure--PREFIX=/USR/LOCAL/PHP5--enable-mbstring--with-apx2=/usr/local/apache2/bin/ APXS--with-mysql=/usr/local/mysq--with-config-file-path=/usr/local/php5b) –prefix: Setting up the PHP installation path
Configure command Options meaning
--prefix: Set the installation path for the PHP program
-–enable-mbstring set PHP to support multibyte strings
-–WITH-APXS2: Set up the APXS module support program file provided by the Apache server
-–with-mysql: Supports the installation location of the MySQL server program
-–with-config-file-path: Set the location of the PHP configuration file
3). Compiling installation
[Root@www php-5.2.6]# make; Make install
4). copy php.ini configuration file
[Root@www php-5.2.6]# CP Php.ini-dist/usr/local/php5/php.ini
2. Set up httpd.conf file
PHP programs need to coordinate with the Web server in order to play a powerful role. So after compiling the installed PHP program, you will also need to edit the httpd server's master profile httpd.conf to add the relevant configuration to support the PHP environment.
To enable the HTTPD server to support the PHP page parsing feature, you can use the "LoadModule" configuration item to load the corresponding module of the PHP program. Look in the httpd.conf file to confirm that there is a configuration line "LoadModule php5_module modules/libphp5.so" and add it manually if it is not found.
You also need to use the "AddType" keyword to refer to the related configuration add configuration Line "AddType application/x-httpd-php. php".
[Root@www php-5.2.6]# vi/usr/local/apache2/conf/httpd.conf//Support configuration line for PHP environment
···
LoadModule Php5_module module/libphp5.so
···
AddType application/x-httpd-php. php
where "Php_module" is the module name, "Modules/libphp5.so" is the module file location
If you also need to change the first page file in your Web site's catalog file to use index.php, you will also need to modify the DirectoryIndex configuration line in the httpd.conf file and add the "index.php" item. So that the HTTPD server can search the home file correctly
[Root@www php-5.2.6]# vi/usr/local/apache2/conf/httpd.conf//Adjust the first file setting in httpd.conf file
····
DirectoryIndex index.php index.html
After the above adjustments are completed, the HTTPD service is restarted using the Apachetl script, and the server will be able to correctly parse the Web page files written using PHP voice.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/