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. Create the target folder
mkdir /usr/local/php
That means the php to be installed later will be installed in this folder
3. Unzip:
Place the downloaded file on the server A certain location: such as /root/xiebin
①First install libxml, decompress libxml2-2.6.32.tar.gz,
<span style="font-size:18px;">tar -zxvf libxml2-2.6.32.tar.gz</span>
cd /root/xiebin/libxml2-2.6.32
Execute: ./configure
Execute: make
Execute: make install
②After installing php, decompress tar -zxvf php-5.3.16.tar.gz
cd /root/xiebin/php-5.3.16
Execute: ./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
This is super important. php5.3 and later supports php-fpm startup. If it is not configured properly, it will cause php to be unable to be started later [If apache is used as the server, it does not matter, but we are now nginx]
./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
Execution: make install
4. Configuration file
①ini file: Copy php.ini-development in 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; the tool I use is WinScp, which can be renamed directly with F2, so I usually copy it first, and then F2 naming
When directly cp, I was prompted not find such
②php-fpm file: PHP has integrated php-fpm since 5.3, this is very important! ! ! Used below when you need to start php.
Rename php-fpm.conf.default to php-fpm.conf, that is, remove .default
Modify the configuration in php-fpm: Line 122 Replace www with root
Line 140 user=root
. Start php: Actually start php-fpm
/usr/local/php/etc/php-fpm
Here you will encounter a problem: please specify user and group other than root
When running php-fpm, you can only choose other users and groups except root.
So if you look at the php-fpm document, you will find one of the options: -R
So The correct startup should be: /usr/local/php/etc/php-fpm -R
/usr/local/php/etc/php-fpm -R
Check whether the startup is 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 check whether port 9000 is occupied by php-fpm:
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 segment of
# PASS The PHP Scripts to Fastcgi Server Listening on 127.0.1:9000
Location ~ .php $ { T / 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;
inc lude fastcgi_params;
}
# 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;
}
PS: How to find the position of nginx: #Whereis nginx.conf Send another command: Find the file which nginx
executable file name
configuration, then nginx again, execute:/usr/sbin// nginx -s reload
/usr/sbin/nginx -s reload
Write a test page
The above introduces how to install php under Linux and configure it to nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn