skip to Main Content

I am building a dashboard to control couple different websites (each is in a cPanel separate account (including the Dashboard), but all hosted on the same server).

The dashboard will use php’s shell_exec for example to execute shell commands inside a website’s directory:

shell_exec('cd /home/website/www/app/ && php artisan config:cache')

Or simply read a file:

file_get_content('/home/website/www/app/license');

Of course, by default, accounts are not allowed to have access to each other like this! Is there a way to allow one account/user to access/modify other accounts?

2

Answers


  1. I would use SSH as this would not restrict you having to be on a single server and means that you do not have to breach the isolation of each cPanel account.

    https://www.php.net/manual/en/function.ssh2-connect.php

    I would suggest using this or alternatively this:

    How To Execute SSH Commands Via PHP

    Login or Signup to reply.
  2. Supposing Apache is running as www-data in the group www-data any file you need the server to have access to should be group-readable and have the group www-data.

    You can see what Apache is running as by running:

    ps aux | egrep '(apache|httpd)'
    

    Also remember, the whole path to the file needs to be readable by the group. In other words, given a file /path/to/some/file.txt the directories path, to, and some all need to be group readable and have the group www-data (or whatever Apache is running as).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search