הערה: כיוון שלא מצאתי ברשת הסבר שדומה החלטתי לפרסם פוסט זה באנגלית, כך שיותר אנשים יוכלו להעזר בפוסט זה. אם מישהו מעוניין בהסבר בעברית אשמח לעזור.
It's relatively easy to setup php and rails on the same server using Apache with Phusion, but when we need it all to work on the same domain, things might get a little tricky. Let's assume you have a website: www.myWebsite.com, which you wrote (or it just works) in Rails, and you want to use wordpress as your blog engine. Assuming all of your posts, should be under www.myWebsite.com/blog, this is how to get it done
Before you continue, please see that there's a simpler way to do this now that Phusion supports the PassengerEnabled Off -> Click here to view
- prerequisites:
you already have Apahce, mod_php, mod_rewrite, phusion, 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. - 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
- 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)
- Go to the /var/lib/www.myWebsite.com/public folder, and link to your blog folder :
ln -s /var/www/blog blog - goto to the wordpress directory: cd /etc/wordpress/
- 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 - 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
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog$ /blog/index.php [QSA]
RewriteRule ^(/blog.*/$)$ $1/index.php [QSA]
RewriteRule ^/blog/?(.*)$ %{DOCUMENT_ROOT}/blog/$1 [NC,QSA,L]
</VirtualHost> - restart the apache (/etc/init.d/apache2 restart),
- That's it. Enjoy your blog :)
0 comments:
הוסף רשומת תגובה