Date: February 10th, 2010
Cate: ICT
Tags:

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 “” section.

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.

9 Comments

  1. January 27th, 2011
    REPLY))

  2. 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!

    1F

  3. KevinKevin  
    June 17th, 2011
    REPLY))

  4. Just done this and it works well enough. Thanks alot.

    2F

  5. ôkioôkio  
    June 25th, 2011
    REPLY))

  6. Not that terrible, works for me too ! ;)

    3F

  7. ManyblueManyblue  
    March 17th, 2012
    REPLY))

  8. I have a probleme with the same I have lamp in Ubuntu 11.10
    Can you help me ??
    Kind ragards: Manyblue

    4F

  9. March 19th, 2012
    REPLY))

  10. 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.

    5F

  11. March 29th, 2012
    REPLY))

  12. after hours of searching, i finally found this fix and it worked on my ubuntu 11.10 lamp server with wordpress. thank you.

    6F

  13. sanketsanket  
    February 13th, 2013
    REPLY))

  14. Thanks, I had spent hours to solve the mod_rewrite issue. This blog was a great help for me.

    7F

  15. JoshJosh  
    February 15th, 2013
    REPLY))

  16. Excellent and concise guide! Worked perfectly in Linux Mint 13.

    8F

  17. MatteoMatteo  
    May 5th, 2013
    REPLY))

  18. Thank you, it works wonders!

    9F

Leave a Reply

 Name

 Mail

 Home

[Name and Mail is required. Mail won't be published.]