[英]How to run Wordpress Blog on a Sub URI within a Rails App on Heroku
I have a rails application that needs a blog. 我有一个需要博客的Rails应用程序。 I have looked at various rails cms and blog engines and none of them meet my needs.
我看过各种rails cms和博客引擎,但它们都不满足我的需求。 I would like to add Wordpress on a sub uri www.example.com/blog.
我想在sub uri www.example.com/blog上添加Wordpress。 My application is hosted on Heroku.
我的应用程序托管在Heroku上。 I am able to install wordpress independently as a separate app on heroku and I have tried adding wordpress to the public folder with an .htaccess file like this:
我能够在heroku上将Wordpress作为独立的应用程序独立安装,并且我尝试使用.htaccess文件将wordpress添加到公用文件夹中,如下所示:
RewriteEngine On
RewriteRule ^([^\.]+[^/])$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteBase /
RewriteCond RewriteCond %{REQUEST_URI} ^/blog.*$
RewriteCond %{DOCUMENT_ROOT}/-%2 -d
RewriteRule ^(.*)$ -%2/$1 [QSA,L]
but to no avail. 但无济于事。 I cant use reverse proxies because I would like to have SSO (and shared navigation bar etc and really dont want wordpress and my app to be "separate" applications on heroku) between the Rails app and the wordpress installation.
我不能使用反向代理,因为我想在Rails应用程序与wordpress安装之间使用SSO(以及共享的导航栏等,并且确实不希望wordpress和我的应用程序成为heroku上的“分离”应用程序)。 Is there a way to achieve this
有没有办法做到这一点
I would take a look at wordpress-heroku 我来看看wordpress-heroku
As far as sub URI's, you start to make things more complex when it's not necessary. 至于子URI,在不需要时,您会使事情变得更复杂。 If you want you can run two Heroku apps, but instead of using folder paths, use a subdomain so your main app runs on www.example.com and your blog runs on blog.example.com.
如果您希望可以运行两个Heroku应用程序,而不必使用文件夹路径,请使用子域,这样您的主应用程序可以在www.example.com上运行,而博客可以在blog.example.com上运行。 The use of subdomains is greatly respected in uses like this and makes things a lot easier.
子域的使用在这样的用法中得到了极大的尊重,这使事情变得容易得多。
Are you able to access the Virtual Host file for the server? 您可以访问服务器的虚拟主机文件吗? If so then the adding the following in the server may be your answer:
如果是这样,那么在服务器中添加以下内容可能是您的答案:
<VirtualHost ...>
ServerName ...
DocumentRoot ...
<Location /blog>
PassengerEnabled off
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
</Location>
</VirtualHost>
However I guess it also depends on how the rails app is deployed and whether the public folder is updated on deployment. 但是我想这也取决于Rails应用程序的部署方式以及部署时是否更新了公用文件夹。 You may need to symlink the public folder so it is not updated each time the site is deployed.
您可能需要符号链接公用文件夹,以便在每次部署站点时都不会更新它。
I couldn't say if this would work for Heroku having never used their services but hopefully it will help. 我不能说这对从未使用过其服务的Heroku是否可行,但希望能有所帮助。
Source: http://ziyedbd.wordpress.com/2012/05/11/deploying-wordpress-blog-inside-ruby-on-rails-application/ 来源:http: //ziyedbd.wordpress.com/2012/05/11/deploying-wordpress-blog-inside-ruby-on-rails-application/
Symlink info: http://linux.byexamples.com/archives/19/how-to-create-symlink/ 符号链接信息: http : //linux.byexamples.com/archives/19/how-to-create-symlink/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.