解决nginx启动报错nginx: [emerg] open() “/var/run/nginx/nginx.pid“ failed (2: No such file or directory)
vi /usr/local/nginx/conf/nginx.conf
修改:
pid /usr/local/nginx/logs/nginx.pid;
将 注释去掉,修改为绝对路径
mkdir /usr/local/nginx/logs
完事后,启动nginx即可
一个疑问:为什么我的nginx是安装在 /usr/local 呢?
原因是在进行configure 操作的时候指定的--prefix=/usr/local/nginx
这个命令为什么这么长,原因是需要指定nginx中是否安装其他的插件,好比是买手机是否有其他的配件。
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-http_stub_status_module