1

SOLVED (see my answer below)

When I added a new nginx config edu.conf in sites-available and sites-enabled, nginx just died.

I cant restart service and all sites wont work.

When I type sudo nginx -t -c /etc/nginx/sites-available/edu.conf or the same command on any other of my nginx configs it throws error:

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 

I already had nginx config that was identical to the edu.conf, I just changed the root folders and server name.

If I check for syntax errors on any of previous files that were completely fine it throws a error on first line on all of them. Even the default one.

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 

Here is the edu.conf that I added:

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; } 
13
  • 1
    They are not complete configuration files. They are intended to be included into nginx.conf, within an http {} block. Commented Jan 23, 2017 at 12:24
  • 1
    I have one that is identical to it and it works completely fine with a magento 2 installation. Commented Jan 23, 2017 at 12:39
  • 1
    The file is fine, but you cannot specify it on the command line - it needs to be included from within nginx.conf which is how nginx usually starts up. Commented Jan 23, 2017 at 12:44
  • @RichardSmith I don't understand what I need to do. I had the default nginx conf, I added one for a magento 2 that is exactly like the one I am having problems now with and it worked completely fine, I didn't do anything else. I literally added the same file, but just renamed it and changed config so that it's for a different installation. Commented Jan 23, 2017 at 13:06
  • Configurations are usually included from symbolic links in the sites-enabled directory. Add a symlink from sites-available for your active configurations and remove any symlinks for configurations you no longer require. Commented Jan 23, 2017 at 14:27

1 Answer 1

1

The actual config was working, the problem was in the Magento 2 config. I had to change root $MAGE_ROOT/pub; to root $MAGE_ROOT; in nginx.conf.sample that is located in Magento 2 root directory. Or I had to type URL like this edu.dev/setup instead of edu.dev.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.