[emerg] open() “/usr/local/Cellar/nginx/1.17.10/logs/error.log“ failed (2: No such file or directory
启动nginx时报:[emerg] open() "/usr/local/Cellar/nginx/1.17.10/logs/error.log" failed (2: No such file or directory)
解决办法是去/usr/local/Cellar/nginx/1.17.10/ 目录下,先创建logs目录,然后再新建error.log文件
启动nginx时报:[warn] 1024 worker_connections exceed open file resource limit: 256
worker_connections: 单个后台worker process进程的最大并发链接数worker_connections;
控制台执行:ulimit -a,显示如下,将红色字的变量改为1024即可,使用命令ulimit -n 1024。
然后重启
重启时报:nginx: [error] open() "/usr/local/Cellar/nginx/1.21.4/logs/nginx.pid" failed (2: No such file or directory)
使用nginx -c的参数指定nginx.conf文件的位置
找到nginx 的bin目录,然后输入pwd复制文件目录加上nginx
输入:sudo /usr/local/Cellar/nginx/1.21.4/bin/nginx -c /usr/local/etc/nginx/nginx.conf
进入logs目录,查看,已经生成好了,然后重启nginx
重启后,访问localhost,成功!