Debian11安装nginx编译出错
make && make install 时报错:
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:617: objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory ‘/home/tools/install/tengine-2.2.2’
make[1]: *** [objs/Makefile:923: objs/src/os/unix/ngx_user.o] Error 1
方法1:vim objs/Makefile:
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g -DNDK_SET_VAR
-Werror -g去掉
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused -DNDK_SET_VAR
sed -i “s/ -Werror -g / /g” ./objs/Makefile
方法2 修改 /src/os/unix/ngx_user.c文件;
注释掉cd.current_salt[0] = ~salt[0];
make && make install 就不会报错了。
Nginx脚本安装完毕服务没起来,挺意外的。
root@mytest:/etc/nginx/sites-enabled# systemctl status nginx
Warning: The unit file, source configuration file or drop-ins of nginx.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: bad-setting (Reason: Unit nginx.service has a bad unit file setting.)
Active: inactive (dead)
journalctl -xefu nginx 查看日志:
May 13 11:35:46mytest systemd[1]: /etc/systemd/system/nginx.service:7: PIDFile= references a path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit f>
May 13 11:35:46mytest systemd[1]: /etc/systemd/system/nginx.service:12: Unknown key name ‘ExecQuit’ in section ‘Service’, ignoring.
May 13 11:35:46mytest systemd[1]: /etc/systemd/system/nginx.service:28: Unknown key name ‘ExecQuit’ in section ‘Service’, ignoring.
May 13 11:35:46mytest systemd[1]: nginx.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.
May 13 11:35:47mytest systemd[1]: /etc/systemd/system/nginx.service:7: PIDFile= references a path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit f>
tail -100f /var/log/syslog
May 13 11:35:47mytest systemd[1]: nginx.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.
发现问题了,原来注册nginx服务时候,设置重复了
cat >>/etc/systemd/system/nginx.service <<EOF
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop
ExecQuit=/usr/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
调整完 systemctl daemon-reload就可以启动了。