If you install official version of Nginx from their repository, you'll find that there was no any sites-available
and sites-enabled
directory like in Apache. Good news is, you can add it yourself !
- Create a new directory under
/etc/nginx
.
sudo mkdir /etc/nginx/sites-{available,enabled}
- Append below line
include /etc/nginx/sites-enabled/*; #APPEND THIS
To /etc/nginx/nginx.conf
, so the block would look like.
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; #APPEND THIS
}
- Make sure your configuration is okay and doesn't throw any error, test it.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
- If you want to enable a sites manually, you can do so by symlink it to
sites-enabled
directory/
sudo ln -s /etc/nginx/sites-available/{yoursite} /etc/nginx/sites-enabled/{yoursite}temp