1

I run an Ubuntu 10.04 VPS which hosts 2 Thin processes running Ruby On Rails behind Nginx. I control the Thin processes via a /etc/init.d startup script as a regular user. In my Thin config file I specify:

user: www-data
group: www-data

And in my Thin logs, when I start the server, I see

>> Changing process privilege to www-data:www-data

Good sign. Problem is when I run ps -ef my Thin processes are running as the user I login as -- the user I run /etc/init.d/thin start as.

How can I get the Thin processes started as www-data:www-data when I run /etc/init.d/thin start as the user I log into the server as?

3 Answers 3

1

You can use sudo to run a command as any user:group with these options:

sudo -u www-data -g www-data /etc/init.d/thin start

-u sets the www-data user and -g sets the www-data group

2
  • This does seem to be the proper way to do it on Ubuntu Linux. It works for other daemons, but not the daemon that I originally posted about (thin). That's due to my RVM environment though..
    – Chris
    Mar 9, 2012 at 0:22
  • Ah, then you will want to use rvmsudo. If you are using rvm, NEVER use sudo. Just replace sudo with rvmsudo like so : rvmsudo -u www-data -g www-data /etc/init.d/thin start
    – Evan
    Mar 12, 2012 at 20:55
0

Have you tried to make an :

sudo -c www-data /etc/init.d/thin start

But if your Thin server is listening the port 80, you will need the root privileges.

0

If you're an ordinary user, you will not be able to switch the process ownership to some other user. You will need to run the /etc/init.d/thin script as root to do this.

So, you can do something like sudo /etc/init.d/thin start.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .