简体   繁体   English

如何在Heroku的Rails应用程序中的子URI上运行Wordpress Blog

[英]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.

相关问题 如何在本地Google App Engine上运行Wordpress博客 - How to Run Wordpress Blog on Google App Engine Locally 在根域上运行 php 网站和在子域上运行 wordpress 博客是否可以? - Is it fine to run php website on root domain and wordpress blog on the sub domain? 如何在 React js 应用中实现 WordPress 博客? - How to implement WordPress Blog in a React js App? 在AngularJS应用程序中正确包含Wordpress博客的策略 - Strategy to properly include Wordpress blog within an AngularJS app 在Rails应用程序的子域中的Wordpress博客 - 下载文件而不渲染它们 - Wordpress blog in a subdomain of a Rails app - Downloading files and not rendering them 如何将Wordpress博客链接到在Heroku上运行的PHP Yii网站的/ blog URL上? - How do I bolt a Wordpress blog onto a /blog URL for a PHP Yii site running on Heroku? Wordpress:将博客文章与(子)页面相关吗? - Wordpress: Relate blog post to a (sub)page? 用wordpress作为子文件夹的Rails heroku应用程序,无法登录到管理员 - Rails heroku app with wordpress as subfolder, unable to log in to admin 如何使用Nginx在/ blog /上提供WordPress博客? - How to serve a WordPress blog at /blog/ with Nginx? 在heroku上集成博客和node.js应用程序 - Integrate a blog with node.js app on heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM