Deploy Nginx + PHP5 Web server in CentOS 6
Deploy the Nginx and PHP5 servers on the CetnOS 6 (64-bit) operating system. In this process, run the yum command to install the RPM package.
Refer to the official PHP documentation.
Install necessary YUM Libraries
Run the following command as the root user:
# 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
Add the nginx YUM library configuration file/etc/yum. repos. d/nginx. repo,
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
Run the following command as the root user:
# yum install nginx
Install PHP and important plug-ins php-fpm
Run the following command as the root user:
# yum install php-fpm php
Configure and start php-fpm
Configure/etc/php. ini:
# Locate and cancel the annotation and set it to cgi. fix_pathinfo = 0.
Configure/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/wwwroot and change the directory owner to theflash. Root User execution
# mkdir -p /data/wwwroot# chown theflash:theflash /data/wwwroot -R
From then on, we will use theflash to log on and maintain data in/data/wwwroot.
Directly share my configuration/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 without stopping the Nginx 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 whether the php file has the write permission. Does the parent directory have the execution permission?
#<-- container folders should be granted execute permissionchmod a+x /datachmod a+x /data/wwwroot