Was just doing this, and thought it’d be a nice guide to write up.
I’m assuming you already have Apache2 installed on your machine. If not, check how to install Apache 2 on Ubuntu.
Mod_rewrite is a module that allows runtime modification of the URL structure. Typically this is to allow .htaccess directives to implement friendly URLs. This is done frequently in WordPress and many other CMSes.
Link to the Module
Apache 2 on Ubuntu is a bit different than some servers, as Apache is usually controlled in the /etc/apache2 directory.
There will be 2 directories for enabling mods, they are /etc/apache2/mods-enabled and /etc/apache2/mods-available. Mods-enabled includes a list (hopefully links) of files that are enabled via the configuration file (if you look, there’s a command to load all modules in that directory). Mods-available, is all modules you can enable.
To create the link:
ln -s ../mods-available/rewrite.load rewrite.load
That’s ready …
Allow Mod Rewrite
Once you have the module “Enabled” (not yet since we didn’t restart apache, but essentially enabled), you need to let your instance override.
If you go to your /etc/apache2/sites-available folder you can edit the configuration of your site, if not you can do default (this example assumes “default”):
You should see a line that lists your directory before (/home/web/public_html for example) and afterwards it will say “AllowOverride none“. You want to change this so:
[Move cursor to “none”]
[hit Del to remove “none”]
That should change it (you can edit the file however you want, it’s an easy fix).
Simply (at the command prompt):
service apache2 restart