nginx:nginx.service的作业失败,因为控制进程已退出,并返回错误代码
已解决(见下面我的答案) 当我在可用站点和已启用站点中添加新的nginx configedu.conf时,nginx就死了 我无法重新启动服务,所有网站都无法工作 当我键入nginx:nginx.service的作业失败,因为控制进程已退出,并返回错误代码,nginx,Nginx,已解决(见下面我的答案) 当我在可用站点和已启用站点中添加新的nginx configedu.conf时,nginx就死了 我无法重新启动服务,所有网站都无法工作 当我键入sudo nginx-t-c/etc/nginx/sites available/edu.conf或在我的任何其他nginx配置上键入相同的命令时,它会抛出错误: nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-availa
sudo nginx-t-c/etc/nginx/sites available/edu.conf
或在我的任何其他nginx配置上键入相同的命令时,它会抛出错误:
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-available/edu.conf:1
nginx: configuration file /etc/nginx/sites-available/edu.conf test failed
我已经有了与edu.conf相同的nginx配置,我只是更改了根文件夹和服务器名称
如果我检查以前任何一个完全正常的文件的语法错误,它会在所有文件的第一行抛出一个错误。即使是默认的
sw@asd:/etc/nginx/sites-available$ sudo nginx -t -c /etc/nginx/sites-available/magento2.conf
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-available/magento2.conf:1
nginx: configuration file /etc/nginx/sites-available/magento2.conf test failed
sw@asd:/etc/nginx/sites-available$ sudo nginx -t -c /etc/nginx/sites-available/default
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/default:16
nginx: configuration file /etc/nginx/sites-available/default test failed
下面是我添加的edu.conf:
upstream fastcgi_backend {
server unix:/var/run/php/php7.0-fpm.sock;
# Or TCP
# server 127.0.0.1:9000;
}
server {
listen 80;
server_name edu.dev;
set $MAGE_ROOT /var/www/html/mg;
set $MAGE_MODE developer;
include /var/www/html/mg/nginx.conf.sample;
}
实际配置正在运行,问题出在Magento 2配置中。我必须更改
root$MAGE_root/pub代码>到根$MAGE\u根位于Magento 2根目录中的nginx.conf.sample中的code>。或者我必须像这样键入URLedu.dev/setup
,而不是edu.dev
它们不是完整的配置文件。它们打算包含在http{}
块中的nginx.conf
中。我有一个与之相同的块,它与magento 2安装完全兼容。文件很好,但是您不能在命令行中指定它-它需要包含在nginx.conf
中,这就是nginx
通常的启动方式。@RichardSmith我不明白我需要做什么。我有默认的nginx配置,我为magento 2添加了一个,它与我现在遇到的问题完全一样,工作完全正常,我没有做任何其他事情。我确实添加了相同的文件,但只是重命名了它并更改了配置,以便用于不同的安装。配置通常包含在站点启用
目录中的符号链接中。为活动配置添加来自可用站点的符号链接,并删除不再需要的配置的任何符号链接。