Problem:
I'm trying to open headerr.php via require_once on a XAMPP localhost server. I'm calling this function through index.php but I keep on receiving the following error message
Errors:
Warning: require_once(/Applications/XAMPP/xamppfiles/htdocs/Baseline/headerr.php): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/Baseline/index.php on line 2
Fatal error: require_once(): Failed opening required 'headerr.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/Baseline/index.php on line 2
Attempted Solutions:
-I've tried setting the permissions to Read & Write for everyone on the (/Applications/XAMPP) Folder but that hasn't fixed the permissions issue.
-I've also tried using require_once dirname(FILE) . '/headerr.php'; but that didn't work either..
In Conclusion:
I suspect that I may have to edit the php.ini file but I have no clue what to do..
I appreciate any advice or insight, thanks!
Try this command:
chmod -R 775 yourWebFolder
Related
Consider:
I have a file called test.php. Here is the contents:
<?php
echo "Hello World";
?>
I have ensured my doc root has permissions as per Correct owner/group/permissions for Apache 2 site files/folders under Mac OS X?
When I try to run the above script on my MAMP stack I get this warning:
Warning: Unknown: Failed to open stream: Operation not permitted in Unknown on line 0
Could someone shed some light on my error here please?
Edit: I have tried the ideas below - thank you to #Shozabjaveed - but these have not worked.
Make Sure that the Apache service has read permissions.
chmod 755 test.php
or ran the recursive command to ensure that the Apache service has read permissions.if using MAC
sudo chmod -R 755 ~/foldername
Somebody send me a site to work on so I setup my MAMP webserver, extracted the drupal8 files into the htdocs folder, I setup the database in phpMyAdmin and run the MAMP servers.
When I try to reach localhost I get a HTTP ERROR 500, of-course I check the logs for errors and find this:
[02-Aug-2017 16:14:24 UTC] PHP Warning: require(C:\MAMP\htdocs/../vendor/autoload.php):
failed to open stream: No such file or directory in C:\MAMP\htdocs\autoload.php on line 17
[02-Aug-2017 16:14:24 UTC] PHP Fatal error: require(): Failed opening required 'C:\MAMP\htdocs/../vendor/autoload.php' (include_path='.;C:\php\pear') in C:\MAMP\htdocs\autoload.php on line 17
I thought this had something to do with composer so I reinstalled it and ran cmd
composer install
In installed some files + generated some autoload files which is what i thought was going to solve my problem, but i still get the same error and i feel like im missing something really obvious. Ive been stuck for so long on a small problem.
Hope someone has an answer for me!
SOLVED
It was a pathing error in the autoload.php file
return require DIR . '../vendor/autoload.php';
changed to:
return require DIR . '/vendor/autoload.php';
I do Dropbox-API
it needs to access the Dropbox-SDK..
Here is the error shown in browser.
Warning: require_once(dropbox-sdk/Dropbox/autoload.php): failed to open stream: Permission denied in /home/albert/public_html/test/search.php on line 11
Fatal error: require_once(): Failed opening required 'dropbox-sdk/Dropbox/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/albert/public_html/test/search.php on line 11
I have been researching about it and try to chmod all the files, also chown all.. but it still show the same error..
Can anyone help? Thx
Check your include path for it may be that you have to change it or include/require the autoload file using its full path.
Is dropbox-sdk/Dropbox/autoload.php under . or /usr/share/php or /usr/share/pear, if not, that is your problem - your include path is incorrect, or your installation path for Dropbox was placed in the wrong place
i am getting the following errors when i am trying to include a file.. i have tried chmod 777 for the directory..checked twice ,the path is correct ..but still the errors persist
the errors are:
Warning: require(../lib/GoogleChart.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/project1/admin/googlechart/examples/line_chart_full.php on line 3
Fatal error: require(): Failed opening required '../lib/GoogleChart.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/project1/admin/googlechart/examples/line_chart_full.php on line 3
What might be wrong is it with the permission cause i have done chmod -R 777 on the directory
You coul try with absolute path starting from documen root (if you have no needs to run the script in command line because $_SERVER array is not provided if the script is launched by a shell)
require($_SERVER['DOCUMENT_ROOT'] . "/lib/GoogleChart.php";
Giving that the lib directory is in the root (www.example.com/lib/GoogleChart.php).
I would suggest require_once instead
I am on Ubuntu 11.10 and installed apache server to host my local website before i host it from a company.
My website root location is "/home/a1a4a/www/"
I have a php file in /home/a1a4a/www/account/account_info.php"
That i want him to include a file in "/home/a1a4a/www/include/fg_membersite.php"
It's what i did from account_info.php
require_once('./include/fg_membersite.php');
And i got this error
Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/a1a4a/www/account/account_info.php on line 10 Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a1a4a/www/account/account_info.php on line 10
So what have i done wrong ? How to fix .
I have full permissions ( sudo chown -R www-data ).
Thanks and Happy Holidays :)
Always use the absolute path or you will face errors depending on the calling script.
require_once('./include/fg_membersite.php');
should actually be
require_once(dirname(dirname(__FILE__)).'/include/fg_membersite.php');