配置Nginx遇到Active:inactive (dead)解决方法
问题:
● nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: inactive (dead) Docs: https://nginx.org/en/docs/ Oct 30 23:07:31 iZj6cfjv84u6xjdqohirooZ sh[3175338]: -V, --version output version information and exit Oct 30 23:07:31 iZj6cfjv84u6xjdqohirooZ sh[3175338]: For more details see kill(1). Oct 30 23:07:31 iZj6cfjv84u6xjdqohirooZ systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Oct 30 23:07:31 iZj6cfjv84u6xjdqohirooZ systemd[1]: nginx.service: Failed with result 'exit-code'. Oct 30 23:07:37 iZj6cfjv84u6xjdqohirooZ systemd[1]: Starting nginx - high performance web server... Oct 30 23:07:37 iZj6cfjv84u6xjdqohirooZ systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after start: Operation not permitted Oct 30 23:07:37 iZj6cfjv84u6xjdqohirooZ systemd[1]: Started nginx - high performance web server. Oct 31 18:13:28 iZj6cfjv84u6xjdqohirooZ systemd[1]: Stopping nginx - high performance web server... Oct 31 18:13:28 iZj6cfjv84u6xjdqohirooZ systemd[1]: nginx.service: Succeeded. Oct 31 18:13:28 iZj6cfjv84u6xjdqohirooZ systemd[1]: Stopped nginx - high performance web server.
解决方法:
先运行:service nginx start
再运行:sudo systemctl status nginx
结果:
● nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-10-31 18:36:28 CST; 4min 20s ago Docs: https://nginx.org/en/docs/ Process: 3751102 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 3751103 (nginx) Tasks: 3 (limit: 4423) Memory: 2.8M CGroup: /system.slice/nginx.service ├─3751103 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf ├─3751104 nginx: worker process └─3751105 nginx: worker process Oct 31 18:36:28 iZj6cfjv84u6xjdqohirooZ systemd[1]: Starting nginx - high performance web server... Oct 31 18:36:28 iZj6cfjv84u6xjdqohirooZ systemd[1]: Started nginx - high performance web server.