mac下nginx安装

 

一、安装 Nginx

  1. 终端执行:
brew search nginx
brew install nginx

当前版本 1.10.2,通过brew可以把nginx需要的pcre,openssl,zlib全部一键装好。

安装完以后,可以在终端输出的信息里看到一些配置路径:

/usr/local/etc/nginx/nginx.conf (配置文件路径)

/usr/local/var/www (服务器默认路径)

/usr/local/Cellar/nginx/1.10.2_1  (安装路径)

执行nginx -V可以看到安装配置过程的一些选项,能自动化安装,就不要手动安装,不然会有各种出乎意料的问题。

nginx version: nginx/1.10.2
built by clang 8.0.0 (clang-800.0.38)
built with OpenSSL 1.1.0b  26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.10.2_1 --with-http_ssl_module --with-pcre --sbin-path=/usr/local/Cellar/nginx/1.10.2_1/bin/nginx --with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl@1.1/include' --with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl@1.1/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module --with-ipv6

可以通过执行ps -ef | grep nginx快速查看nginx master进程的pid,通过kill来关闭,通过执行nginx -c /user/local/etc/nginx/nginx.conf来重新打开


二、访问localhost:8080

Nginx 默认8080端口,这时已经可以访问了:

localhost:8080

会有一个默认欢迎界面。

原文地址:https://www.cnblogs.com/zlcxbb/p/6413036.html