Nginx virtual machine settings

Source: Internet
Author: User
: This article mainly introduces nginx virtual machine settings. if you are interested in the PHP Tutorial, you can refer to it. Generally, we do not deploy only one project on one machine. in this case, we need to set up a virtual machine to map the resolution of multiple addresses.

Assume that we have a configured nginx server.php-fpmProvide services.

Find the configuration file address

Sometimes we don't know where the configuration file is, but there is a big gap between different versions of Linux releases. at this time, we need to find the location of the configuration file.

[root@iZ28405a6nlZ ~]# whereis nginxnginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx

In this way, the location of the configuration file is found./etc/nginx

Set the configuration file

Go to the configuration folder and findconf.dFolder, the configuration file in which it is loaded every time it is restarted.Your domain name. confFile, suchwww.localhost.com.conf

The following is an example I wrote. the configuration of each server is different.

server {    listen80;    server_name www.xxx.com;    index index.html index.htm index.php;    root  /usr/share/nginx/html/xxx;    location / {          try_files$uri$uri/ /index.php?$args;          if (!-e $request_filename){          rewrite ^/(.*) /index.php last;          }          root   /usr/share/nginx/html/markweb;          index  index.php  index.html  index.htm;      }       location~ \.php$ {        root           /usr/share/nginx/html/xxx;        include  fastcgi_params;        fastcgi_pass127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/markweb$fastcgi_script_name;       # include        fastcgi_params;    }    log_format www.xxx.com '$remote_addr - $remote_user [$time_local] $request''$status$body_bytes_sent$http_referer ''$http_user_agent$http_x_forwarded_for';    access_log  /var/log/www.xxx.com.log www.xxx.com;}

After the restart, set the corresponding domain name resolution ~

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the nginx virtual machine settings, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.

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.