On my my VPS with cpanel (CentOs) I have two rails projects on different virtual hosts served by Passenger.
The second project is a branch of first, so now they are equal.
Directories of them are:
/home/web/public_html/msystem
/home/web/public_html/msystem2
Settings in httpd.conf:
<VirtualHost My.host.IP.adress:80>
ServerName msystem.mydomain.com
ServerAlias www.msystem.mydomain.com
DocumentRoot /home/web/public_html/msystem
CustomLog /usr/local/apache/domlogs/msystem.mydomain.com combined
CustomLog /usr/local/apache/domlogs/msystem.mydomain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
ScriptAlias /cgi-bin/ /home/web/public_html/msystem/cgi-bin/
Include "/usr/local/apache/conf/userdata/std/2_2/web/msystem.mydomain.com/*.conf"
</VirtualHost>
/usr/local/apache/conf/userdata/std/2_2/web/msystem.mydomain.com/msystem.conf:
DocumentRoot /home/web/public_html/msystem/public/
<Directory /home/web/public_html/msystem/public/>
AllowOverride all
Options -MultiViews
</Directory>
I removed all standard cpanel lines. The second VirtualHost is the same, except replacing msystem -> msystem2.
The first project works, the second no.
There is a Delayed Job in project. And in both projects I set my logger in initializers/delayed_job.rb:
Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'dj.log'))
The second project raises with error:
Permission denied # rb_sysopen - /home/web/public_html/msystem2/log/dj.log (Errno::EACCES)
This dj.log in both projects has equal permissions:
# ls -l msystem/log/dj.log
-rw-r--r-- 1 nobody nobody 10604043 Aug 7 12:34 msystem/log/dj.log
# ls -l msystem2/log/dj.log
-rw-r--r-- 1 nobody nobody 66 Aug 8 09:25 msystem2/log/dj.log
Passenger on error page says that he runs by nobody:nobody user.
User and groups
uid=99(nobody) gid=99(nobody) groups=99(nobody)
I read many topics on stackoverflow.com about this error. I tryed to change owner to root or permissions to 777. Tryed to restart Apache, Passenger.
First works, second not. What is it? May be I forgot something?
This question has an answer:
Ruby on Rails: permission denied when using "rails generate controller welcome"
chmod 1644 msystem2/log
Related
So I am using digital ocean to host my ruby on rails application
I used this tutorial on how to deploy it: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04
After completing it I have tried to access my server through its IP address and it gives me a 403 Access Denied Error and checking the apache error log I find the following message:
AH01630: client denied by server configuration: /home/appname, referer: http://IPADDRESS/
My /etc/apache2/sites-available/appname.conf files is as follows:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# 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.peerparking.com
ServerAlias www.peerparking.com
ServerAdmin webmaster#localhost
DocumentRoot /home/peerparking/peerparking/peerparking/public
RailsEnv development
# 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
DocumentRoot /home/peerparking/peerparking/peerparking/public
RailsEnv development
# 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
<Directory /home/peerparking/peerparking/peerparking/public>
Require all granted
Options FollowSymLinks
</Directory>
# 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
My ruby on rails app is located at /username/home/appname/appname/appname
Dont ask why I have three successive folders named the same, I messed up pulling from my repository
I am very new to ROR and currently following book "Agile Web Development with Rails v4".
According Iteration K1: Deploying with Phusion Passenger and MySQL (at page 233), I tried config the server using config below
<VirtualHost *:80>
ServerName depot.yourhost.com
DocumentRoot /home/rubys/work/depot/public/
<Directory /home/rubys/work/depot/public>
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now I can see the server but it only shows the list of files in public folder (like below). And my public folder has no any default html file.
Index of
Name Last modified Size Description
404.html 2015-01-02 22:52 1.3K
422.html 2015-01-02 22:52 1.3K
500.html 2015-01-02 22:52 1.2K
favicon.ico 2015-01-02 22:52 0
robots.txt 2015-01-02 22:52 202
Apache/2.4.7 (Ubuntu) Server at 192.168.0.195 Port 80
Can you please give me some direction what I did wrong.
Thanks
I have just installed Redmine(2.5.2) on Ubuntu 14.04.
I am using Apache2+Passenger
The site works fine but it does not load css files like the following screenshot.
When I inspect, this is what I get.
My VirtualHost is shown below.
ServerAdmin admin#example.com
ServerName redmine.example.com
DocumentRoot /usr/local/redmine/public
RailsEnv production
RailsBaseURI / <Directory /usr/local/redmine/public>
Options Indexes FollowSymLinks
AllowOverride All </Directory>
ErrorLog ${APACHE_LOG_DIR}/redmine.example.com-error.log </VirtualHost>
Does anyone have a suggestion on how to fix this problem?
Than you!!!
Update
This is apache error log
[Mon Sep 22 09:00:58.736635 2014] [authz_core:error] [pid 20338] [client 175.130.114.60:56351] AH01630: client denied by server configuration: /usr/local/redmine/public/stylesheets/application.css
I don't see any error in redmine/log/production.log
I found the solution to this.
I got an answer from this SO article
The issue lied with my VirtualHost configuratoin
I added the following line
Require all granted
Situation is like this :
I have hosting company justhost.com
There I have main domain and two subdomains. First subdomain is with PHP
based webpage, but second is newly created and based on ruby on
rails.
I want such thing, before I am sure that newly created application on RoR is functioning well, keep old one up and running. But somehow when I want modify .htaccess file with code for RoR (source- https://my.justhost.com/cgi/help/rails#access ).
main htacces file located on root_page :
DirectoryIndex index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm home.htm default.htm index.fcgi default.html
# -FrontPage-
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthUserFile /home/ecotec11/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ecotec11/public_html/_vti_pvt/service.grp
ErrorDocument 404 /404.shtml
AuthName ecotechno.lv
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
htacces file for RoR application:
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Change to your environment
RailsEnv production
RailsBaseURI /$HOME/$USER/eco
SetEnv GEM_HOME /
This is what I get :
http://gyazo.com/291394024c60284e315b04b3b91128f4 :
It seems that project can't find installed gems or valid rails installation. I tried to update rails installation, but now when it succeded there is no change at all.
Thanks
I own the domain, "peterlee.com.cn", and I added an A Record in my domain control panel:
RR Destination IP TTL
rs.peterlee.com.cn 10.50.10.75 1 hour
I have an RoR (Ruby on Rails) project running on 10.50.10.75:9051, which means the user can visit my RoR application by http://10.50.10.75:9051
I want to let the user visit it by http://rs.peterlee.com.cn, so I added the following VirtualHost File/Site:
<VirtualHost *:80>
ServerName rs.peterlee.com.cn
DocumentRoot /usr/website/myapp/current/public
PassengerEnabled off
ProxyPass / http://127.0.0.1:9051/
ProxyPassReverse / http://127.0.0.1:9051/
RackEnv production
RailsEnv production
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all requests to the maintenance page if present
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</IfModule>
</VirtualHost>
After enabling the site and restarting the Apache2, I tried http://rs.peterlee.com.cn, it gives me the 500 Internal Server Error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.22 (Ubuntu) Server at rs.peterlee.com.cn Port 80
Thanks.
Peter
I found the following warning in /var/log/apache2/error.log:
[Thu Jul 19 10:22:20 2012] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
[Thu Jul 19 10:22:20 2012] [warn] proxy: No protocol handler was valid for the URL /favicon.ico. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
So I enable the following modules:
sudo a2enmod proxy proxy_balancer proxy_http
After restarting Apache2, it worked!
Thanks anyway.
BTW: I start the service using Passenger:
passenger start -a 127.0.0.1 -p 9051 -e production -d