Apache-2.2

Apache2 上的乘客 - 如何使站點出現在根目錄下

  • November 1, 2011

我是 apache2 的新手,也是設置 rails 應用程序的乘客,並遵循了有關如何設置 redmine(rails 應用程序)的教程(http://xdissent.com/2010/05/04/github-clone-with-紅米/)。

這一切都很好,但要訪問您需要轉到 /redmine 目錄的應用程序。我已將其設置為 redmine.local/redmine。如果我能成為 redmine.local 那就太好了。

我查看了我作為 apache/mongrel/passenger 部分設置的文件,並取出了對目錄的引用,但可惜它從來沒有那麼容易。

我將不勝感激任何幫助,或連結到我可以從中學習的初學者的更多資訊。

謝謝你的幫助!亞當


- - 更新 - -

一些額外的細節,我有以下文件,作為伺服器設置的一部分,我也進行了編輯:

/etc/apache2/conf.d/redmine

Include /opt/redmine/apps/redmine/conf/redmine.conf

/opt/redmine/apps/redmine/conf/redmine.conf

ProxyPass /redmine balancer://redminecluster
ProxyPassReverse /redmine balancer://redminecluster

<Proxy balancer://redminecluster>
  BalancerMember http://127.0.0.1:3001/redmine
  BalancerMember http://127.0.0.1:3002/redmine
  Order deny,allow
  Allow from all
</Proxy>

/opt/redmine/apps/redmine/config/mongrel_cluster.yml

--- 
prefix: /redmine
log_file: log/mongrel.log
port: "3001"
environment: production
pid_file: tmp/pids/mongrel.pid
servers: 2

/etc/apache2/sites-available/default

<VirtualHost *:80>
   ServerAdmin webmaster@localhost

<Directory /var/www/>
   Options FollowSymLinks
   AllowOverride None
</Directory>
<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /var/www/usr/lib/cgi-bin>
   AllowOverride None
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   Order allow,deny
   Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory /var/www/usr/share/doc/>
   Options Indexes MultiViews FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
   Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
DocumentRoot /var/www

</VirtualHost>

我找不到引用目前目錄 /redmine 作為路由的文件,所以不確定伺服器首先找到它 - 除非它是 conf.d 的東西。

更新

  1. 將文件編輯為redmine.conf以下內容:
<VirtualHost *:80>
   ServerName redmine.local
   ErrorLog logs/redmine_error_log

   RewriteEngine On
   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
   RewriteRule ^/(.*)$ balancer://redminecluster%{REQUEST_URI} [P,QSA,L] 

   <Proxy balancer://redminecluster>
       BalancerMember http://127.0.0.1:3001
       BalancerMember http://127.0.0.1:3002
   </Proxy>
</VirtualHost>
  1. 從 中刪除prefix選項mongrel_cluster.yml
  2. 重新啟動 Apache 並重試。

引用自:https://serverfault.com/questions/326321