LAMP installation on Ubuntu with Mod_Rewrite
So there is plenty of information out there about installing a standard LAMP server out there.
I’ve had a LAMP server on my Ubuntu laptop for quite some time. But i ran into troubles when I wanted to have a CakePHP installation on my local machine because I couldn’t get Apache’s mod_rewrite to work.
I’ve finally figured it out, and, given the difficulty I had finding the information I thought I should probably share my experience with the world.
So, firstly, installing LAMP. In case you’d missed it, LAMP stands for Linux, Apache, MySQL, PHP.
You’ve already got the Linux part, so I just went through the Synaptic Package Manager and installed the following repositories (you can find a much more detailed description here and here):
- apache2
- php5
- mysql-server
- php5-mysql (may be installed by default with the mysql-server package – sorry, can’t remember)
- phpmyadmin
- webmin (a very helpful program
Read what others have written on this topic as well though.
Next, in order to give yourself permissions to the /var/www/ directory, you need to run the following command in your terminal:
sudo chown -R $USER:$USER /var/www/
It’s not a secure thing to do (I don’t think) but it will make your life much easier (no permissions to worry about, no need to “sudo nautilus”).
Finally, getting mod_rewrite to work.
First, initiate it with the following command:
a2enmod rewrite
Then edit the file /etc/apache2/sites-enabled/000-default. You can do this with the following command:
nano /etc/apache2/sites-enabled/000-default
Then change the “AllowOverride None” to “AllowOverride All” in the “
In other words, when you run the nano command above you see the following in amongst some other stuff:
Options Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
allow from all
Change the AllowOverride to ‘All’.
Then restart your server with the following command:
sudo /etc/init.d/apache2 restart
And you’re done!
Disclaimer: I’m a terrible systems admin and make no guarantee for the above. However, it did work for me which makes me happy.
REPLY))
Thanks, this worked fine for me! Just released that the default LAMP settings doesn’t have mod_rewrite enabled. So this fix is quick and easy!
REPLY))
Just done this and it works well enough. Thanks alot.
REPLY))
Not that terrible, works for me too !
REPLY))
I have a probleme with the same I have lamp in Ubuntu 11.10
Can you help me ??
Kind ragards: Manyblue
REPLY))
Sorry Manyblue, I haven’t actually tried to set it up on 11.10 yet so I don’t think I can be much help.
REPLY))
after hours of searching, i finally found this fix and it worked on my ubuntu 11.10 lamp server with wordpress. thank you.