0

I want to build and test my website on my Arch Linux computer.

The contents of the website, including index.html, are in /srv/http/myproject/.

/etc/nginx/sites-available/myproject.conf looks like this...

server {
        listen 80;
        listen [::]:80;
        root /srv/http/myproject;
        index index.html index.htm;
        server_name myproject.local;

   location / {
       try_files $uri $uri/ =404;
   }    
}

UPDATE: I had already ran ln -s /etc/nginx/sites-available/myproject.conf /etc/nginx/sites-enabled/myproject.conf.

And /etc/hosts has this...

127.0.0.1 myproject.local

But when I navigate to http://myproject.local/, all I see is the "Welcome to nginx" page.

7
  • 2
    Please be more specific about won't connect. What is the exact error message you encounter? And did you create a symlink to your .conf in sites-enabled? – Gerald Schneider Aug 27 '20 at 7:23
  • You need to create a server block for the hostname you are trying to use. – Michael Hampton Aug 30 '20 at 0:54
  • @MichaelHampton How must that code look in this case? – Username Aug 30 '20 at 16:30
  • server_name the_real_name;. – Michael Hampton Aug 30 '20 at 16:36
  • @MichaelHampton When I replaced server_name myproject.local with server_name myproject in the server block that changed nothing. – Username Aug 30 '20 at 19:05
4

You have to enable the website.

ln -s /etc/nginx/sites-available/myproject.conf /etc/nginx/sites-enabled/myproject.conf

And the ofcourse, restart/reload nginx.

3
  • Forgot to mention I already ran that. Updated my question to reflect that. – Username Aug 29 '20 at 22:55
  • You have added "myproject.local" to your hostfile, and added "myproject.local" as a servername - but you are trying to navigate to "predictit-monitor.local" ? – Orphans Aug 30 '20 at 13:43
  • Whoops, updated my question. – Username Aug 30 '20 at 16:29
2

How about just 127.0.0.1 myproject.local in the /etc/hosts? In my experience it would not necessary the semicolon in the end of line

1
  • Updated my question to reflect that. – Username Aug 29 '20 at 22:55
1

I needed to include include /etc/nginx/sites-enabled/*; in the http block of /etc/nginx/nginx.conf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.