ホームページ  >  記事  >  バックエンド開発  >  サーバー Mac インストール nginx 環境

サーバー Mac インストール nginx 環境

WBOY
WBOYオリジナル
2016-08-08 09:27:25919ブラウズ

少し前にプロキシサーバーに接続し、試行錯誤してnginx環境をセットアップしました。 次に、Macにnginx環境をインストールする基本的な手順を紹介します。

  1. この記事では homebrew を使用して nginx をインストールします。まずターミナルを開き、インストールコマンドライン
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    を入力して homebrew をインストールします。公式ウェブサイト: http://brew.sh/。
    次のプロンプトが表示された場合は、nginx が Mac にインストールされているか、前回のインストール失敗で 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をダウンロードした後、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. Basic nginx の使用法
    nginx -s reload    #重新加载配置
    nginx -s reopen   #重启
    nginx -s stop       #停止
    nginx -s quit        #退出
    选项:
        -?,-h           : 打开帮助信息
        -v              : 显示版本信息并退出
        -V              : 显示版本和配置选项信息,然后退出
        -t              : 检测配置文件是否有语法错误,然后退出
        -q              : 在检测配置文件期间屏蔽非错误信息
        -s signal       : 给一个 nginx 主进程发送信号:stop(停止), quit(退出), reopen(重启), reload(重新加载配置文件)
        -p prefix       : 设置前缀路径(默认是:/usr/local/Cellar/nginx/1.2.6/)
        -c filename     : 设置配置文件(默认是:/usr/local/etc/nginx/nginx.conf)
        -g directives   : 设置配置文件外的全局指令

上記はサーバー Mac の nginx 環境を内容も含めて紹介したもので、PHP チュートリアルに興味のある友人に役立つことを願っています。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。