: 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.