>  기사  >  백엔드 개발  >  서버 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/.
    다음 프롬프트가 나타나면 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가 설치됩니다. , 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는 정상적으로 작동합니다. 마지막으로 먼저 nginx 구성 파일을 변경합니다
    chmod 777 file
    file为需要开放权限的文件路径
  5. 구성 파일을 변경한 후 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. nginx -s reload    #重新加载配置
    nginx -s reopen   #重启
    nginx -s stop       #停止
    nginx -s quit        #退出
    위 내용을 포함하여 서버 Mac 설치 nginx 환경을 소개합니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되길 바랍니다.
    选项:
        -?,-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   : 设置配置文件外的全局指令

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.