nginx:worker_proccesses 指令不起作用

use*_*529 11 nginx

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

nginx: [emerg] "worker_processes" 指令在 /etc/nginx/sites-enabled/default:1 中是不允许的:配置文件 /etc/nginx/nginx.conf 测试失败

这是我的代码

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/;
Run Code Online (Sandbox Code Playgroud)

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

Mic*_*ton 23

你说你的错误信息是:

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
Run Code Online (Sandbox Code Playgroud)

将此指令放在 of/etc/nginx/nginx.conf而不是 in的顶部/etc/nginx/sites-enabled/default。该worker_processes指令仅在配置的顶层有效。

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