Monday 10 April 2017

Grant the server the permission of creating a folder

I have a Ubuntu Server on DigitalOcean, which hosts some websites. I just built a mean.js stack app on my mac, and I plan to deploy it to production, thus to this existing server (though I don't know if I need to create another droplet like here).

I followed this link to install node.js and mongodb, etc. Then, rather than cloning the sample app of mean.js, I cloned my own app from the github:

sudo git clone https://github.com/softtimur/app.git /opt/app
cd /opt/app
sudo mkdir public/tmp/
sudo npm install
npm start

Then, in a browser, I entered https://xxx.xx.xx.xx:3000/#/new. On the server side, I got an error:

router.post /mkdir
{ Error: EACCES: permission denied, mkdir 'public/tmp/sAlTI6NDo5NQcO-lAAAA/'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: 'public/tmp/sAlTI6NDo5NQcO-lAAAA/' }

This is because in the server, it tries to create a folder in public/tmp/ by fs.mkdir(...) where fs = require('fs').

So does anyone know to how to give the server this permission?

PS: I also tried to run

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

but it did not help.



via SoftTimur

No comments:

Post a Comment