Redmine in Apache shows Blank Page - ruby-on-rails

I've just tried to configure Redmine on my Apache server, as folows:
Files in /var/www/redmine.my.domain
In /etc/apache2/sites-available/redmine.my.domain.conf
<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.
ServerName redmine.my.domain
ServerAdmin webmaster#localhost
DocumentRoot /var/www/redmine.my.domain/public/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/redmine.my.domain/public>
Options Indexes ExecCGI FollowSymLinks
Order allow,deny
Allow from all
AllowOverride all
Options Indexes FollowSymLinks MultiViews
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
It only shows a blank page. Does anyone know what may be missing?

Redmine is RoR (Ruby on Rails) application, for usage and installation, official wiki should be followed since there are multiple steps and ways to run it on different platforms. Cick here and find the best way for your case.
In order to run it via Apache you must either run it as CGI/FCGI which is not very common way.
Or to run it via PhusionPassenger Apache module or PhusionPassenger standalone.
One common way to run it is via some Ruby app server like Puma, Unicorn, Webrick or Thin, then Apache or Ngnix reverse proxy it.
As stated earlier, various methods to run it, depending upon platform are described in official wiki.

Related

Apache + Passenger Rails app failing with a 403 error

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?

Images are not loading on production

I'm deploying a Rails app to Digitalocean. I'm working with Apache and Passenger. I was able to run my app locally in production and worked fine. I had the same problem on localhost but did the following things to make it work. Locally I work with Webrick server and in Ubuntu with Apache.
Installed these gems:
therubyracer
execjs
I added this to production.rb
config.serve_static_files = true
config.assets.compile = true
config.assets.precompile = ['*.js', '*.css']
Then I did
RAILS_ENV=production bundle exec rake assets:precompile
I tried the same for production in Ubuntu and everything seems fine but the images.
This is what I have in /etc/apache2/sites-available/metalmind.com.co.conf
<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.
#ServerName www.example.com
ServerAdmin something#hotmail.com
ServerName metalmind.com.co
ServerAlias www.metalmind.com.co
DocumentRoot /home/luisjar/Metalmind_2/public
<Directory "/home/luisjar/Metalmind_2/public">
Options All
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I appreciate any help here.
For images to load in production , you need to check certain things -
1) What's the url being generated where you see no image loaded (Use firebug to see the url path)
2) Where are you storing your images , is it under images or under public folder .
3) Have you precompiled you assets for production using this command (rake assets:precompile RAILS_ENV=production)
Also , in cases like these logs are quite helpful too .

Rails application isn't restarting after system reboot

I have a Rails 4 application deployed with Apache and Passenger.
The configuration was provided by this thread and everything worked perfectly.
I created a whenever job that runs when the machine restarts, and I rebooted the machine to check if it works, and it does.
BUT, from some reason my web address is no longer reachable. It seems like the machine doesn't route the requests to the application (I get "this webpage isn't available" message from the browser).
I've double checked the /etc/httpd/conf/httpd.conf file to make sure the configuration still exists and it does.
I also tried to push again the application to the machine using cap production deploy, and didn't get any errors while doing that.
My configuration in the /etc/httpd/conf/httpd.conf file is the following:
<VirtualHost *:80>
ServerName csi-eng-perf.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/eng_performance/current/public/
<Directory /var/www/eng_performance/current/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>
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>
</VirtualHost>
I have no idea what have gone wrong.
Well, as it turns out #Substantial suggestion was correct.
I wasn't able to issue the apachectl status command (needed the installation of another package called links) but the restart command did the trick- apachectl -k restart.

confused about apache server virtual host

So I configured a VirtualHost in the httpd-vhosts.conf directory, but whenever I navigate to the servername, it seems to always give me the page listed in httpd.conf.
I am new to apache web server and am not sure what else I need to do.
In my httpd-vhosts.conf I have
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName helloworld.com
DocumentRoot /Users/username/Desktop/RailsDemo/depot/public/
<Directory /Users/username/Desktop/RailsDemo/depot/public/>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In my httpd.conf, I have default settings, so I didn't change anything since install.
Also, I have matched helloworld.com to the correct ip address. Typing helloworld.com into the browser produces the wrong view...it produces the view indicated in httpd.conf.
If this helps, I am trying to do p. 238 of Pragmatic Agile Web Development with Ruby on Rails (4th Edition) -- Iteration K1: Deploying with Phusion Passenger and MySQL
Any help would be appreciated, thanks!
You seem to be running Mac OS X. In your httpd.conf, you will have the lines;
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Remove the comment, making it
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
Restart apache, and that should activate your named vhost.

Setting up Rails app on Apache with passenger - Rails doesn't seem to load

I am trying to set up Rails on a Ubuntu instance by following along with documentation such as https://help.ubuntu.com/community/RubyOnRails. I am trying to set up the app from the Rails Getting Started page here: http://guides.rubyonrails.org/getting_started.html.
What I have done so far:
Installation of Ruby/RubyGems/Rails through RVM and GEM (this installed Ruby 1.9.2 and Rails 3.0.7)
Installation of the mysql and mysql2 module (latter which didn't work)
Creation of rails app (blog app as tutorial is instructing)
Sym linking of /home/me/www/blog/public/ from /var/www/blog/
Creation of DB through rake
Installation of passenger module for Rails execution in Apache
Running of passenger-install-apache2-module to configure Apache
Deletion of public.html file from public/ rails app folder so that my controller/view can fire
Configuration of sites-available files for virtual hosts
Configuration of Rails routing
I believe it is the last two steps that are tripping me up, partly due to lack of familiarity with Apache and Rails (I am new to both).
In my virtual host file I am trying to point to the blog public dir in /var/www/blog. For my Rails route I have root :to => "home#index" as instructed.
When I browse to the http:// url I should normally be seeing my "Hello, Rails!" page per section 4.3 of the Getting Started guide, however all I see is the directory listing from Apache. Static pages work but not Rails processing.
At this point I am unclear if the passenger module is even doing anything or where to look for any evidence of what is happening. I tried various things like running the Rails app off a different virtual host called "blog" at http:///blog and the routing worked (static pages and all) but no Rails as above.
Update: after playing around some more, I now get a new error message (404):
Not Found
The requested URL /dispatch.cgi was
not found on this server.
I have since determined that this cgi 404 was caused by a rewrite rule I had added to .htaccess from guidance from the help.ubuntu.com page I pointed out above. Looks like it wasn't necessary or applied to an older version of Rails. The inconsistencies in instructions when looking up help online is disorienting! Removing the file leaves me with the previous problem though.
Here's the entry in the Apache log that I believe correlates with the first error. Although I am no longer getting this error it seems, may be related to something else I was trying before...
[Fri May 27 22:49:41 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9 with Suhosin-Patch Phusion_Passenger/3.0.7 configured -- resuming normal operations
[Fri May 27 22:51:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/rails, referer: http://192.168.1.138/blog/
Here's the most recent entry with the 404 on the cgi thing:
[Sat May 28 08:01:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/dispatch.cgi
What could I be missing? Thanks!
Additional details as requested. Apache sites file:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/blog/
RailsEnv development
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
<Directory "/var/www/blog/">
Options Indexes FollowSymLinks -MultiViews +ExecCGI
AllowOverride All
Order allow,deny
allow from all
# AddHandler cgi-script .cgi
</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>
Another update: I was able to get it working, finally, by using a top level DocumentRoot (/var/www) and basing my Rails app off that using RailsBaseURI. This maps to the "Deploying to a sub URI" section of the Phusion Passenger instructions. It is used as http:///blog which is not really what I wanted to get, but it's kind of irrelevant as I am using this just to learn Rails in a virtual. I will need to go and work on getting it working as a top level app again sometime later. Here's my current (final) VirtualHost file for reference:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
RailsEnv development
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
</Directory>
RailsBaseURI /blog
<Directory /var/www/blog/>
Options Indexes FollowSymLinks -MultiViews +ExecCGI
AllowOverride All
Order allow,deny
allow from all
# AddHandler cgi-script .cgi
</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>
Deploying a Ruby on Rails application
Suppose you have a Ruby on Rails
application in /webapps/mycook, and
you own the domain www.mycook.com. You
can either deploy your application to
the virtual host’s root (i.e. the
application will be accessible from
the root URL, http://www.mycook.com/),
or in a sub URI (i.e. the application
will be accessible from a sub URL,
such as
http://www.mycook.com/railsapplication).
Deploying to a virtual host’s root
Add a virtual host entry to your
Apache configuration file. Make sure
that the following conditions are met:
The virtual host’s document root must
point to your Ruby on Rails
application’s public folder.
The Apache per-directory permissions
must allow access to this folder.
MultiViews must be disabled for this
folder.
For example:
<VirtualHost *:80>
ServerName www.mycook.com
DocumentRoot /webapps/mycook/public
<Directory /webapps/mycook/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
You may also need to tweak your
file/folder permissions. Make sure
that the following folders are
readable and executable by Apache:
this public folder.
the application’s config folder.
all parent folders. That is, /webapps/mycook and /webapps must also
be readable and executable by Apache.
Then restart Apache. The application
has now been deployed.
Read the whole docs here
Double check to make sure passenger is loading your application by typing
sudo passenger-status
This will show you an error if passenger isn't loaded or the below if it is. Note the part where it shows you which application or applications it has loaded and what the current uptime is:
----------- General information -----------
max = 6
count = 1
active = 0
inactive = 1
Waiting on global queue: 0
----------- Application groups -----------
/home/rourkem/public_html/evecord.com/current:
App root: /home/rourkem/public_html/evecord.com/current
* PID: 18976 Sessions: 0 Processed: 5 Uptime: 23m 55s
Be sure to delete the file index.html from the public directory of your application.

Resources