rubyonrailsin

A Ruby and Rails talk

Tuesday, March 23, 2010


Re: [Rails] Re: Blank Log Files - New to RoR - Ubuntu Server 9.10

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

On Tue, 2010-03-23 at 12:38 -0700, Justin wrote:
> Michael,
>
> Thanks SO much for helping me. I still haven't gotten the logs to
> populate, even with root:www-data
>
> No luck with your chown -R root:www-data testapp1
> If restarted apache: /etc/init.d/apache2 restart
> * Restarting web server apache2
> ... waiting ...done.
>
> My symbolic link:
> $ cd /var/www
> $ ls -l
> lrwxrwxrwx 1 root www-data 31 2010-03-21 07:55 testapp1 -> /home/
> justinschier/www/testapp1
>
> My home www folder:
> $ cd /home/justinschier
> $ ls -l
> drwxrwxrwx 3 root www-data 4096 2010-03-20 08:02 www
>
> My testapp1 folder:
> $ cd /home/justinschier/www
> $ ls -l
> drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 testapp1
>
> My log folder:
> $ cd /home/justinschier/www/testapp1
> $ ls -l
> ...
> drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 log
> ... (everything's the same permissions and ownership as log)
>
> My log files:
> -rwxrwxrwx 1 root www-data 1676 2010-03-22 20:58 development.log
> -rwxrwxrwx 1 root www-data 0 2010-03-20 08:02 production.log
> -rwxrwxrwx 1 root www-data 0 2010-03-20 08:02 server.log
> -rwxrwxrwx 1 root www-data 0 2010-03-20 08:02 test.log
>
> I know the development.log is showing now, BUT that's because I tried
> running WebBrick. That's why there's something in there.
>
>
> My /public folder (no .htaccess file):
> $ cd /home/justinschier/www/testapp1/public
> $ ls -al
> drwxrwxrwx 5 root www-data 4096 2010-03-22 08:21 .
> drwxrwxrwx 13 root www-data 4096 2010-03-20 08:02 ..
> -rwxrwxrwx 1 root www-data 947 2010-03-20 08:02 404.html
> -rwxrwxrwx 1 root www-data 930 2010-03-20 08:02 422.html
> -rwxrwxrwx 1 root www-data 948 2010-03-20 08:02 500.html
> -rwxrwxrwx 1 root www-data 0 2010-03-20 08:02 favicon.ico
> drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 images
> -rwxrwxrwx 1 root www-data 7466 2010-03-20 08:02 index.html
> drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 javascripts
> -rwxrwxrwx 1 root www-data 204 2010-03-20 08:02 robots.txt
> drwxrwxrwx 3 root www-data 4096 2010-03-22 15:30 stylesheets
>
>
> Still when I run this, the log files don't grow at all:
> http://testapp1.fuse.sonikserver.com/
> Welcome Aboard Page loads correctly
>
> http://testapp1.fuse.sonikserver.com/rails/info/properties
> and I still get "We're sorry, but something went wrong"
>
> Apache has instances running as both root and www-data:
> $ ps aux | grep apache2
> root 14157 0.0 0.3 141016 8040 ? Ss 12:24 0:00 /usr/
> sbin/apache2 -k start
> root 14170 0.0 0.0 23192 1888 ? Sl 12:24 0:00 /var/
> lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/
> ApplicationPoolServerExecutable 0 /var/lib/gems/1.8/gems/
> passenger-2.2.11/bin/passenger-spawn-server /usr/bin/ruby1.8 /tmp/
> passenger.14157
> www-data 14175 0.0 0.2 141492 6036 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14176 0.0 0.2 141348 5812 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14177 0.0 0.2 141348 5812 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14178 0.0 0.2 141476 5796 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14179 0.0 0.2 141476 5924 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14183 0.0 0.2 141476 5852 ? S 12:24 0:00 /usr/
> sbin/apache2 -k start
> www-data 14188 0.0 0.2 141016 4692 ? S 12:25 0:00 /usr/
> sbin/apache2 -k start
> root 14206 0.0 0.0 7340 884 pts/0 S+ 12:27 0:00 grep
> apache2
>
>
> I even got rid of the symbolic link (above) and no change:
>
> $ vi /etc/apache2/sites-available/default
>
> Now reads:
>
> ... default part ommitted for this post ....
>
> LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.11/
> ext/apache2/mod_passenger.so
> PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.11
> PassengerRuby /usr/bin/ruby1.8
>
> <VirtualHost *:80>
> ServerName testapp1.fuse.sonikserver.com
> DocumentRoot /home/justinschier/www/testapp1/public
> <Directory /home/justinschier/www/testapp1/public>
> Allow from all
> Options -MultiViews
> </Directory>
> </VirtualHost>
>
> Man, I am so out of ideas. Anything else you can think of for me to
> try?
>
> Thanks again SOOO much. If you have an Amazon wish list, I'm totally
> buying you something.
----
log files are written by rails as the 'user', not by the apache user.
See the directory listing of my 'logs' below.

Apache user is www-user anyway, not root. Root user is only for the
master process.

you should change the ownership back on all files/folders
in /home/justinscheier/www/testapp1

Then, you need to indicate in your apache configuration which RailsEnv
is to be used...

<VirtualHost *:80>
ServerName testapp1.fuse.sonikserver.com
DocumentRoot /home/justinschier/www/testapp1/public
## note the following line ##
RailsEnv production # or development if that's what you are running
##
<Directory /home/justinschier/www/testapp1/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>

Passenger is very clever and can be forced to restart just by issuing the command (as user), 'touch tmp/restart.txt'

On my setups (RH/CentOS/Fedora), apache is both user and group and apache web server runs as user:group apache:apache

thus...
drwxrwxr-x 3 craig apache 4096 2010-03-21 03:17 log
drwxrwxr-x 7 craig apache 4096 2010-03-06 01:23 tmp

note: apache group on both folders and group permissions are rwx (or chmod 775 log tmp)

also, inside tmp...
$ ls -l tmp/
total 16
drwxrwxr-x 3 craig apache 4096 2010-02-09 02:58 cache
drwxrwxr-x 3 craig apache 4096 2010-02-09 02:58 pids
-rw-rw-r-- 1 craig craig 0 2010-03-23 00:12 restart.txt
drwxrwxr-x 3 craig apache 4096 2010-02-09 02:58 sessions
drwxrwxr-x 3 craig apache 4096 2010-02-09 02:58 sockets

the only places you should even think about changing ownership (log & tmp) and even then, just the group bits, not the user.

root is used nowhere.

The other thing you have to make certain of, is that if you are running apache from your home directory, that the apache user (in your case, www-data) can actually access.

so ls -ld /home /home/justinscheier /home/justinscheier/www /home/justinscheier/www/testapp1 must all be 'o+x' so the web server user can access.

** log files (with logrotate handling weekly rotation, development log only updates when I run script/console)
$ ls -l log
total 23932
-rw-r--r-- 1 craig craig 9546293 2010-03-19 22:29 development.log
-rw-r--r-- 1 craig craig 1052394 2010-03-23 20:07 production.log
-rw-r--r-- 1 craig craig 4943853 2010-02-28 03:21 production.log-20100228
-rw-r--r-- 1 craig craig 2694898 2010-03-07 03:38 production.log-20100307
-rw-r--r-- 1 craig craig 2908919 2010-03-14 03:33 production.log-20100314
-rw-r--r-- 1 craig craig 3306385 2010-03-21 03:17 production.log-20100321

Craig


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive