Nginx missing sites-available directory in the Nginx configuration directory

Date: 03-04-2021

Once you installed Nginx on Centos 7 to set up virtual host files, you are unable to find the /etc/nginx/sites-available in /etc/nginx directory. You can follow the below steps to enable this option.

Step 1: Create the below directories in the nginx configuration directory. /etc/nginx/sites-availabe and /etc/nginx/sites-enabled.

Step 2: Open /etc/nginx/nginx.conf file and edit to add blow line in http block.
include /etc/nginx/sites-enabled/*;

Step 3: Restart the nginx service by using below command
#systemctl restart nginx

Step 4: Now you can create vhost file inside sites-available and you can create a symlink for them inside sites-enabled for those you want enabled.

Step 5: If you prefer a more direct approach to create vhost file without symlinking between sites-available and sites-enabled, you can follow below steps.
1. Create the conf.d directory in /etc/nginx if it doesn’t already exist and make sure to give it the right permissions/ownership like root or www-data.
2. Open /etc/nginx/nginx.conf file and edit to add blow line in http block.
include /etc/nginx/conf.d/*.conf;
3. Create your separate config files like domain name.conf into the directory conf.d
4. Restart the nginx service.

Thank you!

Leave a Reply