20Jun/075
Activating mod_rewrite on Apache @ Ubuntu
I can usually find my way through Server configuration files fairly easy, but upon installing a LAMP server on Ubuntu I noticed "mod_rewrite" wasn't working at all. The answer ended up being fairly simple, once you know where to look, but for others not to struggle as I did I'll post what and where to look.
Ubuntu's Apache is quite modularized; both in packages and in runtime senses. This has several advantages which I wont mention here, but forces you to edit several configuration files to make adjustments.
Here's the ABC to it:
- Add a loader to mod_rewrite module:
Execute (on the shell):
sudo a2enmod rewrite - Edit the apache2.conf by adding a call:
On ubuntu this file usually sits on: /etc/apache2/apache2.conf
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
Note: you can also add this on the .htaccess files. - Edit the virtual host file:
To know what hosts are enabled take a look at:
/etc/apache2/sites-enabled/
There you'll see a simlink to some file(s) sitting at:
/etc/apache2/sites-available/
which you'll have to edit.
You need to add the permissions for your directorie(s):
<Directory />Note: you can set this values for the root directory (as in this example) or for just 1 or more folders / sub-folders.
Options FollowSymLinks
AllowOverride All
</Directory> - Restart your Apache:
sudo /etc/init.d/apache2 force-reload
or
sudo apache2ctl restart
That should do the trick!