So you’ve installed apache and the rest of your lamp system in Ubuntu, and you’re needing to do some configuring. You’ve got some virtual hosts you need set up and some modules you need enabled. You can dive into the config files and enable everything that way, however apache comes with some nice methods to do this for us. Lets say we want to enable the rewrite module. If you browse the directory structure you will see there is “/etc/apache2/mods-available” and “/etc/apache2/mods-enabled”. This is pretty self explanatory, the trick is mods-enabled directory is really just symbolic links to the modules in mods-available.

Enable Apache Module

Ok, so now that you know the inner workings, here’s how to enable an available module from the terminal without getting our hands too dirty:

sudo a2enmod rewrite

That wasn’t too bad! Also you can run just “a2enmod” and it will print out all available modules and ask you to type in the one you want.

Enable Apache Site/VirtualHost

Ok, now you have a site you need enabled, “mynewsite”. You’ve already added “mynewsite” to your host file (/etc/hosts). Now you would create a new site file in “/etc/apache2/sites-available” called “mynewsite” and add your virtual host config:

sudo pico /etc/apache2/sites-available/mynewsite

I’ll let you handle the details of your new site’s virtual host config and move on. Now we can call apache’s tool to enable this site (essentially tell apache to create a symbolic link in sites-enabled):

sudo a2ensite mynewsite
# running just a2ensite will print available sites and allow you to key in the site you want

And finally restart apache, and we’re done!

sudo apache2ctl restart

Now after all of this if you need to disable a module or site you can run “a2dismod” or “a2dissite” accordingly. Thats it! You’re enabling and disabling apache modules like a pro!