我正在尝试在 apache 下安装 Redmine。apache 服务器在本地网络上工作。我的 apache 设置包含在单个虚拟主机上。我可以使用对应的路径进入不同的目录:
http://ip_address/folder_of_the_project_1
在这种情况下,如何设置虚拟主机以使 redmine 工作?这是我当前的虚拟主机设置:
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
RailsBaseURI /redmine
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /var/www/redmine/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/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, …Run Code Online (Sandbox Code Playgroud) 我使用的是 Nginx 0.7.64、Passenger 2.2.9、Rails 2.3.5。我将我的页面缓存目录设置为 /public/cache,并且我希望能够在通过 HTTP 请求时提供缓存页面,但在通过 HTTPS 请求时总是点击 Rails 应用程序。
我的大部分配置如下所示:
server {
listen 80;
server_name website.com www.website.com;
proxy_set_header X-Forwarded-Proto http;
root /home/deploy/website/current/public;
passenger_enabled on;
if (-f $document_root/cache/$request_filename.html) {
rewrite (.*) $document_root/cache/$1.html break;
}
}
server {
listen 443;
server_name website.com www.website.com;
root /home/deploy/website/current/public;
passenger_enabled on;
proxy_set_header X-Forwarded-Proto https;
ssl on;
ssl_certificate /home/deploy/website/shared/ssl/www.website.com.combined.crt;
ssl_certificate_key /home/deploy/website/shared/ssl/www.website.com.key;
}
Run Code Online (Sandbox Code Playgroud)
我预计当我请求 website.com/about 时,我应该得到 /public/cache/about.html 的服务,但我却访问了 Rails 服务器(尾随日志显示了它)。
认为我可能有一个不合适的斜线(并且$document_root在大多数示例中没有看到),我还尝试了以下所有变体,但没有一个有效:
if (-f cache$request_filename.html) {
rewrite (.*) cache$1.html break;
}
if (-f /cache$request_filename.html) …Run Code Online (Sandbox Code Playgroud) 我是一名 iOS 开发人员,所以我对 Apache 和 RoR 的经验很少,这是我第一次尝试使用 Mac OS X 作为服务器。
http://rubyonrails.org/deploy建议将Phusion Passenger (mod_rails)与 Apache 一起使用。所以这就是我想要完成的,但我已经走到了死胡同。
这就是我所做的:
我已启用 Apache(设置中的复选框)并将我的浏览器指向 localhost 给我文本“It works!”。我也可以通过我的 dyndns 访问它。
我运行以下命令来安装乘客:
sudo gem install passenger
passenger-install-apache2-module
Run Code Online (Sandbox Code Playgroud)我添加了以下几行/etc/apache2/httpd.conf:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-3.0.7
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Run Code Online (Sandbox Code Playgroud)然后我添加了以下内容/etc/apache2/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerName my.dyndns.org
DocumentRoot /Users/Shared/rails/project/public # <-- be sure to point to 'public'!
<Directory /Users/Shared/rails/project/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory> …Run Code Online (Sandbox Code Playgroud)我正在使用Passenger + Nginx 来运行Rails 应用程序。如果我使用“rails_env 开发”;该应用程序运行良好。
但是如果我在生产模式下运行,我会得到“我们很抱歉,但出了点问题。”。
我确实为生产运行了 db:migrate,我可以正常访问数据库。
奇怪的是,我没有在日志中得到任何新条目(nginx 和 rails 之一),而且我确保 nginx 用户可以在它们上面写字。
如果我运行 rails 控制台生产,它工作正常:
# rails console production
Loading production environment (Rails 3.2.0)
1.9.3-p125 :001 >
Run Code Online (Sandbox Code Playgroud)
关于可能发生什么的任何想法?我还应该检查什么?
- - 编辑 - -
在@BenLee 建议将passenger_debug_log_file 添加到nginx.conf 之后,我开始在开发和生产中遇到此错误:
# /etc/init.d/nginx restart
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: [alert] Unable to start the Phusion Passenger watchdog: it seems to have crashed during startup for an unknown reason, with exit code 1 (-1: Unknown error) …Run Code Online (Sandbox Code Playgroud) 我们有一个使用 ruby on rails 开发的站点。它有过
我们开始使用 wordpress 来管理网站内容。我们已经完成了开发,现在必须进入生产阶段。这是 wordpress 当前在 /wordpress URI 下工作的虚拟主机代码。
<Location /wordpress>
PassengerEnabled off
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
</Location>
Run Code Online (Sandbox Code Playgroud)
我想让 phusion 乘客为 /admin 和 /api URI 工作。和/去wordpress。
我们可以根据 URI 更改文档根目录吗?或任何其他更好的解决方案?
由于乘客声称的一个明显常见问题,我遇到了乘客无法启动的问题:没有这样的文件或目录 - config/environment.rb。
我已经在网络上搜索了高低,这似乎是一个与权限相关的问题。据我了解,Passenger 作为 config.ru 和 config/environment.rb 文件的所有者运行。在我的情况下,这个所有者是“管理员”。我正在管理员用户的主目录中运行应用程序根目录。所以,我相信我有使用设置正确的权限:
sudo chown -R admin:admin /home/admin/www
和
sudo chmod -R 755 /home/admin/www
应用根目录位于:/home/admin/www/app
这是我的虚拟服务器配置文件:
Run Code Online (Sandbox Code Playgroud)<VirtualHost *:80> ServerName track.example.com DocumentRoot /home/admin/www/app/current/public <Directory /home/admin/www/app/current/public> Options FollowSymLinks AllowOverride none Order allow,deny Allow from all </Directory> PassengerResolveSymlinksInDocumentRoot on RailsBaseURI / PassengerAppRoot /home/admin/www/app RailsEnv production ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel debug CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
我正在运行 Ubuntu 12.0.4、Rails 3.2.8、Ruby 1.9.3、Passenger 3.0.18、Apache 2
谢谢你的帮助。
我想用 SSL 运行我的整个 Rails 应用程序,所以我想使用 Rails 的全局 force_ssl 配置选项,这很好用,除了 ELB 的健康检查器永远不会工作,因为如果我将它设置为 http,Rails 将转发到 https 301,健康检查将失败,因为它不是 200。如果我将其设置为 https,nginx/rails 将无法处理请求,因为 SSL 由 ELB 处理,而 nginx/rails 仅处理 HTTP。
我的非理想解决方案是对global force_ssl健康检查页面进行例外处理,但 Rails 的global force_ssl配置始终覆盖 ,force_ssl :except => :health_check因此似乎不起作用。
另一种解决方案是不使用ELB进行SSL终止,并设置HAProxy左右,但我想尽可能多地使用亚马逊的基础设施,更多地关注项目的核心开发而不是基础设施。
这是我的第一篇 serverfault 帖子,所以我很感激我能得到的任何帮助(或我可以提供的更多信息)。谢谢。
更新:
到目前为止,我通过让 ELB 通过与 80 不同的端口访问 EC2 实例来“解决”这个问题,该端口只有它可以访问,这感觉很极端,但在应用程序层和服务器层之间保持分离。如果健康检查请求来自来自该端口的 ELB,nginx 将转发设置为“https”的 X-Forwarded-Proto 标头,这会让 Rack 认为它来自 SSL,并让它通过。对于通过标准端口 80 传入的所有其他流量,它只转发 ELB 给出的 X-Forwarded-Proto 标头,它将准确报告外部用户正在使用的内容,并让 Rails 决定是否强制使用 https。
仍在等待更清洁的解决方案,但这就是我所拥有的。
我们在许多应用程序服务器上安装了 3 个 Ruby on Rails 应用程序(A、B 和 C)。我们的前端是 HAProxy,后端是 Apache + Phusion Passenger。最初我们在每个应用程序服务器上都安装了所有 3 个 Rails 应用程序,但是这个设置很慢,因为 HAProxy“不知道”给定的 Rails 应用程序在给定的支持服务器上是否“热”。

每个乘客实例配置为最多运行 8 个 Rails 应用程序实例。
考虑以下场景(简化):
在每分钟有大量请求的大计划中,所有 3 个 Rails 应用程序经常在每个应用程序服务器上启动和停止,这很慢。
在完美世界中,应用程序启动一次并处理大量请求,而无需关闭和重新启动。这就是为什么我们必须在 3 个 Rails 应用程序之间划分我们的应用程序服务器:
问题:是否有一个负载均衡器软件可以“感知”后端并且知道并使用以下信息来平衡负载:
load-balancing haproxy ruby-on-rails phusion-passenger high-load
我正在使用 puma 和 nxinx,据我所知,即使我以 16 个或更多线程的默认值启动它,它也只使用单个线程。我已经设置了一个新的 rails 应用程序,然后完成了这里描述的设置:
http://blog.wiemann.name/rails-server
这给出了这个示例 nginx 配置:
upstream benchmarkapp.com {server unix:/tmp/benchmark_app.sock fail_timeout=0;}
server {
server_name benchmarkapp.com;
root /home/tristan/benchmark_app/public;
try_files $uri/index.html $uri @benchmarkapp.com;
location @benchmarkapp.com {
proxy_redirect off;
proxy_pass http://benchmarkapp.com;
}
}
Run Code Online (Sandbox Code Playgroud)
然后创建一个简单的控制器动作,它只是休眠 3 秒,然后呈现“hello”:
class WelcomeController < ApplicationController
def index
sleep(2)
render :text => "hello"
end
end
Run Code Online (Sandbox Code Playgroud)
然后我开始使用 puma: puma -t 16 -b unix:///tmp/benchmark_app.sock -S /tmp/benchmark_app.state
一旦运行,我使用 siege 用 10 个并发用户命中它,这是结果
% siege -c 10 -t 60s http://benchmarkapp.com
** SIEGE 2.70
** Preparing 10 concurrent …Run Code Online (Sandbox Code Playgroud) 我有一个在 Ubuntu 18.04 上运行的 Rails 项目,我刚刚将系统升级到 Ubuntu 20.04。
cap production deploy在以下步骤中失败deploy:assets:precompile:
00:07 deploy:assets:precompile
01 /home/deploy/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 bundler: failed to load command: rake (/var/www/framelinker/shared/bundle/ruby/2.6.0/bin/rake)
01 Gem::Exception: can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
Run Code Online (Sandbox Code Playgroud)
我尝试将 rake 添加到我的 gemfile 中,尽管我有一种感觉这不是答案,因为 a) 它没有任何区别,b) 当一切都在 Ubuntu 18.04 上运行时,rake 不在我的 gemfile 中。
谷歌搜索告诉我要运行gem update --system,但我不想手动弄乱服务器。
我在服务器上使用 rbenv。我的 gemfile 被锁定在 …
ruby-on-rails ×10
apache-2.2 ×4
nginx ×3
bundler ×1
haproxy ×1
high-load ×1
mac-osx ×1
redmine ×1
rewrite ×1
ruby ×1
ssl ×1
ubuntu-20.04 ×1
virtualhost ×1
web-server ×1
wordpress ×1