Configure Nginx + Fastcgi + PHP for multiple websites in CentOS

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.