11 Mart 2012 Pazar

WordPress Permalinks not working on Ubuntu 10.04 – mod_rewrite issue requires a symlink


by on JULY 27, 2010

Ubuntu & WordPressI recently installed WordPressMU on a virtual server and had problem with the permalinks. Much Google searching followed with little success at first but after some persistence I found the answers I needed.

I will try and write this up for three reasons:

  1. So hopefully it could benefit someone else with the same problem
  2. To try and better understand it myself
  3. I will no doubt forget for next time and need to refer back.

The bulk of this post is taken from a fantastic post on the Drupal site (http://drupal.org/node/332318). Although I had done lots of Google searches I struggled to find the answer for quite some time until I hit the post above. I think this is because the key to finding the right answer for a problem is finding someone with the same set-up. Saying this I found the solution to my WordPress problem on Drupal site although the issue was with a common problem area of ‘mod_rewrite’ on the Apache web server and in particular the Apache server running on Ubuntu. Ubuntu has a different way of storing apache settings (e.g it has a blank htppd.conf and uses apache2.conf) and holds modules in an ‘enabled’ folder not in the main settings file. This may well be better way than the ‘other’ ways but it can mean that a lot of the mod_rewrite ‘solutions’ on Google are not relevant if they are not specifically for Ubuntu.

Just quickly for this project my setup was:

Virtual Server Provider: VPS.net

Base install: Ubuntu 10.04 (Lucid) x64 LAMP*

WordPress 3.0 (with Multisite enabled)

* This was a preconfigured Ubuntu server with LAMP already instated and my experience may have been different if I had taken a clean Ubuntu install and installed LAMP myself. VPS.net do a offer a fully preconfigured WordPress server in Ubuntu which I am sure would have not had these issues but I wanted to install WordPressMU and this requires the install to be on the www root (VPS.net install it on a folder called WordPress) and the latest version. In my way of thinking I would prefer to install from scratch on a clean webserver than upgrading/moving an existing install – OK I like to learn the hardway.

Anyway the solution to my problem:

1. First we need to check if the rewrite module is installed. I was connected to my VPS server via SSH but either in a Terminal or via SSH type (or copy from below):

[[code]]czoxNzpcIg0KYXBhY2hlMmN0bCAtTQ0KXCI7e1smKiZdfQ==[[/code]]

This should show a list of Apache modules. Rewrite_Module should be there (as it is a default in Ubuntu 10.04) but if not check with your FTP client or in your file browser that /etc/apache2/mods-available contains a file called rewrite.load. If it does not then you need to fix this before you can carry on.

Presuming it does exist then we need to create a symlink (Symbloic Link on Wikipedia) between mods-enabled to mods-available. Again in the Terminal/SSH type or copy:

[[code]]czo3NTpcIg0KY2QgL2V0Yy9hcGFjaGUyL21vZHMtZW5hYmxlZA0Kc3VkbyBsbiAtcyAuLi9tb2RzLWF2YWlsYWJsZS9yZXdyaXRlLmx7WyYqJl19b2FkDQpcIjt7WyYqJl19[[/code]]

2. Now we need to check that rewrite module rewrite.load is in the mods enabled folder (/etc/apache2/mods-enabled). The easiest way is to have a look at that folder with your FTP client or file browser.

3. Presuming you are still OK then then the final and very important stage is to ‘Enable AllowOverride All’

In the folder /etc/apache2/sites-enabled you should find a file called 000-default and you need to check that all permissions are set to read & write not just read only, easily done with an FTP client (right click file>File Permissions in Filezilla)

In 000-default it will probably say AllowOverride None in several places. Find the one for where you’ve installed WordPress , and change it to AllowOverride All. e.g if WordPress is installed atvar/www/????? then it may be under the Directory “/var/www” grouping.

Finally, dont forget to restart Apache from the terminal:

/etc/init.d/apache2 restart

(now corrected see Keith’s comment)

if you don’t restart none of the changes will take affect

That worked for me and hopefully will work for somebody else. A big thanks to the Drupal site for thepost but I thought it was worth regurgitating for WordPress users as I am sure it could affect a few.

{ 28 comments… read them below or add one }

Seth Gottlieb July 27, 2010 at 1:13 pm

Just as an FYI, Debian and Ubuntu provide helper scripts for managing modules and sites under apache. The “a2enmod” and “a2dismod” commands will enable and disable modules.

So you could have done: a2enmod rewrite

If there had been a separate heades.conf file, this would have symlinked that as well.

Philip Oakley July 29, 2010 at 10:39 pm

Many thanks Seth. Thats very useful to know, I will try that next time.

Mike August 23, 2010 at 2:25 am

Dude,

Thanks for the post! I could not get the permalinks options work on localhost using Ubuntu 10.04 for love or money. My mod_rewrite was installed, so I was stuck. However, if you go to the permalink page, you’ll see an ominous message stating ” update .htaccess file.” Further down, you’ll find the text required. Cut and paste the file into your root directory. In my case, it was /var/www/blog. Caution! You may have an .htaccess file, but it may not contain the correct info, so copy the new info provides by Wordpress.

Good luck!

Mike

Keith Graber September 2, 2010 at 1:55 pm

Thanks for the pointers!

Just wanted to mention that your command to restart the Apache server is incorrect (looks like you pasted the symlink command by accident).

You can use either: apachectl2 restart or /etc/init.d/apache2 restart

Keith Graber September 2, 2010 at 1:57 pm

Thanks for the pointers!

Just wanted to mention that your command to restart the Apache server is incorrect (looks like you pasted the symlink command by accident).

You can use either: apache2ctl restart or /etc/init.d/apache2 restart

edit: mistyped the apache2clt command

Philip Oakley September 3, 2010 at 10:06 pm

Thanks Keith, much appreciated. I will update the post.

Adam October 2, 2010 at 6:39 pm

Thank you SO much for this post!

I’d been ripping my hair out trying to figure out why one of my servers was fine while the one I’m currently working with would not use .htaccess files! Turns out that the Rewrite module was available but not installed for some dumb reason and had it not been for you, I’m not sure I would have ever thought to look at it.

Thanks again!

picajoso October 4, 2010 at 4:09 pm

Saved my life this afternoon! Thank you so much ;)

Philip Oakley October 4, 2010 at 9:56 pm

Glad it could help someone else and thanks to all the comments that have added to it as well.

Winterbraid October 8, 2010 at 5:04 pm

Thanks a lot, this was a lifesaver – the procedure works on Maverick as well. Pretty sure I didn’t have that many problems with permalinks on my old Jaunty server, or perhaps I was using a better tutorial back then…

Nick November 20, 2010 at 3:33 pm

Brilliant, a perfect solution. Thanks

greywalk December 3, 2010 at 5:44 pm

AllowOverride All – this solved everything =) thanks a lot for this post.

Eric P December 15, 2010 at 4:02 pm

Ditto: AllowOverride All – solved everything. Thanks man, for taking the time to share !!

Manish January 18, 2011 at 7:16 am

Thanks! It did help me a LOT! :-)

To make it more difficult for me, I am new to PHP+Apache as well.

Though I had enabled rewrite module by this – a2enmod rewrite
I had to modify “000-default” from /etc/apache2/sites-enabled to get this working as per your instructions here.

AllowOverride All –> That was all needed and finally find here. Thanks a lot for your post.

MKO March 29, 2011 at 10:00 am

Thank you very much.

Damn you “AllowOverride None”

Pat Hann April 20, 2011 at 3:50 am

This worked like a charm. I have been trying to figure it out to no avail. I think I will post a link to this page on mine. Just Great!!

Suleiman Leadbitter May 13, 2011 at 9:05 am

I was having so much trouble with this and tried so many different methods. Thank you it works superb now.

:)

Stephan Miller June 3, 2011 at 4:27 am

Thanks man! Just went through backing up an exploded WP multisite database and repairing what I could from a raw file backup, rebuilding the sitemeta table from scratch because it was gone and moving everything to a new server and ran into this weird issue, but you saved my site.

Marvin June 19, 2011 at 5:08 pm

Thanks, this trick saved me some time searching the internet…!

Sahus Pilwal July 4, 2011 at 10:47 pm

Thanks “AllowOverride All” worked a treat however I did this on the sites-available > default file instead of sites-enabled > 000-default.

Does anyone know if there are any implications in doing this? What’s the difference between “sites available” & “sites-enabled”?? Thanks

james July 18, 2011 at 4:31 am

yes i am also using /etc/init.d/apache2 restart to restart the apache.

Diana Eftaiha July 25, 2011 at 5:56 pm

hi. thanks for the article. i have a problem cause i dont want to put wordpress permalink rules in .htaccess file. i want them to go directly in apace2.conf config file. everything goes well and pages display as supposed to. only problem is with files that have a .css or .php extension (which are basically the style sheets, images, and the comment post php file). what can i do to correct the problem

heres what i have inside the block :

RewriteEngine On
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

any suggestions?

Christopher September 25, 2011 at 12:55 pm

Just want to say THANK YOU. I quite searched for a couple of hours and could not find any solution to my problem.. it was already driving me nuts.. until I found your posting.
Again, thank you very much for sharing this important notice.

John September 28, 2011 at 4:21 pm

Thanks for this… Ive been trying every trick in the book to get this working and this is the first post that I found that actually worked…

Thanks for your help.

Ethagnawl February 7, 2012 at 6:46 am

Thanks!

This solved my WordPress permalink problems in Ubuntu 11.10.

(Hopefully that’ll up your SEO mojo!)

Tristan Dunn February 16, 2012 at 1:52 pm

Thank you so much for this. It’s really helped me getting Joomla and WordPress sites at working using SEO/User-friendly URLs working.

Tristan Dunn February 20, 2012 at 11:11 am

Also worked on my Debian Squeeze server at home. Hardly surprising, given Ubuntu being based on Debian. Just thought I’d throw this into the mix if any debian users find their way here.

Thanks again,
Tris

Alek Silver March 2, 2012 at 10:46 pm

Thank you very much! I got it working my site working on Ubuntu 10.04. I would have never figured this one out on my own.

One side note: Your code blocks are not working, so we have no idea what we are supposed to type into the terminal. Your code blocks have a bunch of garbled gibberish in them! You can delete this paragraph without offending me if you want, especially if you fix the code blocks.

I was able to get it working by reading the rest of your post. I only needed to do three things:

1. Create a symbolic link of the rewrite.load file from the /etc/apache2/mods-enabled /etc/apache2/mods-available directory.

2. Modify the /etc/apache2/sites-enabled/000-default to say “AllowOverride All” in the section pertaining to my Wordpress install directory.

3. Restart the Apache2 webserver.

Now to fix this on my other Ubuntu web server.

Hiç yorum yok:

Yorum Gönder