【发布时间】:2023-04-03 19:24:01
【问题描述】:
几个月前我安装了 Phusion Passenger,现在我刚刚启动了 Apache,我请求了一个位于 /usr/local/apache2/htdocs 的页面:
http://localhost:8080/2.htm
大约 30 秒后,我的浏览器中出现了一个紫色和黑色的 Phusion 乘客页面,上面写着:
WEB APPLICATION COULD NOT BE STARTED
Application root
/Users/7stud/ruby_programs/phusion_passenger_programs/1app
但我不想在以下位置启动我的 Sinatra 应用程序:
/Users/7stud/ruby_programs/phusion_passenger_programs/1app
我想要做的就是让 Apache 通过返回 html 页面 2.htm 来响应我的浏览器请求——就像我以前能够做的那样。
这是我安装 Phusion Passenger 所做的:
~/ruby_programs/phusion_passenger_programs/1app$ passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v4.0.48.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
Here's what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
--------------------------------------------
Which languages are you interested in?
Use <space> to select.
If the menu doesn't display correctly, press '!'
‣ ⬢ Ruby
⬢ Python
⬢ Node.js
⬡ Meteor
--------------------------------------------
Warning: some directories may be inaccessible by the web server!
The web server typically runs under a separate user account for security
reasons. That user must be able to access the Phusion Passenger files.
However, it appears that some directories have too strict permissions. This
may prevent the web server user from accessing Phusion Passenger files.
It is recommended that you relax permissions as follows:
sudo chmod o+x "/Users/7stud"
Press Ctrl-C to return to the shell. (Recommended)
After relaxing permissions, re-run this installer.
***I CHANGED PERMISSIONS, THEN RERAN INSTALLER****
…
…
Sanity checking Apache installation...
Multiple Apache installations detected!
You are about to install Phusion Passenger against the following
Apache installation:
Apache 2.2.24
apxs2 : /usr/sbin/apxs
Executable: /usr/sbin/httpd
However, 1 other Apache installation(s) have been found on your system:
* Apache 2.4.3
apxs2 : /usr/local/apache2/bin/apxs
Executable: /usr/local/apache2/bin/httpd
Are you sure you want to install against Apache 2.2.24 (/usr/sbin/apxs)? [y/n]: n
--------------------------------------------
* To compile against Apache 2.4.3 (/usr/local/apache2/bin/apxs):
Re-run this installer with: --apxs2-path "/usr/local/apache2/bin/apxs"
You may also want to read the "Installation" section of the manual for
installation troubleshooting:
***I RERAN INSTALLER AGAIN***
$ passenger-install-apache2-module --apxs2-path "/usr/local/apache2/bin/apxs"
…
…
Sanity checking Apache installation...
Multiple Apache installations detected!
You are about to install Phusion Passenger against the following
Apache installation:
Apache 2.4.3
apxs2 : /usr/local/apache2/bin/apxs
Executable: /usr/local/apache2/bin/httpd
However, 1 other Apache installation(s) have been found on your system:
* Apache 2.2.24
apxs2 : /usr/sbin/apxs
Executable: /usr/sbin/httpd
Are you sure you want to install against Apache 2.4.3 (/usr/local/apache2/bin/apxs)? [y/n]: y
===LOT'S OF OUTPUT HERE FOR COMPILATION, THEN ERRORED OUT:
Undefined symbols:
"___fork", referenced from:
Passenger::asyncFork() in Utils.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
rake aborted!
Command failed with status (1): [c++ buildout/agents/PassengerHelperAgent.o -o buildout/agents/PassengerHelperAgent buildout/common/libpassenger_common/Logging.o buildout/common/libpassenger_common/Exceptions.o buildout/common/libpassenger_common/Utils/SystemTime.o buildout/common/libpassenger_common/Utils/StrIntUtils.o buildout/common/libpassenger_common/Utils/IOUtils.o buildout/common/libpassenger_common/Utils.o buildout/common/libpassenger_common/Utils/Base64.o buildout/common/libpassenger_common/Utils/CachedFileStat.o buildout/common/libpassenger_common/Utils/LargeFiles.o buildout/common/libpassenger_common/ApplicationPool2/Implementation.o buildout/common/libpassenger_common/ApplicationPool2/AppTypes.o buildout/common/libpassenger_common/AgentsBase.o buildout/common/libpassenger_common/Utils/MD5.o buildout/common/libpassenger_common/Utils/fib.o buildout/common/libpassenger_common/Utils/jsoncpp.o buildout/common/libboost_oxt.a buildout/libev/.libs/libev.a buildout/libeio/.libs/libeio.a -lpthread -Wl,-dead_strip ]
/Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.48/build/cplusplus_support.rb:51:in `run_compiler'
/Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.48/build/cplusplus_support.rb:77:in `create_executable'
/Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.48/build/agents.rb:101:in `block in <top (required)>'
/Users/7stud/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/7stud/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => apache2 => buildout/agents/PassengerHelperAgent
(See full trace by running task with --trace)
--------------------------------------------
It looks like something went wrong
Please read our Users guide for troubleshooting tips:
/Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.48/doc/Users guide Apache.html
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
If that doesn't help, please use our support facilities. We'll do our best to help you.
https://www.phusionpassenger.com/documentation_and_support
==========
The error is because Passenger no longer supports Snow Leopard.
Next I uninstalled the current passenger gem:
$ gem uninstall passenger -v 4.0.48
and installed version 4.0.5
$ gem install passenger -v 4.0.5
Then:
$ passenger-install-apache2-module --apxs2-path "/usr/local/apache2/bin/apxs"
And passenger installed successfully:
====
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.5
PassengerDefaultRuby /Users/7stud/.rvm/wrappers/ruby-2.1.2/ruby
***I MODIFIED apache2/conf/http.conf ACCORDING TO THE ABOVE***
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Press ENTER to continue.
--------------------------------------------
Deploying a Ruby on Rails application: an example
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:
/Users/7stud/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.5/doc/Users guide Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
以下是我的 httpd.conf 文件中的一些相关部分:
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/Users/7stud/ruby_programs/phusion_passenger_programs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
编辑:
我决定摆脱 Phusion Passenger,所以我在这里阅读了卸载文档:
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#uninstalling
我使用安装程序安装:
$ passenger-install-apache2-module
...如果您使用安装程序安装,卸载文档不会告诉您如何卸载。伟大的!
所以,如果我只是注释掉我的 httpd.conf 文件中提到 Phusion Passenger 的任何内容,那么我应该没问题,对吧?我这样做了,然后重新启动了 apache2,现在我尝试访问的每个页面(在 apache2/htdocs 目录中)的 URL 如下:
http://localhost:8080/2.htm
我明白了:
Not Found
The requested URL /2.htm was not found on this server.
还是:
/usr/local/apache2/bin$ sudo ./apachectl -k stop
Password:
/usr/local/apache2/bin$ sudo ./apachectl -k start
/usr/local/apache2/bin$ cd ../htdocs
/usr/local/apache2/htdocs$ ls
1.htm html.html mysql2.php
1.php index.html page1.html
2.htm js.js page2.html
2.php js2.js q
3.htm js3.js test.html
4.htm lib test.php
A.html mail.php xhr.js
B.html my.htm xml2.xml
css my_manifest.appcache
home.html mysql.php
感谢 Phusion Passenger,我不能再让 apache 提供页面了。
下一步,卸载乘客 gem:
$ gem uninstall passenger
Remove executables:
passenger, passenger-install-apache2-module, passenger-install-nginx-module, passenger-config, passenger-status, passenger-memory-stats
in addition to the gem? [Yn] Y
Removing passenger
Removing passenger-install-apache2-module
Removing passenger-install-nginx-module
Removing passenger-config
Removing passenger-status
Removing passenger-memory-stats
Successfully uninstalled passenger-4.0.5
同样的结果。重新启动了我的电脑。结果相同。 Apache2 不再提供页面。
【问题讨论】: