יום ראשון, 5 באפריל 2009

Wordpress and Rails on the same Domain -> a much simplier configuration

About two weeks ago, I wrote a blog about how to make Wordpress and Ruby on Rails work on the same domain. That way still works but it might make problems if you use the non-default permalink options, and you have to change the .htaccess file. Also, this way is much simpler:
  1. Same assumptions apply: you already have Apahce, mod_php, phusion(Passenger), and you know how to make it work. Your existing blog and website are working, but not on the same domain, or not concurrently. You are using Debian / Ubuntu.
    Make sure you use the Passenger Version 2.1.3 or above. This is key here.

  2. I assume you've installed your blog under /var/www/blog, and let's say you've installed your rails website under /var/lib/www.myWebsite.com

  3. Login to your blog as admin, goto Options -> General, and change your Wordpress Address URL, and your Blog Adress URL to www.myWebsite.com/blog (click update Options, and disregard whatever doesn't work right now)

  4. Go to the /var/lib/www.myWebsite.com/public folder, and link to your blog folder :
    ln -s /var/www/blog blog

  5. goto to the wordpress directory: cd /etc/wordpress/

  6. make wordpress look at the configuration file (linking the mywebsite configuration file to the default config-blog.php file):
    sudo ln -s config-blog.php config-www.myWebsite.com.php


    Up to here everything was the same,
    the key here, that now Passenger supports the "PassengerEnabled off" command, as follows:

  7. edit your /etc/apache2/sites-available/www.myWebsite.com. Add the following lines
    <VirtualHost *>
    ServerName www.myWebsite.com
    DocumentRoot /var/lib/www.myWebsite.com/public
    <location>
    PassengerEnabled off
    </location>
    </VirtualHost>

  8. restart the apache (/etc/init.d/apache2 restart),

  9. That's it.

    Now, you can also change the .htaccess in your blog directory, and the permalink will work. It will be probably something like:

    <ifmodule>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </ifmodule>

A very similar configuration we did for our blog about test tools and testing methodologies in http://www.practitest.com. The website is a rails application, but the http://www.practitest.com/qablog is a wordpress blog.
Good luck.

0 comments:

הוסף רשומת תגובה