Submitted by Jordan on
This is a problem I've solved many times, but I keep forgetting to write it down. The problem is: You install Drupal on a new Linux server running Ubuntu. Clean urls don't work.
Solution: Actually, there are several. This is my attempt to make it simple.
- LAMP: Make sure you installed the lamp stack correctly. Follow these instructions: https://help.ubuntu.com/community/ApacheMySQLPHP
- Install Drupal: Make sure Drupal is installed correctly. If you follow the official Drupal instructions for clean urls, most of them have to do with an .htaccess file not being set up correctly. D7 comes with an .htaccess file that already has most of the settings you need, so make sure it's there.
- mod_rewrite: Install the Apache rewrite module: sudo a2enmod rewrite
- Apache config: Modify the Apache config file. On Ubuntu it's located at /etc/apache2/apache2.conf . Add the following:
<Directory /var/www/>Options Indexes FollowSymLinksAllowOverride AllRequire all granted</Directory><Directory /var/www/html>RewriteEngine onRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?q=$1 [L,QSA]AllowOverride All</Directory> - Restart Apache: /etc/init.d/apache2 restart
That's it! This has worked for years, all the way up to Ubuntu 14.04. Does it work for you? Leave a message in the comments.