I'm trying to learn how to develop web application with Ruby On Rails but I've incurred in a silly error.
I'm trying to use Phusion Passenger aka mod_rails to use Apache instead of WEBrick; I've installed the module via gem and run the
sudo passenger-install-apache2-module
command to install passenger; then I edited the http.conf file adding
LoadModule passenger_module /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/Stopped/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.19
PassengerRuby /Users/Stopped/.rvm/wrappers/ruby-1.9.3-p327/ruby
added the VirtualHost
<VirtualHost *:80>
ServerName rails.local
DocumentRoot "/Users/Stopped/RoR/prova/public"
<Directory /Users/Stopped/RoR/prova/public>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restarted Apache with sudo apachectl restart but It's not working :( If I lookup in localhost I see the "It works!" page but if I go at rails.local there is not my Rails app :(
Passenger is loaded
Apache/2.2.22 (Unix) Phusion_Passenger/3.0.19 DAV/2 PHP/5.4.9 Server at localhost Port 80
Any ideas?
PS: This is "apachectl -S" output
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
port 80 namevhost rails.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK
SOLUTION
Uhm... I solved it, adding 127.0.0.1 rails.local to my hosts file but I can't understand why; can someone explain this to me? ._.
you can't use a wildcard with localhost in your hosts file. you have to explicitly specify each subdomain for localhost in your hosts file. if you're looking for an alternative, you could buy a domain name and point that domain name to 127.0.0.1 with a wildcard. you could even go a step further and have a skeleton app which points different subdomains to different applications by mapping the routes.
Related
I want to deploy my ruby on rails application on Red Hat Enterprise Linux Server release 6.5 server
I have done the following:
Server version: Apache/2.2.15 (Unix)
rvm install ruby
gem install rails
gem install passenger
passenger-install-apache2-module
then I added the following line on my httpd.conf file
LoadModule passenger_module /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/myname/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
PassengerDefaultRuby /home/myname/.rvm/gems/ruby-2.1.2/wrappers/ruby
</IfModule>
alos I added the following to my httpd.conf
<VirtualHost *:80>
ServerName www.whatever.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/whatever/public
<Directory /var/www/whatever/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
Additional info
rvm 1.25.31
I restarted the httpd and I cannot see my app running on whatever.com
I have bought the domain and redirected it to the IP of my machine.
What is wrong?
There's a number of reasons why this can happen, #user1876128 had some internal network issues and it wasn't acutally apache at fault.
For this apache setup to work, your network needs to allow http traffic to port 80 of your server box.
It's also advisable to allow traffic on port 3000, so you can run up a rails dev server on the same address (plus :3000) to check any changes before they're up.
You can log in to most domestic routers by pointing your browser at 192.168.0.1 or 192.168.1.1, then using the password (which is either written on your router, or the default password you can find online, or you've already changed it). And setting up a service for port 80 and your server box.
You need to uncomment the line indicated below and restart your apache service (sudo service apache2 restart or similar sudo /etc/init.d/apache2 restart)
<VirtualHost *:80>
ServerName www.whatever.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/whatever/public
<Directory /var/www/whatever/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
---> Require all granted
</Directory>
This is a common issue with the default stuff from passenger. Chances are you're on a newer version of apache which means # Uncomment this if you're on Apache >= 2.4: would apply.
I have a Rails server (Apache/CentOS-backed) that's accessible at mydomain.com:3000, but I'd like it to be exposed at :80 so I can access it at just mydomain.com. As best I can tell, this should be done through Apache's httpd.conf file. Mine contains the following:
<VirtualHost *:80>
ServerAdmin my-email#gmail.com
#RailsEnv development
DocumentRoot /var/www/webapps/railsSite/public
ServerName mydomain.com
ErrorLog logs/mydomain.com-error_log
CustomLog logs/mydomain.com-access_log common
<directory /var/www/webapps/railsSite/public>
AllowOverride all
Options -MultiViews
</directory>
</VirtualHost>
Am I missing anything from this block?
I'm starting my server via the standard rails server command. I looked up starting it directly to :80 via rvmsudo rails server -p 80, but I get an error saying sudo: rails: command not found. Somehow, sudo's not able to find rails?
Thanks for any help!
I have browsed over 100 links in the past hour, and nothing has helped. What I'm trying to do is simple: deploy a rails app on apache using passenger. The issue I'm getting is a 403 Forbidden error. My setup:
I run these two commands:
sudo gem install passenger
rvmsudo passenger-install-apache2-module
Then in etc/apache2/other I create a file called Passenger.conf with:
LoadModule passenger_module /Users/maq/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /Users/maq/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.14
PassengerDefaultRuby /Users/maq/.rvm/wrappers/ruby-2.0.0-p247/ruby
Then in /etc/apache2/extra/httpd-vhosts.conf, I have:
<VirtualHost *:80>
ServerName rails.local
DocumentRoot /webapps/coolapp/public
<Directory /webapps/coolapp/public/>
AllowOverride all
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
Then in my /etc/hosts file, I add this entry:
127.0.0.1 rails.local
Then, I change permissions on my webapps directory:
sudo chmod -R 755 /webapps
I then restart Apache:
sudo apachectl restart
NONE OF THIS IS FIXING THE ISSUE. I keep getting the same thing when I access rails.local in my browser:
You don't have permission to access / on this server. Apache/2.2.22
(Unix) DAV/2 Phusion_Passenger/4.0.14 mod_ssl/2.2.22 OpenSSL/0.9.8x
Server at rails.local Port 80
Someone for the love of god tell me what the issue could be.
Apache won't have permission to access /. You should be serving up your websites from /Library/WebServer/Documents/ or—depending on what group Apache is configured to run under (wheel by default in OS X)—you can try sudo chown -R root:wheel /webapps
Edit
My httpd.conf configuration has the following user/group:
User: [my user] # is an admin user
Group: staff
Used railsready, then passenger w/ apache2, finally copied my app to /home/myapp.
Inserted the passenger config lines into /etc/apache2/apache.conf at the bottom along with my virtual host settings:
The servers name is rails.
LoadModule passenger_module /home/myapp/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /home/myapp/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7
PassengerRuby /home/myapp/.rvm/wrappers/ruby-1.9.2-p180/ruby
<VirtualHost *:80>
ServerName rails
DocumentRoot /home/myapp/public
</VirtualHost>
All I get is the apache "It Works" page when I open the IP address. Am I doing something wrong?
You declared a ServerName so you must use it to access this VirtualHost (and not the IP address as you mentioned). Connect to http://rails/
For this to work, the hostname rails must resolv to your server's IP. You can add it to you hosts file or use a real domain name configured to resolve to this IP.
Or you can change the DocumentRoot of the default VirtualHost of Apache, and then it will always respond with the Rails app.
Try:
<VirtualHost *:80>
ServerName rails
DocumentRoot /home/myapp/public
<Directory /var/www/robox/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Also, you might need to disable the default site. In Ubuntu you can do this with:
[sudo] a2dissite default
[sudo] service apache2 restart
I'm trying to configure SSL on EC2onrails with no luck. At present I am unable to even telnet into my server at port 443, it simply says trying MY.IP.ADDRESS... and stays there indefinitely. Telnet into 80 works fine.
This was my starting point. I followed the instructions exactly, and because I have a go daddy cert I created this custom default-ssl file so I could add the SSLCertificateChainFile directive:
NameVirtualHost *:443
<VirtualHost *:443>
Include /etc/apache2/sites-available/app.custom
Include /etc/apache2/sites-available/app.common
ErrorLog /mnt/log/apache2/error.log
LogLevel warn
CustomLog /mnt/log/apache2/access.log combined
# see http://httpd.apache.org/docs/2.2/ssl/ssl_intro.html and http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
SSLEngine On
SSLCertificateFile /etc/ec2onrails/ssl/cert/ec2onrails-default.crt
SSLCertificateKeyFile /etc/ec2onrails/ssl/private/ec2onrails-default.key
SSLCertificateChainFile /etc/ec2onrails/ssl/cert/ec2onrails-chain.crt
RequestHeader set X_FORWARDED_PROTO 'https'
ServerName MY_SERVER_NAME
</VirtualHost>
Note that I had to add
ServerName MY_SERVER_NAME
Or else I saw the following warning at apache startup in the error.log file:
[Wed May 27 19:46:20 2009] [warn] RSA server certificate CommonName (CN) ` MY_SERVER_NAME' does NOT match server name!?
I have run cap ec2onrails:server:enable_ssl, apache boots up cleanly, regular access over port 80 works, and apache access logs indicate no request activity to port 443. I know apache is loading my default-ssl config files because if I type gobbledygook in them it complains at startup.
Has anyone else successfully gotten SSL working with EC2onRails? What else can I do to debug this issue? Right now I am using ec2onRails version 0.9.9.1 which is based on a version of Ubuntu.
OK I figured it out. Amazon's EC2 has it's own firewall as part of its "security group" concept. This firewall was blocking port 443.