问题1
服务器上的nginx服务突然报错,导致网站应用都挂掉了。
1.1 报错描述
重启nginx报错信息:
Starting A high performance web server and a reverse proxy server...
Sep 18 09:03:04 ubuntu nginx[139928]: nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/conf.d/mod-http-passenger.conf:2
Sep 18 09:03:04 ubuntu nginx[139928]: nginx: configuration file /etc/nginx/nginx.conf test failed
Sep 18 09:03:04 ubuntu systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Sep 18 09:03:04 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 18 09:03:04 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Sep 18 09:04:42 ubuntu systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive.
执行 sudo nginx -t
错误信息:
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/conf.d/mod-http-passenger.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
1.2 处理方法
1. 重新安装passenger相关
sudo apt-get install -y libnginx-mod-http-passenger
2. 检查nginx配置并重启nginx
# 检查nginx配置
sudo nginx -t
# 输出
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# 重启nginx服务
sudo /etc/init.d/nginx start
参考链接:https://stackoverflow.com/questions/21840707/nginx-unknown-directive-for-passenger-root