Failed to start A high performance web server and a reverse proxy server 错误提示

本文介绍了一次解决Raspbian系统中Nginx配置文件错误的经历,通过调整server_names_hash_bucket_size设置解决了因虚拟主机配置导致的服务重启失败问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击打开链接

I am running nginx on Raspbian Jessie operating system.

I just created new virtual host and reloaded nginx service:
/etc/init.d/nginx restart
Now I got:
[....] Reloading nginx configuration (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed!
Turns out I can test if the configuration file is OK with:
nginx -t -c /etc/nginx/nginx.conf
This time it says:
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed
Lets check what this setting is in config:
grep server_names_hash_bucket_size /etc/nginx/nginx.conf
And it says that it is not configured:
        # server_names_hash_bucket_size 64;
OK lets increase this as it says:
sed -i "s/^.*server_names_hash_bucket_size..*;$/server_names_hash_bucket_size 64;/" /etc/nginx/nginx.conf
Check again:
grep server_names_hash_bucket_size /etc/nginx/nginx.conf
Its good now:
server_names_hash_bucket_size 64;
Lets test config file:
nginx -t -c /etc/nginx/nginx.conf
This now says:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Got to go:
/etc/init.d/nginx restart
root@iZf8z2slk85lm15so7cuorZ:~# nginx -s reload 2025/03/10 14:49:22 [notice] 201951#201951: signal process started 2025/03/10 14:49:22 [error] 201951#201951: open() "/run/nginx.pid" failed (2: No such file or directory) root@iZf8z2slk85lm15so7cuorZ:~# systemctl status nginx.service × nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Mon 2025-03-10 14:48:30 CST; 1min 21s ago Docs: man:nginx(8) Process: 201838 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 201839 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) CPU: 20ms Mar 10 14:48:28 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:28 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:88 failed (98: Address already in use) Mar 10 14:48:29 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ nginx[201839]: nginx: [emerg] still could not bind() Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: nginx.service: Failed with result 'exit-code'. Mar 10 14:48:30 iZf8z2slk85lm15so7cuorZ systemd[1]: Failed to start nginx.service - A high performance web server and
03-13
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值