Learn about Centmin Mod LEMP Stack today
Register Now

Give PHP/Nginx access to /usr/local/nginx/conf/conf.d

Discussion in 'System Administration' started by Oxide, Nov 10, 2015.

Tags:
  1. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    3:25 PM
    Anyone here know how to do this?

    I'm working on a PHP Script that allow me to edit the configs straight from my web panel, however I can't seem to write or do anything there.


    When i execute:
    echo exec('ls /usr/local/nginx/conf/conf.d);

    only "virtual.conf" appears..
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,934
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    3:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    that is correct as that is output for

    Code:
    ls /usr/local/nginx/conf/conf.d
    although it should be at least
    Code:
    ls /usr/local/nginx/conf/conf.d
    demodomain.com.conf  ssl.conf  virtual.conf
     
  3. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    3:25 PM
    i have like 7 virtual hosts there, that is not appearing.. also trying this command as a example:

    echo exec('mv /home/nginx/domains/domain.net/public/test.conf /usr/local/nginx/conf/conf.d/test.conf');
     
  4. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    3:25 PM
    I could only assume it would have to do with permissions, i do have php suhoshin. I removed the .ini, but same issue occurs even when i did that.. so don't think that's the issue.
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,934
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    3:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Standard disclaimer...

    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    With that said, you're using wrong php function to do the job... hint exec vs shell_exec ;)

    With that said, I'd be careful writing a web control panel for such if you are not 100% sure what you're doing - but of course doing is part of learning.
     
  6. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    3:25 PM
    Yeah, none of those works. Shell_Exec doesn't even return anything when using ls or mv.

    I am doing this most likely to learn, just always though it would be cool to have such.. Trying to do it through PHP, using that, cron jobs and exec.. so far it's going horrible.
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,934
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    3:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  8. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    3:25 PM