(1) Download and install Nginx
mkdir nginx-src && cd nginx-src wget http://nginx.org/download/nginx-1.7.3.tar.gz tar xzf nginx-1.7.3.tar.gz CD nginx-1.7.3./configure--prefix=/home/cyw/tools/nginx/source make do install
Where--prefix represents the installed directory. Just like selecting the path to the installation file in window. After the installation is complete, you can see the following file structure under the source folder:
(2) Download and install PHP
wget http://cn2.php.net/distributions/php-5.4.7.tar.gztar zvxf php-5.4.7.tar.gzcd php-5.4.7./configure -- Prefix=/home/oduyub/tools/php/source--enable-fastcgi--enable-debug--enable-fpmmakemake Install
The make step takes a relatively long time. After the installation is complete, you can see the following folder list below the folder. After the installation is complete, you can see the following file structure under the source folder:
After the installation is complete, you can see the following file directories under the source folder:
(3) Start PHP service
The use of PHP-FPM is the starting mode.
The Start command is:
> cd/sbin/>./php-fpm
After startup, perform
Ps-ef|grep PHP
You can see the output as follows:
(4) Start Nginx Service
You need to modify the nginx.conf file before starting
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root htm l; # Fastcgi_pass 127.0.0.1:9000; # Fastcgi_index index.php; # Fastcgi_param script_filename html$fastcgi_script_name; # include fastcgi_params; #}
"Note" The above # needs to be removed.
Note that the root line of HTML and Fasstcgi_param in the/html need to correspond. Indicates the path that PHP is looking for
> Cd/sbin/>sudo./nginx-s reload
Input/HTTP server address: Port number/
If can appear Nginx homepage, indicating nginx installation success
(5) test whether it can be started
Write a simple php test file index.php
<?php phpinfo () >
Enter the following link in the URL:/HTTP server address: Port number/index.php.
If the statistics page of PHP appears, it indicates that the instructions can be executed in PHP.
(5) Error List
nginx+php deployment