我已遵循在 Linux/Unix 生产服务器上安装 Passenger + Apache 中给出的每个安装步骤 对于 Node.js 应用程序 + Red Hat 6 / CentOS 6(带 RPM) 并且一切正常,但是当我尝试使用 WHM 在 CentOS 6 服务器上的虚拟主机中配置子域来托管我的 botkit 机器人时,我收到此错误:
“/usr/local/apache/bin/httpd”命令(进程27088)报告 结束时出现错误编号 1。第 9 行检测到配置问题 文件/usr/local/apache/conf/includes/post_virtualhost_2.conf.tmp: 无效命令“PassengerAppRoot”,可能拼写错误或由 模块不包含在服务器配置中--- /usr/local/apache/conf/includes/post_virtualhost_2.conf.tmp --- 3 服务器别名 subdomain.mydomain.com 4 ServerAdmin [email protected] 5 6 7 # 告诉 Apache 和 Passenger 您的位置 应用程序的代码目录是 8 DocumentRoot /var/www/MyApp/Code/public 9 ===> PassengerAppRoot /var/www/MyApp/Code <=== 10 #Error logging 11 ErrorLog logs/subdomain-error_log 12 CustomLog logs/subdomain-access_log common 13 14 # Tell Passenger that your app is a Node.js app 15 PassengerAppType node --- /usr/local/apache/conf/includes/post_virtualhost_2.conf.tmp ---
这是我的配置:
<VirtualHost *:80>
ServerName www.subdomain.mydomain.com
ServerAlias subdomain.mydomain.com
ServerAdmin [email protected]
# Tell Apache and Passenger where your app's code directory is
DocumentRoot /var/www/MyApp/code/public
PassengerAppRoot /var/www/MyApp/code
#Error logging
ErrorLog logs/votebot-error_log
CustomLog logs/votebot-access_log common
# Tell Passenger that your app is a Node.js app
PassengerAppType node
PassengerStartupFile bot.js
# Relax Apache security settings
<Directory /var/www/MyApp/code/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>
我尝试删除配置并通过 .htaccess 传递:
PassengerEnabled on
PassengerAppRoot /var/www/MyApp/code
SetEnv NODE_ENV production
SetEnv NODE_PATH /usr/lib/node_modules
PassengerAppType node
PassengerStartupFile bot.js
但仍然不起作用。 我最近检查并在验证乘客时收到以下消息:
* Checking whether this Passenger install is in PATH... ✓
* Checking whether there are no other Passenger installations... (!)
You are currently validating against Phusion Passenger 5.1.8, located in:
/usr/bin/passenger
Besides this Passenger installation, the following other
Passenger installations have also been detected:
/usr/local/rvm/gems/ruby-2.4.1/bin/passenger
Please uninstall these other Passenger installations to avoid
confusion or conflicts.
问题是我不知道卸载 /usr/local/rvm/gems/ruby-2.4.1/bin/passenger 的步骤是什么。
该错误意味着在指定 Passenger 配置选项之前,Passenger 模块尚未在 apache 配置中加载
LoadModule passenger_module /path/to/.../passenger/buildout/apache2/mod_passenger.so
行。
如果
sudo /usr/bin/passenger-config validate-install
通过了 apache 配置测试,那么您有多个 apache 配置,并且当您收到错误消息时正在加载错误的配置。
根据您的错误,conf 位于
/usr/local/apache/conf/
,使用 LoadModule
在配置中查找任何 fgrep -RH LoadModule /usr/local/apache/conf/
行,并添加一行来加载乘客模块。
我在“文件管理器”中更改了文件的权限,问题就解决了。 (我用的是Django)