noblemfd's avatar

nginx: configuration file /etc/nginx/nginx.conf test failed

I uploaded Laravel-5.8 projects to the DigitalOcean Server using Ubuntu. The site is running very well. Later I decided to create virtual hosts to be able to host multiple applications on the same server.

I followed this link:

https://graspingtech.com/nginx-virtual-hosts-ubuntu-16-04/

Now I did:

root@MyServer: cp /etc/nginx/sites-available/default /etc/nginx/sites-available/site1.conf
root@MyServer: cp /etc/nginx/sites-available/default /etc/nginx/sites-available/site2.conf

Then

root@MyServer: ln -s /etc/nginx/sites-available/site1.conf	/etc/nginx/sites-enabled/
root@MyServer: ln -s /etc/nginx/sites-available/site2.conf	/etc/nginx/sites-enabled/

Then when I did:

root@MyServer: nginx -t

I got this error:

nginx: configuration file /etc/nginx/nginx.conf test failed

This is the content of /etc/nginx/nginx.conf

ser www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;

# set client body size to 5M #
client_max_body_size 24000M;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

How do I resolve this?

Thank you

0 likes
2 replies
zaster's avatar
zaster
Best Answer
Level 9

@noblemfd check your site1.conf and site2.conf check for proper spacing , semicolons , typos etc...

Please or to participate in this conversation.