Nginx convert conf.d directory to the sites-available directory setup

Last updated on December 16th, 2022 at 10:54 pm.

To convert an NGINX server from using the conf.d directory to the sites-available directory to store configuration files, you can follow these steps:

  1. Create a sites-available directory if it does not already exist:
sudo mkdir /etc/nginx/sites-available
sudo mkdir /etc/nginx/sites-enabled
  1. Copy the configuration files from the conf.d directory to the sites-available directory:
sudo cp /etc/nginx/conf.d/* /etc/nginx/sites-available/
  1. Create symbolic links from the sites-available directory to the sites-enabled directory for each configuration file:
sudo ln -s /etc/nginx/sites-available/* /etc/nginx/sites-enabled/
  1. Remove the configuration files from the conf.d directory:
sudo rm /etc/nginx/conf.d/*
  1. Modify the include line in the main NGINX configuration file (/etc/nginx/nginx.conf) to include the sites-enabled directory instead of the conf.d directory:
include /etc/nginx/sites-enabled/*;
  1. Restart NGINX to apply the changes:
sudo systemctl restart nginx

This will convert the NGINX server to use the `sites-available directory.


Discover more from Bizanosa

Subscribe to get the latest posts sent to your email.

Comment Here

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!