Deploy Nginx + PHP5 server in CentOS 6 and centosng.pdf
Deploy Nginx + PHP5 Web server in CentOS 6
InCetnOS 6 (64-bit)Deploy Nginx and PHP5 servers on the operating system. This process passesYumCommand to install the RPM package.
Refer to the official PHP documentation.
Install necessary YUM Libraries
RootUser execution:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install Nginx
AddNginxYUM library configuration file/Etc/yum. repos. d/nginx. repo,
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
RootUser execution:
# yum install nginx
Install PHP and important plug-ins php-fpm
RootUser execution:
# yum install php-fpm php
Configure and start php-fpm
Configuration/Etc/php. ini:
# Locate and cancel the annotation and set it to cgi. fix_pathinfo = 0.
Configuration// Etc/php-fpm.d/www. conf:
# Locate and cancel the annotation and set it to the user you want to manage the www application (I will use the user theflash here) listen. owner = theflashlisten. group = theflash
Start the php-fpm listening service
# service php-fpm start
Stop the php-fpm listening service
# service php-fpm stop
Configure and start Nginx
Create a website root directory/Data/wwwrootAnd change the directory ownerTheflash.
RootUser execution
# mkdir -p /data/wwwroot# chown theflash:theflash /data/wwwroot -R
From then on, users will be used in the futureTheflashTo log on and maintain/Data/wwwrootData in
Share my configurations directly/Etc/nginx. conf:
user theflash;events {}http { include /etc/nginx/mime.types; server { root /data/wwwroot; 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; include fastcgi_params; } }}
Start Nginx Server
# service nginx start
Stop Nginx Server
# service nginx stop
If the configuration file is modified during running, you need to reload the Nginx server configuration file.No need to stopNginx Server
# nginx -s reload
FAQ how to solve the "no input file specified" problem, when we install PHP and NGINX
Article: original English version
Check if php files haveWrite PermissionIts parent directory hasExecution permission?
#<-- container folders should be granted execute permissionchmod a+x /datachmod a+x /data/wwwroot