Simple commands to manage apache2 sites and Modules | Ubuntu Geek This tutorial will explain some useful commands to manage apache2 sites and Modules
Apache2 Configuration Files Location
First we will explain what is there under /etc/apache2/ directory
sites-available - A list of configuration files - one per site. A blank install will contain the file default. The system admin can have as many sites here as they need - however - they will not all be active.
sites-enabled - A list of symlinks to configuration files in sites-available. A blank install will contain a symlink 000default to sites-available/default. The sites listed here are the sites which will be active. The site to be used if no virtual hosts match will be the first file found (hence the 000 on 000default).
mods-available - A list of configuration files - one or more per module. Each dpkg installed module will add files here. e.g. php4.conf and php4.load are added with the libapache2-mod-php package. Again - the system admin can install whatever modules they wish - however - until they are set available they will not be active.
mods-enabled - A list of symlinks to configuratioon files in modes-available. Only modules linked in here will be activated on the webserver.
Commands to use
a2ensite - a2ensite is a script that enables the specified site (which contains a <VirtualHost> block) within the apache2 configuration. It does this by
creating symlinks within /etc/apache2/sites-enabled.
Example
sudo a2ensite test
Note:- Test is the file you have created under /etc/apache2/sites-enabled/ with the required configuration
a2dissite - a2dissite is a script that disables the specified site (which contains a <VirtualHost> block) within the apache2 configuration. It does this by removing symlinks within /etc/apache2/sites-enabled.
Example
sudo a2dissite test
a2enmod - a2enmod is a script that enables the specified module within the apache2 configuration. It does this by creating symlinks within /etc/apache2/mods-enabled.
Example
sudo a2enmod imagemap
Enables the mod_imagemap module
a2dismod - a2dismod is a script that disables the specified module within the apache2 configuration. It does this by removing symlinks within /etc/apache2/mods-enabled.
Example
sudo a2dismod mime_magic
Disables the mod_mime_magic module.
You can check the list of available modules under /etc/apache2/mods-available