1. Download
Libxml2-2.6.32.tar.gz http://download.csdn.net/detail/netlong339/1351852
Php-5.3.16.tar.gz http://download.csdn.net/detail/aiyunbreak/5366061
2. Set up the target folder
mkdir/usr/local/php
That is, wait for the installed PHP to be installed in this folder
3, Decompression:
Place the downloaded file in a location on the server: for example,/root/xiebin
① first install libxml, unzip libxml2-2.6.32.tar.gz,
TAR-ZXVF libxml2-2.6.32.tar.gz
cd/root/xiebin/libxml2-2.6.32
Execution:./configure
Execution: Make
Execute: Make install
② is installing PHP, extracting TAR-ZXVF php-5.3.16.tar.gz
cd/root/xiebin/php-5.3.16
Execution:./configure--prefix=/usr/local/php--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2--enable-fpm--with-fpm-user=www-- With-fpm-group=www--with-libevent-dir=libevent
Here super important, php5.3 later support PHP-FPM boot, if not configured here, it will cause the subsequent unable to start PHP "Apache as a server, it doesn't matter, but we are Nginx now"
./configure--prefix=/usr/local/php--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2--enable-fpm--with-fpm-user=www-- With-fpm-group=www--with-libevent-dir=libevent
execution: Make
Execute: Make install
4. Configuration files
①ini file: Copy the php.ini-development from the installation file to/usr/local/php/lib
Cp/root/xiebin/php-5.3.16/php.ini-development/usr/local/php/lib
Rename the file to php.ini; I use the tool is WINSCP, can directly F2 rename, so I usually first copy, in F2 named
The direct CP was prompted not to find such a
②PHP-FPM file: PHP since 5.3 will PHP-FPM integration, this is very important!!! The following need to start PHP when used.
Rename the Php-fpm.conf.default to php-fpm.conf, i.e. remove the. Default
Modify the configuration in PHP-FPM: 122 will change www to root
140 Row User=root
Group=root
5. Start php: actually start php-fpm
/usr/local/php/etc/php-fpm
Here you will encounter a problem: Specify user and group other than root
FPM Initialzation failed
Error, prompt run PHP-FPM run users and groups can only select other than root.
Then look at the PHP-FPM document and find one of the options:-R
So the correct boot should be:/usr/local/php/etc/php-fpm-r
/usr/local/php/etc/php-fpm-r
To see if the startup was successful:
netstat-lnt | grep 9000
netstat-lnt | grep 9000
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
Or, use the following command to see if 9000 ports are PHP-FPM occupied:
NETSTAT-TUNPL | grep 9000
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2124/php-fpm
5. Nginx Configuration
Add a section to the Nginx configuration file
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Location ~ \.php$ {
root/www/web/;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
#fastcgi_param Script_filename/scripts$fastcgi_script_name;
Fastcgi_param script_filename/www/web/$fastcgi _script_name;
Include Fastcgi_params;
}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000location ~ \.php$ {root /www/web/;fastcgi_pass
127.0.0.1:9000;fastcgi_index index.php, #fastcgi_param script_filename /scripts$fastcgi_script_ Name;fastcgi_param script_filename /www/web/$fastcgi _script_name;include fastcgi_params;}
PS: How to find the location of Nginx: #whereis nginx.conf
Send one more command: Find file which nginx executable file name
After the configuration is done, again at home Nginx, execute:/usr/sbin/nginx-s reload
/usr/sbin/nginx-s Reload
Write a test page
Echo ("This is my first PHP pagesss");
?>
The above describes the Linux installation of PHP, and configuration to Nginx, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.