您好,欢迎访问一九零五行业门户网

nginx虚拟机设置

一般情况下,我们的一台机器都不会仅仅部署一个项目,那么这个时候需要我们设置虚拟机来映射多个地址的解析。
假设我们目前有一个已经设置好的nginx服务器,通过php-fpm提供服务。
找到配置文件地址
有的时候我们不知道配置文件在哪里,而不同版本的linux发行版的差距又很大,那么这个时候,就需要去找配置文件的位置
[root@iz28405a6nlz ~]# whereis nginxnginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
这样就找到了配置文件的位置/etc/nginx
设置配置文件
进去配置文件夹,发现里面有个conf.d的文件夹,这里面的配置文件,每次重启都会被加载进去,在这个里面创建你的域名.conf的文件,例如www.localhost.com.conf
下面是我写的例子,每个服务器的配置都会差别,不要随便拿过来用
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;}
重启之后设置对应的域名解析就可以咯~
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了nginx虚拟机设置,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息