美文网首页
mac 安装nginx

mac 安装nginx

作者: 卓三阳 | 来源:发表于2018-07-11 00:06 被阅读28次
    一.下载压缩包安装

    1.首先安装PCRE
    PCRE 作用是让 Nginx 支持 Rewrite 功能。
    (1)下载PCRE, 可以自己去官网下载下来,也可以通过下面的命令来下载(前提你安装了wget)
    ➜ ~ wget http://downloads.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz

    (2)解压安装包

    ➜  ~    cd Downloads 
    ➜  Downloads    tar zxvf pcre-8.42.tar.gz 
    

    (3)进入安装包目录

    ➜  Downloads   cd pcre-8.42
    

    (4) 编译安装

    ➜  pcre-8.42 ./configure --prefix=/usr/local
    ➜  pcre-8.42  make  
    ➜  pcre-8.42  make install
    

    (5)查看pcre版本

    ➜  pcre-8.42 pcre-config --version                 
    8.42
    

    2.安装nginx
    (1)下载nginx, 可以自己去官网下载下来,也可以通过下面的命令来下载
    ➜ ~ wget http://nginx.org/download/nginx-1.15.0.tar.gz

    (2)解压安装包

    ➜  ~    cd Downloads 
    ➜  Downloads    tar zxvf nginx-1.15.0.tar.gz
    

    (3)进入安装包目录

    ➜  Downloads   cd  nginx-1.15.0
    

    (4) 编译安装

    ➜  nginx-1.15.0 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations"
    ➜  nginx-1.15.0  make  
    ➜  nginx-1.15.0  make install
    

    (5)查看nginx版本

    ➜  nginx-1.15.0  nginx -v        
    nginx version: nginx/1.15.0
    

    二.通过Homebrew安装,简单快捷
    ➜  ~  brew install nginx
    

    1.我就是通过这种方式安装,安装目录在/usr/local/Cellar/nginx

    nginx.png

    我们看到html是一个链接文件,指向/usr/local/var/www

    2.配置文件在/usr/local/etc/nginx

    confgig.png
    三.使用nginx

    常用的指令有:

    1. nginx -V 查看版本,以及配置文件地址
    2. nginx -v 查看版本
    3. nginx -c filename 指定配置文件
    4. nginx -h 帮助

    重新加载配置|重启|停止|退出 nginx
    nginx -s reload|reopen|stop|quit

    打开 nginx
    sudo nginx

    测试配置是否有语法错误
    nginx -t

    相关文章

      网友评论

          本文标题:mac 安装nginx

          本文链接:https://www.haomeiwen.com/subject/fxaqpftx.html