伺服器 mac安裝nginx環境

WBOY
發布: 2016-08-08 09:27:25
原創
929 人瀏覽過

前段時間接觸到了代理伺服器,在摸索下搭建了nginx環境,接下來給大家介紹一下在mac上安裝nginx環境的基本步驟。

  1. 本文是利用homebrew來安裝nginx,先打開終端機輸入安裝命令列
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    登入後複製
    來安裝homebrew。官網:http://brew.sh/ 。
    若出現以下提示,表示mac已安裝nginx或上一次安裝nginx失敗留下殘餘
    It appears Homebrew is already installed. If your intent is to reinstall you
    should do the following before running this installer again:
        rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    登入後複製
    按照提示輸入刪除命令列:
    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    登入後複製
    刪除後,再輸入安裝命令列。
  2. 下載homebrew後會自動安裝homebrew,用brew一鍵安裝nginx
    brew install nginx
    登入後複製
  3. 安裝後測試nginx權限是否能正常工作
    nginx -t
    正确提示:nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
             nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
    登入後複製
  4. 安裝後測試nginx權限權限
    chmod 777 file
    file为需要开放权限的文件路径
    登入後複製
  5. nginx能正常運作後,先更改nginx的設定檔
    vim /usr/local/etc/nginx/nginx.conf
    登入後複製
    server {
            listen       9999(自定义端口号);
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   /Users/loki/Desktop/web/(需要部署应用的文件路径);
                index  index.html index.htm;
            }
    登入後複製
  6. 設定檔更改完,啟動nginx
    sudo nginx
    登入後複製
  7. 以上就介紹了伺服器 mac安裝nginx環境,包括了方面的內容,希望對PHP教學有興趣的朋友有幫助。
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!