簡體   English   中英

使用乘客從 Apache 上的子目錄運行 rails 應用程序

[英]Running rails app from a subDir on Apache with Passenger

我已經花了幾個小時徹底試圖找到答案。 來自 Site5 的提供托管服務的家伙碰壁了。

我正在嘗試做的事情:從 playplanit[dot]com/sfcal 而不是從 playplanit[dot]com/ 運行 reils 應用程序。

當前設置: - 應用程序本身在這里:/home/playplan/apps/ppi/current/ - 在PassengerAppRoot /home/playplan/apps/ppi/current 上的.htaccess 文件PassengerEnabled - 公共文件在public_html 中(以前是在這里 /home/playplan/apps/ppi/current/public 和 public_html 是一個符號鏈接,但我改變了它,因為做這個改變的重點是我可以在 docRoot 中運行 Wordpress 博客

已經嘗試過的內容: - 創建符號鏈接:sfcal/ -> /home/playplan/apps/ppi/current/public - 將 RailsBaseURI /sfcal 添加到 .htaccess 文件 - 嘗試更改 routes.rb 中的所有“路徑” 這是 rake routes output after paths I could think to change where changed: http://cl.ly/2N2Q2z0N332v2B2F3r38 - I thought that maybe map.root need to be changed somehow, but couldn't and then one of the technicians helping me added this line到 environment.rb: config.action_controller.relative_url_root = "/sfcal" - 根據他們的說法,httpd.conf 文件中不需要更改任何內容 - 我還嘗試通過在 tmp/ 中創建 restart.txt 文件來重新啟動應用程序

我知道符號鏈接有效,但應用程序中的某些內容識別出它是一個 subDir,並將提供位於“公共”目錄中的 404。

關於其他需要配置的任何想法?

謝謝!

檢查乘客文檔部署到子 URI

編輯

您只需要遵守乘客文件。 您不必弄亂 rails 路線或移動您的應用程序public

假設您已將 rails 應用程序部署到/home/playplan/apps/ppi/current並且/home/playplan/public_html目錄是虛擬主機的根目錄,並具有以下 Apache 配置:

<VirtualHost *:80>
  ServerName playplanit.com
  DocumentRoot /home/playplan/public_html
  <Directory /home/playplan/public_html>
    Allow from all
  </Directory>
</VirtualHost>

要從http://playplanit.com/sfcal訪問您的應用程序,您需要執行以下操作:

  • 確保在 httpd.conf 中為您的VirtualHost啟用 Apache Options FollowSymLinksAllowOverride Options ,否則以下操作將不起作用。

  • 在指向您的 rails public目錄的public_html目錄中創建名為sfcal的鏈接。

ln -s /home/playplan/apps/ppi/current/public /home/playplan/public_html/sfcal

  • 將以下內容添加到/home/playplan/public_html/.htaccess

     RailsBaseURI /sfcal
  • 將以下內容放入/home/playplan/public_html/sfcal/.htaccess

     Options -MultiViews

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM