Today, I want to help my friends configure the CentOS + PHP + Nginx environment and record it, hoping to help more partners
Today, I want to help my friends configure the CentOS + PHP + Nginx environment and record it, hoping to help more partners
Install nginx
yum install nginx
Php5.x already comes with php-fpm, if not
yum install php-fpm
Configure nginx. conf
Server {listen 80; server_name 127.0.0.1; server_name_in_redirect off; location/{root/var/www/html; index index.html index. php ;}# this step is used to introduce the configuration of all websites, including/etc/nginx/vhost /*. conf;
Continue to all files under/etc/nginx/vhost/
# xxx1.com.confserver { listen 80; server_name xxx1.com www.xxx1.com; access_log /etc/nginx/log/xxx1.com.log; location / { root /var/www/www.xxx1.com; index index.html index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/error; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/www.xxx1.com/$fastcgi_script_name; include fastcgi_params; }}# xxx2.com.confserver { listen 80; server_name pet82.com www.xxx2.com; access_log /etc/nginx/log/xxx2.com.log; location / { root /var/www/www.xxx2.com; index index.php index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/error; } location ~.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/www.xxx2.com/$fastcgi_script_name; include fastcgi_params; }}
Modify/etc/php-fpm.d/www. conf Default Configuration
# Change both the user and user group to nginxuser = nginxgroup = nginx # comment out security. limit_extensions =. php. php3. php4. php5
Then modify the website directory permission
chown -R nginx.nginx /var/www/www.xxx1.comchown -R nginx.nginx /var/www/www.xxx2.comchmod -R 700 /var/www/www.xxx1.comchmod -R 700 /var/www/www.xxx2.com
Restart nginx and php-fpm
service nginx restartservice php-fpm restart
Remember to add/etc/hosts
127.0.0.1 www.xxx1.com127.0.0.1 www.xxx2.com