I'm having a rough time with Apache and my Rails app on my production server. I have everything installed, libraries, gems, the whole get down. The issue is that I get a "Forbidden" error in my browser. I've even chmod'd my app directory with "777" but still no luck.
So my questions are:
What is your ServerName Directive (in your virtual host configuration)?
Where is your application located on your server?
Who owns your application directory?
What user should own your application directory?
Assuming your Apache has the Passenger (aka mod_rails) module installed and enabled, configuring a new Rails app is as simple as
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
# Index file and Document Root (where the public files are located)
# DirectoryIndex index.html
DocumentRoot /path/to/app/public
# Custom log file locations
ErrorLog /path/to/log/example.com/error.log
CustomLog /path/to/log/example.com/access.log combined
</VirtualHost>
Some important notes:
the default environment is "production"
be sure your DocumentRoot points to the /public folder of your app, not to the app root
Related
I currently have a rails app that works locally but at the moment of deploying the app i'm having an error configuring the server.
I followed the steps here, and i'm stuck on step 6. Instead of seeing the rails webpage i got
Inside /etc/apache2/sites-available/tesis.conf i got
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/tesis/public
RailsEnv development
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/tesis/public">
Options -MultiViews
Require all granted
Allow from all
</Directory>
And the rails app is located at /var/www/html/tesis/public, so that makes sense, but the odd thing is that debugging the apache error logs (/etc/apache2/sites-available/tesis.conf) i see:
[client 143.244.50.172:44448] AH01630: client denied by server configuration: /home/deploy/tesis/public/config
Why apache is going to that path instead of the one i specify on the configuration file?
running a R.o.R. site on passenger. Passenger is running fine, but I'm not sure if I am having an issue with the way I setup my vHosts or what, but It's returning a the apache start page, and not my application.
When I run
passenger-status
here is the message:
Version : 4.0.18
Date : 2013-09-26 10:42:03 -0400
Instance: 20958
----------- General information -----------
Max pool size : 6
Processes : 0
Requests in top-level queue : 0
----------- Application groups -----------
[USERNAME#gregorymurray relaunchradio]#
Here is the passenger stuff in my httpd.conf:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger- 4.0.18/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.18
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
PassengerDefaultUser root
No problem that I see there, here is my vhost.conf file in the main directory of my site:
ServerName gregorymurray.com
ServerAlias gregorymurray.com
DocumentRoot /var/www/vhosts/gregorymurray.com/relaunchradio/public
PassengerAppRoot /var/www/vhosts/gregorymurray.com/relaunchradio
<Directory "/var/www/vhosts/gregorymurray.com/relaunchradio/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsEnv production
RailsBaseURI /
Here are the two links I followed in the process of getting this running:
http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers
https://coderwall.com/p/lu3nfa
Are you sure apache2 is finding the vhost.conf file? Are you using some kind of shared hosting that requires placing that file in your website's main directory? Because, that's not the normal setup. The virtual hosts file belongs under /etc/apache2 or /etc/httpd depending on whether using Ubuntu or centOS. Look at your apache conf file to find out where it's looking for the virtual hosts.
Open /etc/httpd/conf/httpd.conf and look for vhost.conf. Or look for a Include directive of the full path to your gregorymurray.com. I doubt either one will be found. Which means you need to move vhost.conf to /etc/httpd/conf/sites-enabled/vhost.conf and add Include sites-enabled/ in your httpd.conf just above the passenger module stuff.
Placing your vhost.conf in your website directory would require that you alter your httpd.conf to look in that website directory for a virtual host conf file. That's not the default setup or conventional setup.
I have installed the Skeleton Application manually. My application is kept in "D:\xampp\htdocs\zf2". I've created a virtual host in the following way, in httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
<Directory "D:/xampp/htdocs/zf2/public/index.php">
#DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but it does not shown properly and it gives the output
and the remain ing application with module and database shows also not shows in the proper way
but if i slightly modify in virtual host settings of
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
to
DocumentRoot "D:/xampp/htdocs/zf2/public"
then, skeleton application shows fine but when i configure module and database it gives error "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. zend sleleton application error"
can any one help me i have waste lot of time to set it but didn't.
You need to set document root to the folder not a file. The page looks messed up when pointing to index.php as documentroot because it cannot find the stylesheets.
The issue with configuring the module/database is probably a different issue, and you would have to post your module/database configuration to get help there.
I'd like to enable Apache directory listings on a specific subdirectory of my Rails application's "public/" directory. For the sake of this discussion, let's say it is the "public/listme"
I've set Apache options to enable directory listings, but if I request something like http://mydomain.com/listme, I get a 404 error, and if I check the Rails log, I get an error like:
ActionController::RoutingError (No route matches "/listme")
So: is there a way to disable routing for a specific folder within my Rails app and allow Apache's automatic directory listings to kick in?
It turns out that this question is answered in the modrails documentation. See http://www.modrails.com/documentation/Users%20guide%20Apache.html
In summary :
Suppose that you have a Rails application in /apps/foo. Suppose that you’ve dropped Wordpress — a blogging application written in PHP — in /apps/foo/public/wordpress. You can then configure Phusion Passenger as follows:
<VirtualHost *:80>
ServerName www.foo.com
DocumentRoot /apps/foo/public
<Directory /apps/foo/public/wordpress>
PassengerEnabled off
AllowOverride all # <-- Makes Wordpress's .htaccess file work.
</Directory>
</VirtualHost>
I'm trying to get multiple rails apps hosted under the same domain, but different directories. My configuration before attempting to host multiple apps (which works great), looks like this:
<VirtualHost *:443>
ServerName secure.mydomain.com
DocumentRoot /root/store/public
</VirtualHost>
I google'd around and found documentation suggesting I use the following configuration:
<VirtualHost *:443>
ServerName secure.mydomain.com
DocumentRoot /root
RailsBaseURI /store/public
RailsBaseURI /store2/public
</VirtualHost>
That configuration, however, only causes my directory structure to be revealed, and no app appears to run. Any advice would be great!
Not sure what you found on the Googles, but you might want to re-read the mod_rails docs on Deploying to sub URIs
I'm guessing you'll need to create some symbolic links (aliases) in your /root directory to the public folder of each application
ln -s /store/public /root/store