Blank Log Files - New to RoR - Ubuntu Server 9.10

Hi -

I’ve got what seems to be a solid installation of Ubuntu Server 9.10
with the latest version of ruby, rails, etc.

I followed the Ubuntu installation guide.

I set up a Virtual Site with Apache.

The Welcome Aboard page shows correctly.

However, when I click “About your application’s environment”, I get a
very unhelpful error message that says:
“We’re sorry, but something went wrong.”

All four log files in my /log directory are 0 bytes.

Any idea how I can get the logs to at least show me what’s going on?

Thanks very much,
Justin Schier

On 22 March 2010 04:30, Justin [email protected] wrote:

All four log files in my /log directory are 0 bytes.

Any idea how I can get the logs to at least show me what’s going on?

Sounds like permissions; does the www-data user own the application
directory?
chown -R www-data.www-data my_rails_app

However, when I click “About your application’s environment”, I get a
very unhelpful error message that says:
“We’re sorry, but something went wrong.”

I’ve found in the past that problems accessing the application after a
fresh install are often DB problems - like I’ve forgotten to run
migrations or something :wink:
Can you fire up an IRB session and run code? - even something simple
like “User.all”…

Michael,

I didn’t know about www-data, but your suggestion still didn’t work. I
rebooted the server completely. I still get the blank logs. Also, I
still get the correct Welcome Aboard page, but when I click “About
your application’s environment”, I still get “We’re sorry, but
something went wrong”. There’s only one installation of rails on the
server, so I know this must be it.

http://testapp1.fuse.sonikserver.com

Apache /etc/apache2/sites-available/default:

---- Default VirtualHost - omitted 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 /var/www/testapp1/public
<Directory /var/www/testapp1/public>
Allow from all
Options -MultiViews

$ cd /var/www
$ ls -l
lrwxrwxrwx 1 www-data www-data 31 2010-03-21 07:55 testapp1 → /home/
justinschier/www/testapp1

$ cd /home/justinschier
$ ls -l
drwxrwxr-x 3 www-data www-data 4096 2010-03-20 08:02 www

$ cd www
$ ls -l
drwxrwxr-x 13 www-data www-data 4096 2010-03-20 08:02 testapp1

$ cd testapp1/log
$ ls -l
-rwxrwxrwx 1 www-data www-data 0 2010-03-20 08:02 development.log
-rwxrwxrwx 1 www-data www-data 0 2010-03-20 08:02 production.log
-rwxrwxrwx 1 www-data www-data 0 2010-03-20 08:02 server.log
-rwxrwxrwx 1 www-data www-data 0 2010-03-20 08:02 test.log

Trust me, chown -R www-data:www-data testapp1 did work - everything is
owned by www-data www-data

Please help - I’m losing my mind.

Thanks,
Justin

On 22 March 2010 14:11, Justin [email protected] wrote:

I didn’t know about www-data, but your suggestion still didn’t work. I
rebooted the server completely. I still get the blank logs. Also, I
still get the correct Welcome Aboard page, but when I click “About
your application’s environment”, I still get “We’re sorry, but
something went wrong”. There’s only one installation of rails on the
server, so I know this must be it.

I’d focus on trying to get the logs populating first… any other
problems are not going to be easier to fix without it - and you might
find that whatever problem is causing the log-files not to get written
might be causing others…

Did you try accessing your models in the console? What was the outcome
to that? You may get a hint that pushes you in the right direction.

Anyway, the idea to change the owner of the files is more general than
specific; I’m assuming your server’s using the www-data user to run
the site - if it’s a different user, the ownership needs to be
different.
Anything in the Apache error logs?

On 23 March 2010 09:57, Michael P. [email protected] wrote:

On 22 March 2010 14:11, Justin [email protected] wrote:

I didn’t know about www-data, but your suggestion still didn’t work.

I just checked a server I have here (Ubuntu 9.04LTS) and the directory
ownership is slightly different to what I said.
I’ve got it as:
chown -R root.www-data my_rails_app

Also worth checking the permissions of the log folder, and if there’s
log files in there, check their perms - delete them if necessary and
see if the app recreates them once all the ownership is set.

How about trying to put the server in development mode (if necessary
diff
the production.rb and development.rb files and copy the settings, such
as
consider_all_requests_local, over to production.rb) so that the error
will
be printed out to the screen instead of the log?

Remember to put it back afterwards, but that might let you see what it
thinks is wrong…

Cheers,

Andy


Andy J.
http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS
Company number: 5452840

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

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.

Justin

On Tue, 2010-03-23 at 12:38 -0700, Justin wrote:

My symbolic link:
My testapp1 folder:

My /public folder (no .htaccess file):
drwxrwxrwx 2 root www-data 4096 2010-03-20 08:02 javascripts

sbin/apache2 -k start
www-data 14188 0.0 0.2 141016 4692 ? S 12:25 0:00 /usr/

<Directory /home/justinschier/www/testapp1/public>
    Allow from all
    Options -MultiViews
</Directory>

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>

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.

Success!! (Sorry for the delay - I’ve been under the weather and busy
with some other things)

It’s working in development, but not production mode. (Can you help
with that?)

The changes I made:

  1. Change ownership on everything to www-data:www-data
  2. chmod -R 775 /home
  3. Added RailsEnv development to apache config
  4. touch /home/justinschier/testapp1/tmp/restart.txt
  5. Deleted /log/production.log

After that, I got the configuration screen to show correctly and the
development.log was written

However, when I changed to RailsEnv production and restarted apache,
now I get “We’re sorry, but something went wrong”. I’m sure the /
config/environments/production.rb file is original. The /log/
production.log file was re-created automatically

The production.log now only has this one line:

Logfile created on Tue Apr 06 15:11:14 -0700 2010

Questions:
A. Should justinschier be the user, instead of www-data?
B. Is there anything else I should check to see why production isn’t
working?

Thanks very, very much,
Justin Schier

On 23 March 2010 19:38, Justin [email protected] wrote:

Michael,

Thanks SO much for helping me. I still haven’t gotten the logs to
populate, even with root:www-data

Justin,

I don’t know what you’re so impressed with me for… we’ve not sorted
your problem. And I’m afraid I pretty much out of ideas, I’m afraid
:frowning:

It’s bugging me, because I had the same issue a couple of weeks ago
(log files not being written to), although my application was working.
But I can’t remember what was the thing that fixed it, and I’m not at
home to look to see if I made any notes.

Just looking through your post again; if you delete the log files, do
they get created by Apache? And what does the tail of the Apache log
say?