4

I am working on a Laravel project where I have to generate a Nginx configuration file and store it on /etc/nginx/sites-available directory which only has write rights for the admin user, I have admin rights on the server, I just want to know if there is a way for doing this using the Process Component of Symfony stack.

Thanks a lot and bests ;)

yceruto
  • 9,230
  • 5
  • 38
  • 65
bretanac93
  • 627
  • 8
  • 20
  • yes. I've done it. just prefix the command with sudo, precisely as you would on the command line. but the user executing the script must have sudo, which if you're using Laravel, then it's probably the web server user account, which would be a dangerous idea to give that permission. – Jeff Puckett Jan 25 '17 at 03:23
  • I'd think about that, and this system is for internal usage on a university, indeed the access is only granted via IP address and credentials to the IP range on the department which is going to be used. – bretanac93 Jan 25 '17 at 14:33

1 Answers1

4

I would recommend using linux ACL, and give PHP process rights to write into the directory. That way you don't need sudo.

Also, you will need rights to reload the nginx process. And imho having a cronjob under root user, that reloads the configuration, if it changes and is valid, is a much better option.

You should read the relevant answers, that suggest not having rights to do a sudo call from PHP, for example

Just don't do it. Find a workaround that doesn't require sudo permissions.

Community
  • 1
  • 1
Filip Procházka
  • 808
  • 9
  • 31