require_once: failed to open stream: Permission denied(lampp)

Nikola Atanasov picture Nikola Atanasov · Nov 25, 2015 · Viewed 14.8k times · Source

I need help solving , what says to be a permission error in the htdocs folder, because i needed to alter them to even add folders in the first place.

This is my init.php file:

<?php
//Start Session
session_start();

//Include Configuration
require_once('config/config.php');

//Helper Function Files
require_once('helpers/system_helper.php');
require_once('helpers/format_helper.php');
require_once('helpers/db_helper.php');

//Autoload Classes
function __autoload($class_name){
require_once('libraries/'.$class_name . '.php');
}
?>

I try to include it via `

When i run my index.php file i get this error:

Warning: require_once(../../htdocs/PHP-Wizard/helpers/system_helper.php): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 9

Fatal error: require_once(): Failed opening required '../../htdocs/PHP-Wizard/helpers/system_helper.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 9

I tried going one folder up with ../ , but it doesn't work.

I looked around for a similar error to mine, but no luck. They all say No such file or directory in (path).

Could it be that it is the same error, or do i really need to change my permissions, if so, how can i do that?

Edit: When i use include_once('helpers/system_helper.php'); i get this error:

Warning: include_once(helpers/system_helper.php): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 9

Warning: include_once(): Failed opening 'helpers/system_helper.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 9

Warning: include_once(helpers/format_helper.php): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 10

Warning: include_once(): Failed opening 'helpers/format_helper.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 10

Warning: include_once(helpers/db_helper.php): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 11

Warning: include_once(): Failed opening 'helpers/db_helper.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/PHP-Wizard/core/init.php on line 11

Answer

Nikola Atanasov picture Nikola Atanasov · Nov 26, 2015

The problem was indeed the permissions, i'm guessing because i copied the folder.

I fixed it by chmod 777 on all the files in that folder, and now it works fine.

Thank you for your time attempting to help me.