小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Nginx MAC上搭建環(huán)境及常見問題

 玄冰優(yōu) 2016-05-19
剛剛接手一個WEB項目,就要重新搭建環(huán)境。
首先是使用 Homebrew來安裝所需插件。

http:///index_zh-cn.html
按照此網(wǎng)頁上面的指令進行安裝。

安裝Homebrew之后 安裝Nginx
https://segmentfault.com/a/1190000002963355
解釋的比較詳細。
就挑幾個比較常用的。

// ==================

安裝nginx

brew install nginx

修改配置文件

sudo vim /usr/local/etc/nginx/nginx.conf
    #修改默認的8080端口為80

給予管理員權(quán)限

sudo chown root:wheel/usr/local/opt/nginx/bin/nginx
sudo chmod u+s/usr/local/opt/nginx/bin/nginx

加入launchctl啟動控制

mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

運行nginx

sudo nginx #打開 nginx
nginx -s reload|reopen|stop|quit  #重新加載配置|重啟|停止|退出 nginx
nginx -t   #測試配置是否有語法錯誤

用法詳解

nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

選項列表

-?,-h           : 打開幫助信息
 -v : 顯示版本信息并退出
 -V : 顯示版本和配置選項信息,然后退出
 -t : 檢測配置文件是否有語法錯誤,然后退出
 -q : 在檢測配置文件期間屏蔽非錯誤信息
 -s signal : 給一個 nginx 主進程發(fā)送信號:stop(停止), quit(退出),
reopen(重啟), reload(重新加載配置文件)
 -p prefix : 設(shè)置前綴路徑(默認是:/usr/local/Cellar/nginx/1.2.6/)
 -c filename : 設(shè)置配置文件(默認是:/usr/local/etc/nginx/nginx.conf)
 -g directives : 設(shè)置配置文件外的全局指令
 
// ==========
nginx的使用

每次都要在終端打開nginx
sudo nginx

檢查服務(wù)器路徑
cat /usr/local/etc/nginx/nginx.conf

修改本地服務(wù)器路徑
vi /usr/local/etc/nginx/nginx.conf

在server中修改本地服務(wù)訪問的文件和瀏覽器訪問的域名
server {
        listen       80; 
        server_name  localhost;  //訪問的域名
       root /Users/LIAN/Desktop/DIY/trunk/;  //本地文件地址
       index index.html index.htm; //訪問的文件
}
PS:修改server_name  不能相同  
root 地址就是 新的要運行的html的地址   不能出現(xiàn)中文

在location中修改訪問其他數(shù)據(jù)的接口
 location {
                proxy_pass http://172.99.80.196:9999/;  //其他數(shù)據(jù)接口IP
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

修改本地的hosts
sudo vi /etc/hosts

檢查nginx是不是 已經(jīng)配置成功
sudo nginx -t 

重新加載nginx
sudo nginx -s reload

增加多個域名

    # another virtual host using mix of IP-, name-, and port-based configuration
在此下面進行添加服務(wù)器

server {
        listen       80;
        server_name  TEST.com;
        root /Users/LIAN/Desktop/TEST/trunk/;
        index index.html index.htm;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /ajax-default/ {
                proxy_pass http://172.126.43.101:9999/;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}



問題:
nginx: [error] invalid PID number "" in "/usr/local/var/run/nginx/nginx.pid"
更改方式
sudo nginx -c /usr/local/etc/nginx/nginx.conf
 sudo nginx -s reload
// =============













    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多