skip to Main Content

I am running my server on cPanel.

I have two users accounts:

/home/user1
/home/user2

From user2 I need to include /home/user1/public_html/config.php.

Is their anyway to apply this?

2

Answers


  1. It is fully possible to access php files located in other parts of the hard drive than where the site is run. However, this depends on two things. First of, the web user needs read permissions for the file, and you need to define the root folder where that php file is located as a accessable folder for the website.

    Setting file permissions for the file can be done with:

    chmod +R 775 /home/user1/public_html/config.php
    

    Defining the accessible folders for PHP depends on wether you are running Apache or Nginx.

    In Nginx for example:

    fastcgi_param PHP_ADMIN_VALUE "open_basedir =$document_root:/tmp:/usr/local/lib/php:/var/www/vhosts/yourdomain/httpdocs/:/home/user1/public_html“;

    In Apache:

    Apache readme

    Now you should be able to require the file like you normally would require any file:

    require('/home/user1/public_html/config.php');
    
    Login or Signup to reply.
  2. Why not just copy paste the /home/user1/public_html/config.php file to /home/user2/public_html/? If you don’t have permissions to access or do any operation on the file, then you are simply not authorized to attempt this.

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