Enable or disable a site, hosted with Apache
In Apache web server different virtual host can be created to host different sites. These virtual hosts/sites can be disabled or enabled as required. To enable or disable a site hosted with Apache, you can use the ‘a2ensite’ and ‘a2dissite’ commands, respectively. Both these commands are almost same in syntax:
a2ensite <site>
a2dissite <site>
In this the ‘<site>’ is the name of the site’s Virtual Host configuration file, which is located in ‘/etc/apache2/sites-available/’, without the ‘.conf’ extension.
For example, if your site’s Virtual Host configuration file is called ‘your-website.com.conf’, then the commands would look like</site>
a2ensite your-website.com
a2dissite your-website.com
These commands work perfectly and ensure that everything is always configured correctly.
Always restart Apache after running those commands. The exact command will depend on which Linux distribution you are using, but will most likely be one of the following 2 commands:
sudo systemctl restart apache2
sudo service apache2 restart