Plesk: Access ouside public folder - php

I’m working on a web site that is hosted on a shared server that uses Plesk.
I want to put the database users config files outside of the public folder (httpdocs) and access them with include_once.
The problem is that the pages that use “include_once” don’t open in a browser, giving an error 500. Looking at the error log I found that the problem is caused by permission issues:
PHP Warning: require_once(PATH TO DB CONFIG): failed to open stream: Permission denied in PATH TO/httpdocs/index.php on line 2
PHP Fatal error: require_once(): Failed opening required 'PATH TO DB CONFIG' (include_path='.:') in PATH TO/httpdocs/index.php on line 2
The folders have a permission of 755, but I think the problem is happening because Plesk doesn’t allow access to folders outside the public folder.
Is there any way to allow access to those files?
Thanks!

You need to set open_basedir for the user, you can do this in Plesk under hosting settings, or via Apache config directly.

Related

opencart moving to domain

i moved my website from a subdomain which was made in opencart to a domain by moving the files and exporting and importing the database, and changing the config.php file but i got this errors:
Warning: require_once(/home/inti/public_html/system/startup.php): failed to open stream: Permission denied in /home/smartmobile/public_html/index.php on line 17
Fatal error: require_once(): Failed opening required '/home/inti/public_html/system/startup.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/smartmobile/public_html/index.php on line 17
This is most of times folder permission issue or the path set in config files is not valid.
You can get the path by
echo getcwd();
And use this path in config files.
Permissions can be checked and changed via many methods depending upon your access to server.

file_put_contents failed to open stream: Permission denied

Basic php and javascript website
No errors on Wamp
When I put the files on my Lamp server everything works except for this error I get on the top of the page
Warning: file_put_contents(donneesDonut.json): failed to open stream:
Permission denied in /var/www/html/bp/action/IndexAction.php on line
101
I looked around and most people suggest to change the permission of the file or the entire directory on apache.
chmod 777 did nothing for me.
I'm new to web servers so I probably have missed some apache configuration for permissions during the installation process
Here is a screenshot of the directory
Directory listing
I don't think there is a problem with the code since it works on my local Wamp server but here is the line of code that gives me the error.
file_put_contents($this->json, json_encode($this->donneesDonut));
If you need any other information like specific apache configuration please tell me where to get them.
Hope you can help
The problem was SELinux with was set to enforce by default on Centos

Symlinks w/ Xampp Error

I currently use Xampp on Windows for a local web development. In my web root, I have symlinks to each of my projects like so:
http://i.stack.imgur.com/GW9Yt.png
When the symlink is followed via explorer, it opens up the correct folder and location however, when loaded via Apache in my browser (localhost/project) I receive this error:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:/xampp/htdocs/project/index.php' (include_path='.;C:\xampp\php\PEAR') in Unknown on line 0
The file index.php is located inside the directory the symlink is directed at.
I believe this is a permission error however I cannot seem to discover what might be causing this as I have individually checked the permissions of each folder, file, etc and can't seem to find the issue.
Something I have noticed is that files located in folders located inside folders inside the symlink, e.g. link/style/file.txt will load however those in the root directory of the symlink do not.
Even I faced the same problem while installing magento on XAMPP & Windows-7. This clearly solved my problem.
Stop the apache and mysql
Exit XAMPP
Click on start button and search for XAMPP
Right click on "XAMPP Control Panel" and "Run as administrator"
Now you start apache and mysql
Your symlinks should start working now

Include file from seperate domain on server: Failed to open stream: Permission denied

I just upgraded Plesk to the latest version and it has caused many of my sites to go down.
The websites all rely on a file which is located on another domain on my server so they all host an index file which contains an include like this:
include('/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php');
I am getting the following error when viewing the website:
Warning: include(/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php): failed to open stream: Permission denied in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3 Warning: include(): Failed opening '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php' for inclusion (include_path='.:') in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3
So there is obviously a permissions problem of some sort but I have no idea where to start.
In SSH I have tried changing the ownership of the folder '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/' with no luck. I have noticed that all my domains have different ownership usernames now - would this affect it? EG.mydomain.com has the user of mydomain, cooldomain.com has the user of cooldomain - would this be why they can't access each others files?
Please help as I have 15+ websites down :-(
Fixed this - Plesk decided to change the permissions so simply changing the domain name folder to 755 solved this

Permission denied when opening localhost

I had recently installed Apache, PHP and MySQL in Ubuntu. And copied the files I created to the var/www directory. But when I open http://localhost it is showing
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/var/www/index.php'
(include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
How can I run my project normally? It was working fine in windows.
According to this article, you need to give read/execute permissions to Owner, Group, and Everyone.
Set permissions on the problem file to 777. Note, you should avoid doing this on a server that's accessible from the internet.
http://webomania.wordpress.com/2007/03/12/permission-denied-in-unknown-on-line-0/
To fix this problem, look at the line in your ErrorLog, to find out which folder it is trying to access.
If a block already exists for that folder, make sure it is set to allow access as necessary. If not, add a block to your Apache configuration file, allowing access as required. See the example below for folder /usr/local/awstats/htdocs.
Order allow,deny
Allow from all
for a complete reference, check the apache wiki

Categories