如何在mac下安装nginx反向代理
在Mac安装的时候比较简单
brewinstallnginx
在安装好后,按以往的经验直接sudonginx,结果报错了。
dyld:Librarynotloaded:/usr/local/lib/libpcre.1.dylib
Referencedfrom:/usr/local/bin/nginx
Reason:imagenotfound
Google之,运行brewdoctor。再次显示错误。
Warning:YouhaveunlinkedkegsinyourCellar
Leavingkegsunlinkedcanleadtobuild-troubleandcausebrewsthatdependon
thosekegstofailtorunproperlyoncebuilt.Run`brewlink`onthese:
mackup
按照提示去运行brewlinkmackup和brewlinkpcre。
这样就算是安装好了。
根据查到的资料,要做一个配置文件。
events{
worker_connections1024;
http{
server{
listen9000;
server_namelocalhost;
location/{
root/Users/limi/code/hypclass-webpage/run/;#网站的跟路径
indexindex.htmlindex.htm;
这是最精简的配置了,不过好像nginx配置网站的地址只支持绝对路径。
然后看了一下官方的指南把启动命令改了,貌似正确的是这样。
sudonginx-c/Users/limi/code/website/nginx.conf
到此浏览器输入,正常显示了。
最后要把nginx关掉,再次查看文档查命令。
nginx-sstop
nginx-squit
貌似都可以关闭,至于有什么区别,日后在看。
本回答由提问者推荐
mac 编译安装nginx需要指定group和user吗
你可以用这两个命令,找安装启用的路径netstat-tnlp|grepnginx然后看到一行记录,复制最后的一个数据(进程ID)ps-aux|grep进程ID就可以看到NINGX的启动方式了。如果你现在不知道,并且没重动NIGNX,则可以find/|grepnginx.conf