I've got the error where passenger complains that:
*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /usr/local/rvm/gems/ruby-1.9.3-head/ruby: No such file or directory (2)
[ pid=8970 thr=139698295748416 file=ext/apache2/Hooks.cpp:865 time=2012-11-07 17:17:32.422 ]: Unexpected error in mod_passenger: Cannot spawn application '/www/lensfinder.se/ruby/lensfinder': Could not read from the spawn server: Connection reset by peer (104)
Backtrace:
in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&)' (Client.h:750)
in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:297)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:566)
From what I can read is that it cant access /www/lensfinder.se/ruby/lensfinder though it exist.
And I found this FAQ on Phusion Passengers site
The problem is that, when I try to use that command,
passenger-config --root
I get this:
-bash: /usr/bin/passenger-config: ruby: bad interpreter: No such file or directory
apache config:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby
<VirtualHost 10.0.0.37:80>
ServerAdmin webmaster#compartment.se
DocumentRoot /www/lensfinder.se/htdocs
ServerName lensfinder.se
Redirect 301 / http://www.lensfinder.se/
ErrorLog /var/log/apache2/lensfinder.se-error.log
CustomLog /var/log/apache2/lensfinder.se-access.log combined
</VirtualHost>
<VirtualHost 10.0.0.37:80>
ServerAdmin hostmaster#compartment.se
ServerName lensfinder.se
ServerAlias www.lensfinder.se
ServerAlias *.lensfinder.se
# DocumentRoot /www/lensfinder.se/htdocs
DocumentRoot /www/lensfinder.se/ruby/lensfinder/script
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /www/lensfinder.se/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /www/lensfinder.se/cgi-bin/
<Directory "/www/lensfinder.se/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
</Directory>
<Directory "/www/lensfinder.se/htdocs/usage">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AllowOverride AuthConfig
#Options Includes
#Options FollowSymLinks
#Options +Indexes +Multiviews +FollowSymLinks
</Directory>
ErrorLog /var/log/apache2/lensfinder.se-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/lensfinder.se-access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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>
Alias /ruby/ /www/lensfinder.se/ruby/lensfinder/script
<Directory /www/lensfinder.se/ruby/lensfinder/script>
# Options ExecCGI
# AddHandler cgi-script .cgi
# Addhandler fastcgi-script .fcgi .fcg .fpl
AllowOVerride all
Order allow,deny
Allow from all
</Directory>
<IfModule passenger_module>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/gems/ruby-1.9.3-head/ruby
</IfModule>
RailsEnv production
RailsBaseURI /script
#
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</Location>
</VirtualHost>
Ok my guess is that you point Passenger to the wrong directory. You should point it to the public directory of your Rails app.
Here's a minimalist configuration for your project that goes in /etc/apache2/sites-available/lensfinder.se:
<VirtualHost 10.0.0.37:80>
ServerAdmin hostmaster#compartment.se
ServerName lensfinder.se
ServerAlias *.lensfinder.se
DocumentRoot /www/lensfinder.se/ruby/lensfinder/public
RailsEnv production
<Directory "/www/lensfinder.se/ruby/lensfinder/public">
Options FollowSymLinks
AllowOverride All
Options -MultiViews
</Directory>
</VirtualHost>
Then edit /etc/apache2/apache2.conf and at the end of the file, add :
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.12
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby
then simlink your virtualhost config to enable it:
ln -s /etc/apache2/sites-available/lensfinder.se /etc/apache2/sites-enabled/lensfinder.se
And of course restart apache2
In addition to the previous answer, In my case even after editing configuration files I still had issues loading up Apache as the module was still configured to load the previous (global) .so file.
I found there were source files and scripts in the /usr/local/rvm/gems/[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/ext/apache2/ directory, but no binaries. There were however scripts provided to build those. Simply run sudo /usr/local/rvm/gems/ruby-[YOUR-RUBY-VER]/gems/passenger-[YOUR-PASSENGER-VER]/bin/passenger-install-apache2-module.
Related
I followed this guide to get a free SSL certificate from StartSSL: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-with-a-free-signed-ssl-certificate-on-a-vps
I followed it step by step but I don't actually understand it fully as I'm a newbie.
I have .htaccess which stopped working after I put the below code into my 000-default.conf file:
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/apache2/ssl/ssl.crt
SSLCertificateKeyFile /etc/apache2/ssl/private.key
SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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>
</VirtualHost>
This is what's in my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9\-]+)$ $1.php
ErrorDocument 404 /404error
</IfModule>
^ It's basically to be able to access a page like this domain/page rather than like this: domain/page.php
So as soon as I add the above code from the 000-default.conf file, the rewrite rule works fine. If I add it in, however, I can no longer access files without the .php at the end. My 404 redirect is also not working.
What is it that's causing the problem?
currently I'm trying to set a VHost but somehow it is not working.
I've disabled the vhosts in my machine and I have just one. The page does not load. If I access localhost I get 403 Forbidden
My vhost:
<VirtualHost *:80>
ServerAdmin admin#myvhost.test
ServerName myvhost.test
DocumentRoot /folder/to/app
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /folder/to/app>
Options Indexes FollowSymLinks MultiViews
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and if I run
apache2ctl -S
I get
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
port 80 namevhost myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
Syntax OK
What am I missing here?
Thank you
I'm trying to install the overpass api as a web server with apache (http://wiki.openstreetmap.org/wiki/Overpass_API/install)
Here is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.mydomain.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /srv/osm3s/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/srv/osm3s/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</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
However when I try to run the command:
http://175.33.148.57/api/interpreter?data=%3Cprint%20mode=%22body%22/%3E
I get the 403 Forbidden error.
I have already done
chmod 777 /srv/osm3s/cgi-bin/
But nothing seems to work.
Please help, Ive been stuck on this for 3 days now! Thanks in advance.
Replace:
Allow from all
by
Require all granted
<Directory /www/mysite>
Allow from All
</Directory>
<Directory /www/mysite>
Require all granted
</Directory>
Here is how I solved this problem for anyone who might have a similar one:
It seemed the problem came from where I installed the overpass installation ($EXEC_DIR).
So I had to change the install directories to:
$EXEC_DIR /var/www/osm/
$DB_DIR /var/www/osm/db/
$PLANET_FILE /var/www/osm/planet.osm.bz2
$REPLICATE_DIR /var/www/osm/rep/
Giving the resulting default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.example.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /var/www/osm/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/var/www/osm/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</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
</VirtualHost>
I tried and tried but couldn't get it working with the old dir. Good luck!
try this as it is. don't add Order allow,deny or others
AddHandler cgi-script .cgi .py
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
Allow from all
</Directory>
On localhost I have a file filename.html and an .htaccess in the same folder.
I need to figure out why my .htaccess is not working:
redirect 301 /filename.html http://www.google.com
I am on linux, I have configured the server:
sudo nano /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo service apache2 restart
I found:
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]
my RewriteEngine is working.
I am trying to run my Haskel fastcgi program with apache (Server version: Apache/2.2.15 (Cent OS 6)),
Following are the changes done in httpd.conf
<IfModule fastcgi_module>
AddHandle fastcgi-script .fcgi
</IfModule>
LoadModule fastcgi_module modules/mod_fastcgi.so
<VirtualHost *:80>
ServerAdmin webmaster#<hostname>
DocumentRoot /var/www
ServerName <hostname>
ErrorLog logs/<hostname>.com-error_log
CustomLog logs/<hostname>-access_log common
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/http">
Options -Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
AddHandler fastcgi-script .fcgi
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I followed all the instructions as specified here
When I visit the link curl --include http:// hostname/cgi-bin/test.fcgi
I get error in apache server log as
[error] Premature end of script headers: test.fcgi
How can I debug this issue ?