Unable to start unless root
-
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.