CentOS 6 Deployment Nginx + PHP5 Web server
Deploy the Nginx and PHP5 server on the Cetnos 6 (64-bit) operating system. This process is done with the Yum command for RPM package installation.
Refer to the official PHP documentation.
Install some of the necessary YUM libraries
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Installing Nginx
Add nginx 's YUM library configuration file /etc/yum.repos.d/nginx.repo,
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
root User execution:
# yum install nginx
Install PHP and key plugins php-fpm
root User execution:
# yum install php-fpm
Other dependencies will be installed, including php-fpm and php itself.
Configuring, starting PHP-FPM
Configure /etc/php.ini, setcgi.fix_pathinfo=0
Start PHP-FPM and place the background run
php-fpm -D
The way to stop PHP-FPM
[Email protected]:/etc# Ps-ef | grep php-fpmRoot31591 1 0 -: the?xx:xx:xxPhp-fpm:master process (/etc/php-fpm.conf) Apache31592 31591 0 -: the?xx:xx:xxPhp-fpm:pool Wwwapache31593 31591 0 -: the?xx:xx:xxPhp-fpm:pool Wwwapache31594 31591 0 -: the?xx:xx:xxPhp-fpm:pool Wwwapache31595 31591 0 -: the?xx:xx:xxPhp-fpm:pool Wwwapache31596 31591 0 -: the?xx:xx:xxPhp-fpm:pool wwwroot31914 31878 0 -: +pts/1 xx:xx:xxgrep--color Php-fpm[email protected]:/etc# kill-s SIGINT 31591
or through service command execution
service php-fpm stopservice php-fpm start
Configure, start Nginx
Share my configuration directly /etc/nginx/nginx.conf:
user xiwang;events {}http { include /etc/nginx/mime.types; server { root /home/xiwang/opt/www; location / { index index.html index.htm index.php; } error_page 404 /404.html; location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }}
Start the Nginx server
$ nginx
or through the Service command:
service nginx stopservice nginx start
If the configuration file is modified at run time, you can do so by having the nginx -s reload
configuration file take effect.
FAQ How to solve the "NO INPUT FILE SPECIFIED" problem, when we install PHP and NGINX
Article: English original
Check if the php file has Write permissions , and its parent directory has Execute permissions ?
chmod a+x /home/xiwang/opt #<-- container folder should be granted execute permissionchmod a+x /home/xiwang/opt/www #<-- container folder should be granted execute permissionchmod a+w /home/xiwang/opt/www/*.php #<-- .php file should be granted write permission
CentOS 6 Deployment Nginx + PHP5 Server