Unable to start unless root
-
@BDHarrington7 said:
Can you run anything on nodejs as a non-root user? it might be how you installed node...
You'll have to give me a little more detail on how to test this or fix it, since I'm not 100% sure what you mean. I followed the Wiki's guide for Ubuntu Server I believe.
And can someone give me 3 reputation points please? I have a 10 minute limit between posts, and with my lack of knowledge, I won't be able to help people enough to actually earn them anytime soon haha.
-
have you experienced something like this: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
I wish I could remember the steps that caused the same issue where I couldn't run things on node unless I was root, I'm sure somewhere along the way I tried to fix it by changing permissions (which isn't something you should have to do unless you really know what you're doing). In the end I re-installed node and npm making sure I did not use sudo
-
@Ali said:
@julian @psychobunny help.
I was able to start it as non root by:
-
creating an iptables route from 80 to 3000
-
changing my nodebb config to start from 3000
-
reapplying permissions (some files had become root because it had been started as root)
-
is done by:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
apt-get install iptables-persistent
It'll ask you to save your current rules, say yes.
- edit your config.json
- chown, chmod
-
-
@BDHarrington7 said:
have you experienced something like this: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
I wish I could remember the steps that caused the same issue where I couldn't run things on node unless I was root, I'm sure somewhere along the way I tried to fix it by changing permissions (which isn't something you should have to do unless you really know what you're doing). In the end I re-installed node and npm making sure I did not use sudo
No I don't think so. I think the problem was that node wasn't being allowed to bind to port 80. I solved it by binding to 3000 and redirecting via iptables. I can now start it without root
-
As others have mentioned, you'll need to reset the owner of all files in the NodeBB folder.
Keep in mind if any files are owned by root, you need to be the root user to change ownership!
So that said:
$ su # to get to root $ cd /path/to/nodebb $ ./nodebb stop $ chown -R ali:ali . # change ownership to the "ali" user, for the current directory and all files/directories inside of it $ logout # To get back to the regular unprivileged user
Change
ali
as necessary.