MAC安装nginx教程
2018-01-31 00:30
519 查看
苹果电脑MAC安装nginx教程
最近在搭建Tomcat + Nginx 集群时,安装nginx遇到了点小问题,在这里记录下,方便大家参考Mac下用brew安装nginx
- 可参考文章:https://www.jianshu.com/p/6c7cb820a020
1、首先讲下,Mac下用brew 默认默认默认 安装nginx — 只想说坑爹
首先想到的是上网找nginx的安装办法。可是事事不如人意,安装过程中各种依赖没有。无奈之下想到如果用brew来安装的话就可以避免自己去安装这些依赖。 下面是brew的安装方法:(由于MAC自带ruby,所以安装起来极其轻松) ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 一行命令直接搞定... 那么接下来就来安装nginx吧。 在终端输入以下命令,即可安装: brew install nginx (或者 /usr/local/bin/brew install nginx) 过后等着就行了。会自动安装pcre和ssl等~ 成功后,配置你的nginx...
2、简单说下这种静默安装的坑爹地方在哪
可能有强迫症吧...... 先上代码,给大家看下小子Mac下 默认安装位置,是不是感觉很坑爹,反正我是不习惯果断卸载,使用离线安装~ able@localhost:/usr/local/bin $ nginx -V (大写的V,查看版本,以及配置文件地址) nginx version: nginx/1.12.1 built by clang 9.0.0 (clang-900.0.37) built with OpenSSL 1.1.0f 25 May 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/Cellar/nginx/1.12.1 --with-http_ssl_module --with-pcre --sbin-path=/usr/local/Cellar/nginx/1.12.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 110a7 /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-http_v2_module 关键关键在于 我找不到它们所以不习惯,Linux安装习惯了指定目录,这里就不说什么了卸载吧! 问题关键在于还卸载不干净 需要手动删除的目录: 1、cd /usr/local/var/ 目录下的 www目录 2、cd /usr/local/etc/ 目录下的 nginx目录 命令如下: able@localhost:/usr/local/var $ rm -R www able@localhost:/usr/local/etc $ rm -R nginx
3、小子Mac使用brew安装nginx,全过程
able@localhost:/Users/able $ brew install nginx Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> New Formulae ballerina coreos-ct qtkeychain shogun ==> Updated Formulae apm-server elasticsearch jhipster log4cplus packetbeat python-markdown terragrunt auditbeat filebeat kibana logentries picard-tools rabbitmq vagrant-completion bit harfbuzz ledit logstash plantuml rakudo-star vala carthage heartbeat librealsense makensis presto rtags zanata-client conan i2p libtrng metricbeat prips sccache ==> Installing dependencies for nginx: openssl ==> Installing nginx dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2n.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring openssl-1.0.2n.high_sierra.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include ==> Summary �� /usr/local/Cellar/openssl/1.0.2n: 1,792 files, 12.3MB ==> Installing nginx ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.12.2_1.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring nginx-1.12.2_1.high_sierra.bottle.tar.gz ==> Caveats Docroot is: /usr/local/var/www The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo. nginx will load all files in /usr/local/etc/nginx/servers/. To have launchd start nginx now and restart at login: brew services start nginx Or, if you don't want/need a background service you can just run: nginx ==> Summary �� /usr/local/Cellar/nginx/1.12.2_1: 23 files, 1MB
下面介绍方法一:
使用源文件(离线)进行安装,可以不翻墙以下是在Mac OS X 10.13.3 安装nginx步骤
1.安装PCRE
PCRE 作用是让 Ngnix 支持 Rewrite 功能。1、下载PCRE安装包 地址:http://www.pcre.org/
1、Download latest PCRE. 2、安装 $ cd ~/Downloads ##当然你的pcre源文件是下载到了Downloads目录 $ tar xvzf pcre-8.5 ##版本可能不同pcre-8.5 $ cd pcre-8.5 $ sudo ./configure --prefix=/usr/local $ sudo make $ sudo make install 或者 $ make && make install 3、查看pcre版本 $ pcre-config --version
注意:如果Mac在2017年升级macOS High Sierra 10.13.3
在安装pcre时会提示:xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun.
解决办法:
打开终端,然后运行以下命令:
$ xcode-select --install
这将下载并安装xcode开发人员工具并解决问题。问题是需要明确同意许可协议。
2.安装Nginx
1、Download latest nginx from Nginx.org. 2、安装 $ cd ~/Downloads $ tar xvzf nginx-1.6.0.tar.gz $ cd nginx-1.6.0 $ sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations" $ sudo make $ sudo make install
3.开启Nginx
1、将/usr/local/nginx/sbin加入到环境变量里 2、运行 $ sudo nginx 3、打开浏览器 http://localhost,如果看到如下界面表明nginx启动正常了
4.停止
$ sudo nginx -s stop
下面介绍方法二:
使用homebrew安装,提醒需要翻墙,前面介绍的源码安装方式不需要翻墙,只需要在从网上下载源码、编译、安装即可,建议先确认一下自己能否翻墙,如果可以翻墙就用第二种方法,如果不能就用第一种。。。brew search nginx brew install nginx
启动nginx ,sudo nginx启动nginx ;然后,访问localhost:8080 发现已出现nginx的欢迎页面了,说明nginx安装成功
– 备注: ln -s /usr/local/sbin/nginx /usr/bin/nginx 做个软连接。
常用的指令有:
nginx -V 查看版本,以及配置文件地址 nginx -v 查看版本 nginx -c filename 指定配置文件 nginx -h 帮助 nginx -s reload|reopen|stop|quit 重新加载配置|重启|停止|退出 nginx
打开 nginx
sudo nginx
测试配置是否有语法错误
nginx -t
另外附上Mac安装brew命令:
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
当brew安装成功后,就可以随意安装自己想要的软件了,例如wget,命令如下:
sudo brew install wget
当卸载的话,命令如下:
sudo brew uninstall wget
当查看安装软件的话,命令如下:
sudo brew search /apache*/
注意/apache*/是使用的正则表达式,用/分割。
相关文章推荐
- 苹果电脑mac安装nginx教程
- mac brew 安装 nginx fpm mysql 教程
- mac上安装Nginx详细教程
- Windows、mac字体安装教程
- Spark简要教程系列(一) Mac安装Spark
- Nginx教程-安装
- linux环境下安装nginx教程
- mac 下phpstorm 安装教程
- 【破解向】Mac版Adobe Photoshop CS6 与破解补丁下载–注册机+序列号+修改HOSTS完美可升级激活法及详细图文安装教程(强烈推荐)
- 1.4.2.PHP5.6 女神级教程-女神的成长环境(Mac下 PHP开发环境 配置及安装 php5.6.x nginx mysql)
- 在Mac上安装nginx
- 在Mac OS X上安装使用mysql图文详细教程
- 在Mac OS X上安装 Ruby运行环境 CocoaPods安装和使用教程
- mac下安装nginx和php
- VMware9虚拟机安装MAC OS X Mountain Lion 10.8.2详细图文教程
- Linux下安装Nginx详细图解教程
- mac上安装ubuntu双系统教程
- 011 Linux下编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14教程。
- mac安装nginx
- Mac 操作系统安装 SVN 服务器教程(Subversion With Mac OS X Tutorial)