| 剛剛接手一個WEB項目,就要重新搭建環(huán)境。 首先是使用 Homebrew來安裝所需插件。 http:///index_zh-cn.html 按照此網(wǎng)頁上面的指令進行安裝。 安裝Homebrew之后 安裝Nginx https://segmentfault.com/a/1190000002963355 解釋的比較詳細。 就挑幾個比較常用的。 // ================== 安裝nginx 修改配置文件 給予管理員權(quán)限 加入launchctl啟動控制 運行nginx 用法詳解 選項列表 // ==========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"// ============= | 
|  |