Mac上使用brew安装Nginx服务器

时间:2023-03-10 07:14:43
Mac上使用brew安装Nginx服务器

使用brew安装nginx
$ brew install nginx

启动nginx

sudo nginx

访问localhost:8080 发现已出现nginx的欢迎页面了。
Mac上使用brew安装Nginx服务器

为方便期间,做个软连接:

sudo ln -s /usr/local/bin/nginx /usr/bin/nginx #我的mac没有成功,提示没有权限

常用的指令有:

nginx -V 查看版本,以及配置文件地址
nginx -v 查看版本
nginx -c filename 指定配置文件
nginx -h 帮助 打开 nginx
sudo nginx nginx 重新加载配置|重启|停止|退出
nginx -s reload|reopen|stop|quit 测试配置是否有语法错误
nginx -t

例子:

MacBookPro:superlists apple$ ln -s /usr/local/bin/nginx /usr/bin/nginx

ln: /usr/bin/nginx: Operation not permitted
MacBookPro:superlists apple$ sudo nginx
Password:
MacBookPro:superlists apple$ nginx -v nginx version: nginx/1.10.
MacBookPro:superlists apple$ nginx -V nginx version: nginx/1.10.
built by clang 8.0. (clang-800.0.42.1)
built with OpenSSL 1.1.0c Nov
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
 

Mac上使用brew安装Nginx服务器

Nginx安装日志如下:

 MacBookPro:superlists apple$ brew install nginx
Updating Homebrew...
==> Auto-updated Homebrew!
Updated tap (homebrew/core).
==> New Formulae
cnats mingw-w64-binutils opencoarrays
imagemagick@ molecule watchexec
==> Updated Formulae
abcde gitup mongoose
afl-fuzz gnupg-pkcs11-scd openshift-cli
ansible godep orientdb
aria2 groonga pius
arping gtk+ pngcrush
aws-sdk-cpp h2o pyenv
awscli htmlcleaner rocksdb
certbot httrack speedtest_cli
deis hyperscan sshguard
deisctl ios-webkit-debug-proxy swaks
docker-compose iso-codes swiftformat
docker-machine kobalt tcpkali
docker-machine-nfs libgcrypt tomcat
dpkg libgtop vim
eiffelstudio libtasn1 xz
fabio libxc yank
flow lighttpd yash
fossil logentries youtube-dl
fwup makeself ==> Installing dependencies for nginx: pcre, openssl@1.1
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.39.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pcre-8.39.sierra.bottle.tar.gz