rails 部署:乘客不会阅读 public 目录
rails deployment: passenger won't read the public directory
我正在尝试将 rails 应用程序部署到 RedHat 服务器(rvm、apache)。我没有 root 帐户,但服务器主机试图让我通过 sudo 和 acls 做尽可能多的事情。他们不向我提供应用程序用户,而是为所有用户安装 rvm 和 passenger。所以我尝试让应用程序 运行 作为 apache 用户。我熟悉部署 rails 应用程序。以上就是前提条件。
问题是,乘客不会阅读 public 目录。因此没有设置必要的环境变量。当我出于调试目的直接在 ruby 文件中设置它们时,应用程序 运行s,但仍然没有预编译在 public/assets.
下的资产
我发现 rails 目录属于我的用户,所以我让他们将其更正为 user/group apache:apache。
当我重新启动 apache (sudo apachectl restart) 时,我得到:
root 5177 0.0 0.2 227884 10760 ? Ss Oct27 0:01 /usr/sbin/httpd -k start
apache 25813 0.0 0.2 382060 10488 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25814 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25815 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25816 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25817 0.0 0.2 382060 11232 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25818 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25820 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25826 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25932 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25950 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25951 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
和
root 25791 0.0 0.1 427572 4148 ? Ssl 09:33 0:00 Passenger watchdog
root 25794 0.0 0.2 995708 10624 ? Sl 09:33 0:00 Passenger core
nobody 25799 0.0 0.1 438064 4284 ? Sl 09:33 0:00 Passenger ust-router
kosven 25846 2.8 2.4 316780 97084 ? Sl 09:33 0:02 Passenger AppPreloader: /var/www/html/rails_app/
kosven 25943 0.0 2.3 386332 91060 ? Sl 09:33 0:00 Passenger RubyApp: /var/www/html/rails_app/ (production)
难道这就是乘客不提供来自 public 目录 (rails_app/public) 的文件的原因吗?
非常感谢,
麦克斯
终于找到了,在我能够编辑相应的apache配置之后:
未设置 DocumentRoot。多么愚蠢的错误...
所以正确的配置如下:
<VirtualHost my.stillsecrethost.com:80>
DocumentRoot /var/www/html/rails_app/public
RailsEnv production
PassengerAppRoot /var/www/html/rails_app/
<Directory /var/www/html/rails_app/public >
Allow from all
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
谢谢
麦克斯
我正在尝试将 rails 应用程序部署到 RedHat 服务器(rvm、apache)。我没有 root 帐户,但服务器主机试图让我通过 sudo 和 acls 做尽可能多的事情。他们不向我提供应用程序用户,而是为所有用户安装 rvm 和 passenger。所以我尝试让应用程序 运行 作为 apache 用户。我熟悉部署 rails 应用程序。以上就是前提条件。
问题是,乘客不会阅读 public 目录。因此没有设置必要的环境变量。当我出于调试目的直接在 ruby 文件中设置它们时,应用程序 运行s,但仍然没有预编译在 public/assets.
下的资产我发现 rails 目录属于我的用户,所以我让他们将其更正为 user/group apache:apache。
当我重新启动 apache (sudo apachectl restart) 时,我得到:
root 5177 0.0 0.2 227884 10760 ? Ss Oct27 0:01 /usr/sbin/httpd -k start
apache 25813 0.0 0.2 382060 10488 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25814 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25815 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25816 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25817 0.0 0.2 382060 11232 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25818 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25820 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25826 0.0 0.2 382060 10604 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25932 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25950 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
apache 25951 0.0 0.2 382060 10468 ? Sl 09:33 0:00 /usr/sbin/httpd -k start
和
root 25791 0.0 0.1 427572 4148 ? Ssl 09:33 0:00 Passenger watchdog
root 25794 0.0 0.2 995708 10624 ? Sl 09:33 0:00 Passenger core
nobody 25799 0.0 0.1 438064 4284 ? Sl 09:33 0:00 Passenger ust-router
kosven 25846 2.8 2.4 316780 97084 ? Sl 09:33 0:02 Passenger AppPreloader: /var/www/html/rails_app/
kosven 25943 0.0 2.3 386332 91060 ? Sl 09:33 0:00 Passenger RubyApp: /var/www/html/rails_app/ (production)
难道这就是乘客不提供来自 public 目录 (rails_app/public) 的文件的原因吗?
非常感谢, 麦克斯
终于找到了,在我能够编辑相应的apache配置之后:
未设置 DocumentRoot。多么愚蠢的错误...
所以正确的配置如下:
<VirtualHost my.stillsecrethost.com:80>
DocumentRoot /var/www/html/rails_app/public
RailsEnv production
PassengerAppRoot /var/www/html/rails_app/
<Directory /var/www/html/rails_app/public >
Allow from all
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
谢谢 麦克斯