mac下编译安装nginx,不是homebrew安装
需要先下载pcre,通过官网下载后 运行./configure报以下错误: ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install
需要先下载pcre,通过官网http://www.pcre.org/ SourceForge:下载后(SourceForge:比github下载快,可靠)
解压缩后移动到/usr/local/目录下,进入pcre-8.45
运行./configure报以下错误:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
新建了/usr/local/pcre文件夹,并赋予读写权限,然后
运行sudo ./configure --with-pcre=/usr/local/pcre 通过
然后运行 make ,报以下错误:
wangyuqiang@wangyuqiangdeMacBook-Pro nginx-1.22.0 % sudo make
/Library/Developer/CommandLineTools/usr/bin/make -f objs/Makefile
cd /usr/local/pcre \
&& if [ -f Makefile ]; then /Library/Developer/CommandLineTools/usr/bin/make distclean; fi \
&& CC="cc" CFLAGS="-O2 -pipe " \
./configure --disable-shared
/bin/sh: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre/Makefile] Error 127
make: *** [build] Error 2
运行sudo ./configure --with-pcre=/usr/local/pcre-8.45
路径选错了,哈哈
sudo make
sudo make install
ok
wangyuqiang@wangyuqiangdeMacBook-Pro nginx-1.22.0 % cd objs
wangyuqiang@wangyuqiangdeMacBook-Pro objs % ls
Makefile nginx ngx_auto_config.h ngx_modules.c src
autoconf.err nginx.8 ngx_auto_headers.h ngx_modules.o
wangyuqiang@wangyuqiangdeMacBook-Pro objs % ./nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
2022/09/28 18:08:45 [emerg] 19411#0: mkdir() "/usr/local/nginx/client_body_temp" failed (13: Permission denied)
wangyuqiang@wangyuqiangdeMacBook-Pro objs % sudo ./nginx
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)