nginx:用户指令不起作用

我想尝试在nginx中设置工作进程,但是却抛出了这个错误:

nginx:[emerg]“worker_processes”指令在/ etc / nginx / sites-enabled / default中不允许:1 nginx:configuration文件/etc/nginx/nginx.conftesting失败

这是我的代码

worker_processes 4; worker_rlimit_nofile 8192; worker_priority 0; worker_cpu_affinity 0001 0010 0100 1000; server { server_name --.--.--.---; listen 80; #root /var/www/devsites/wordpress/; root /var/www/devsites/trademob/tm-hp-v2/; 

我能做些什么来解决这个问题?

你说你的错误信息是:

 nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/sites-enabled/default:1 nginx: configuration file /etc/nginx/nginx.conf test failed 

将此指令放在/etc/nginx/nginx.conf的顶部,而不是放在/etc/nginx/sites-enabled/defaultworker_processes指令仅在configuration的顶层有效。

这同样适用于您使用的所有其他worker_*指令。

你的configuration文件中有一个语法错误:

 worker_rlimit_ nofile 8192; 

看来这条线被意外分裂了。 它应该显示为:

 worker_rlimit_nofile 8192; 

worker_cpu_affinity开头的行似乎也发生了同样的错误。

一旦你解决这个问题,你应该让你的服务器备份和运行。