nginx虛擬機設置
來自: http://blog.csdn.net/diandianxiyu_geek/article/details/48444659
一般情況下,我們的一臺機器都不會僅僅部署一個項目,那么這個時候需要我們設置虛擬機來映射多個地址的解析。
假設我們目前有一個已經設置好的nginx服務器,通過php-fpm
提供服務。
找到配置文件地址
有的時候我們不知道配置文件在哪里,而不同版本的Linux發行版的差距又很大,那么這個時候,就需要去找配置文件的位置
[root@iZ28405a6nlZ ~]# whereis nginx nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
這樣就找到了配置文件的位置/etc/nginx
設置配置文件
進去配置文件夾,發現里面有個conf.d
的文件夾,這里面的配置文件,每次重啟都會被加載進去,在這個里面創建你的域名.conf
的文件,例如www.localhost.com.conf
下面是我寫的例子,每個服務器的配置都會差別,不要隨便拿過來用
server { listen 80; 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_pass 127.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;
}</pre>
重啟之后設置對應的域名解析就可以咯~
</div>
本文由用戶 babyzn 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!