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?
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
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:
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:
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.