Is seems that I having issues with the step 5. The server fails to restart after sudo nginx -t . https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04#step-5-setting-up-server-blocks-(recommended)
I tried reinstalling NGINX without completing “Step 5 – Setting Up Server Blocks (Recommended)”. I just copy pass my entire web server files in the HTML directory and it works just fine. Is Step 5 really necessary? Is their a better way than Step 5 because obviously this step is buggy and untested?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, @SephiaSky
I’ve followed the tutorial on a fresh droplet and everything went all good without any issues. Do you get any syntax errors when you check the Nginx configuration using the command you’ve mentioned:
sudo nginx -t
You can skip the part with the creation of the site’s files, e.g the HTML file for the index page and go and setup directly the server block:
/etc/nginx/sites-available/example.com
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
}
then enable the file by creating the symlink
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
and then tweaking the nginx config file:
/etc/nginx/nginx.conf
Let me know if you have any questions.
Regards, Alex
Thanks for the reply! I managed to get it to work earlier. It was some typos I missed in the config file plus files aren’t in the correct location. Nginx won’t work if you didn’t follow the correct syntax.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.