mac brew install nginx遇到的坑
默認使用 brew install nginx?出現了一下的錯誤:
?
localhost:testdj newstart$ brew install nginx
==> Installing dependencies for nginx: openssl, pare
==> Installing nginx dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2n.high_sierra.
######################################################################## 100.0%
==> Pouring openssl-1.0.2n.high_sierra.bottle.tar.gz
Error: Failed to create /usr/local/opt/openssl
Things that depend on openssl will probably not build.
Could not symlink .
/usr/local/opt is not writable.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall openssl`
==> 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"' >> ~/.bash_profile
?
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 dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.41.high_sierra.bottl
######################################################################## 100.0%
==> Pouring pcre-8.41.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink .
/usr/local/opt is not writable.
?
You can try again using:
? brew link pcre
==> Summary
?? /usr/local/Cellar/pcre/8.41: 204 files, 5.3MB
==> Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.12.2_1.high_sierra.
######################################################################## 100.0%
==> Pouring nginx-1.12.2_1.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink .
/usr/local/opt is not writable.
?
You can try again using:
? brew link nginx
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall nginx`
==> 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: 25 files, 1MB
localhost:testdj newstart$ /usr/local/webserver/nginx/sbin/nginx -v
-bash: /usr/local/webserver/nginx/sbin/nginx: No such file or directory
localhost:testdj newstart$ /usr/local/Cellar/nginx/sbin/nginx -v
-bash: /usr/local/Cellar/nginx/sbin/nginx: No such file or directory
localhost:testdj newstart$ brew postinstall nginx
==> Postinstalling nginx
Error: Permission denied @ dir_s_mkdir - /usr/local/etc
localhost:testdj newstart$ sudo chown -R $(whoami) /usr/local/etc/
chown: /usr/local/etc/: No such file or directory
localhost:testdj newstart$ sudo chown -R $(whoami) /usr/local
chown: /usr/local: Operation not permitted
localhost:testdj newstart$ sudo chown -R $(whoami) /usr/local/
chown: /usr/local/: Operation not permitted
localhost:testdj newstart$ nginx
-bash: nginx: command not found
localhost:testdj newstart$ sudo nginx
sudo: nginx: command not found
localhost:testdj newstart$?
?
?
然后就是浩浩蕩蕩的解決之路:
?
首先如果出現一些目錄沒有權限的問題:直接使用??sudo chown -R $(whoami) /usr/local/opt(這個目錄就是需要賦予權限的目錄),往后所有需要給目錄賦權限的使用,直接使用這個,比如,提示Error:?Failed to create /usr/local/opt/openssl?直接使用上面的命令
?
1. openssl 無法link成功
在試過很多方法之后,比如 添加 --force 參數,仍舊無解的情況下,google給了我希望
刪除 /usr/local/Cellar/openssl路徑,可是刪除之后重新使用 brew install openssl 仍舊失敗
繼續,刪除?rm -rf /usr/local/opt/openssl
重新使用 brew install openssl。成功
2. 啟動nginx 仍舊失敗
查看只有發現是 沒有 link pcre
使用命令:brew link pcre
3. 這樣修改之后,仍舊失敗
啟動后,顯示
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (2: No such file or directory)
2017/12/26 15:47:00 [emerg] 36666#0: open() "/usr/local/nginx/conf/nginx.conf" failed (2: No such file or directory)
這個時候,執行 brew postinstall nginx
解決
4. 訪問 localhost:8080 顯示成功
?
轉載于:https://www.cnblogs.com/loveyangaddddd/p/8118501.html
總結
以上是生活随笔為你收集整理的mac brew install nginx遇到的坑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hibernate框架学习之使用SQLQ
- 下一篇: 实现安卓里边下边播的播放器(源码公开)