Reputation: 88
Deploying a RoR app on:
I'm deploying as user root just to try things out. When I run Apache and hit the app, I get his error in my log/production.log (and of course Rails' HTTP 500 HTML appears on the browser):
F, [2013-10-24T21:54:50.253917 #29204] FATAL -- :
Errno::EACCES (Permission denied - /depot/tmp/cache):
app/views/store/index.html.erb:11:in `_app_views_store_index_html_erb___649405275_79899210'
I did some searching and it may be a user permissions issue. I looked at the users running the various process on my server. Here's a top
dump:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 3520 1696 1276 S 0.0 0.3 0:00.76 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.36 ksoftirqd/0
5 root 20 0 0 0 0 S 0.0 0.0 0:00.12 kworker/u:0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
7 root RT 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/0
8 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 cpuset
9 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
11 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
12 root 20 0 0 0 0 S 0.0 0.0 0:00.04 sync_supers
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
17 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
20 root 20 0 0 0 0 S 0.0 0.0 0:00.25 kworker/u:1
21 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
22 root 20 0 0 0 0 S 0.0 0.0 0:00.65 kswapd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
24 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 ecryptfs-kthrea
26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
34 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld
37 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
38 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1
58 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 devfreq_wq
248 root 20 0 0 0 0 S 0.0 0.0 0:00.57 jbd2/vda-8
249 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ext4-dio-unwrit
313 root 20 0 2816 428 428 S 0.0 0.1 0:00.05 upstart-udev-br
316 root 20 0 3088 724 724 S 0.0 0.1 0:00.03 udevd
411 root 20 0 3084 276 272 S 0.0 0.1 0:00.00 udevd
412 root 20 0 3084 280 276 S 0.0 0.1 0:00.00 udevd
426 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
553 root 20 0 2828 200 196 S 0.0 0.0 0:00.00 upstart-socket-
580 messageb 20 0 3240 428 428 S 0.0 0.1 0:00.00 dbus-daemon
622 syslog 20 0 30020 1008 952 S 0.0 0.2 0:00.71 rsyslogd
636 root 20 0 4612 776 656 S 0.0 0.2 0:00.00 getty
637 root 20 0 4612 776 656 S 0.0 0.2 0:00.00 getty
650 root 20 0 4612 772 656 S 0.0 0.2 0:00.00 getty
651 root 20 0 4612 768 656 S 0.0 0.2 0:00.00 getty
655 root 20 0 4612 776 656 S 0.0 0.2 0:00.00 getty
663 root 20 0 2156 592 496 S 0.0 0.1 0:00.00 acpid
664 root 20 0 2600 848 680 S 0.0 0.2 0:00.02 cron
666 daemon 20 0 2452 344 220 S 0.0 0.1 0:00.00 atd
745 root 20 0 6664 2348 1912 S 0.0 0.5 0:00.00 sshd
751 root 20 0 4612 776 660 S 0.0 0.2 0:00.00 getty
7272 mysql 20 0 319m 36m 7044 S 0.0 7.5 0:03.82 mysqld
7625 root 20 0 8176 4352 2688 S 0.0 0.9 0:00.82 apache2
28278 root 20 0 0 0 0 S 0.0 0.0 0:00.00 flush-253:0
28554 root 20 0 0 0 0 S 0.0 0.0 0:00.05 kworker/0:2
28681 root 20 0 0 0 0 S 0.0 0.0 0:00.05 kworker/0:0
28970 root 20 0 11408 3340 2616 S 0.0 0.7 0:00.04 sshd
28984 depot 20 0 11408 1560 832 S 0.0 0.3 0:00.02 sshd
28985 depot 20 0 10168 6552 1596 S 0.0 1.3 0:00.35 bash
29102 www-data 20 0 8216 2208 524 S 0.0 0.4 0:00.00 apache2
29103 root 20 0 7256 1704 1504 S 0.0 0.3 0:00.00 PassengerWatchd
29106 root 20 0 34652 2868 2376 S 0.0 0.6 0:00.17 PassengerHelper
29111 nobody 20 0 16992 3776 3032 S 0.0 0.7 0:00.00 PassengerLoggin
29121 www-data 20 0 225m 2628 840 S 0.0 0.5 0:00.00 apache2
29122 www-data 20 0 226m 3412 1556 S 0.0 0.7 0:00.00 apache2
29185 www-data 20 0 48496 39m 3852 S 0.0 7.9 0:02.97 ruby1.9.1
29204 www-data 20 0 68052 47m 3972 S 0.0 9.5 0:00.24 ruby1.9.1
29229 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/0:1
29321 depot 20 0 2720 1048 844 R 0.0 0.2 0:00.00 top
You can see that apache2 is running under "root" and "www-data" users, and that ruby is running under the "www-data" user. I've tried to change the ownership of the application directory to both "root" and "www-data" to no avail.
Comments on this question seem to suggest that deploying under "root" could be the cause of the problem. I'm assuming this means that I have to reinstall my ruby, apache, and passenger as a user other than root. This seems a bit extreme if I'm missing something else that's simpler.
Any ideas?
Upvotes: 0
Views: 1127
Reputation: 88
Ok, I can't claim to know linux user permissions, but what worked for me was reinstalling apache, passenger, ruby, rails, the app, and all dependencies as a user different from root. That seemed to fix the problem and the permission denied issue did not arise.
Update I should amend my solution by mentioning that I rebuilt the server and did a fresh install of all the above under the non-root user (so I didn't reinstall anything really, I recreated the whole stack from scratch).
Upvotes: 1
Reputation: 18924
Most likely, this is the effect of the automatic user switching feature. See http://www.modrails.com/documentation/Users%20guide%20Apache.html#user_switching for answers.
With "deploying under root" he did not mean that Passenger was installed as root. He meant that his application was owned by root. The documentation clearly explains what happens in that scenario: Passenger will refuse to run the app as root for security reasons, and will run the app as "PassengerDefaultUser" instead (which defaults to www-data on your machine).
Upvotes: 0