PHP, Apache, Linux Problem

Jator

Golden Member
Jun 14, 2000
1,445
7
81
Trying to get a PHP webpage package up. I haven't dabbled with PHP in a long time, and back then it was in windows. This is in a Linux environment and I'm out of my league at this point. Wondering if anyone can give me some pointers:

Webpage http://127.0.0.1/stats/index.php is returning the following:
Warning: include_once(/opt/lampp/htdocs/stats/includes/settings.inc.php): failed to open stream: Permission denied in /opt/lampp/htdocs/stats/index.php on line 3

Warning
: include_once(): Failed opening '/opt/lampp/htdocs/stats/includes/settings.inc.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/stats/index.php on line 3

Warning
: include_once(/opt/lampp/htdocs/stats/includes/template.class.php): failed to open stream: Permission denied in /opt/lampp/htdocs/stats/index.php on line 4

Warning
: include_once(): Failed opening '/opt/lampp/htdocs/stats/includes/template.class.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/stats/index.php on line 4

Fatal error
: Uncaught Error: Class 'Template' not found in /opt/lampp/htdocs/stats/index.php:6 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/stats/index.php on line 6

And the index.php code has the following:
<?php define("_INSIDE",1);
require_once(realpath('./loader.inc.php'));
include_once(INC_PATH.'settings.inc.php');
include_once(INC_PATH.'template.class.php');

$tmpl = new Template('index.tpl');
$tmpl->setContent("HeaderHeight", $GLOBALS['_dnet']['web']['header_height']);
$tmpl->setContent("NavigationWidth", $GLOBALS['_dnet']['web']['navi_width']);

if (!empty($GLOBALS['_dnet']['web']['google_verify'])) {
$tmpl->addHeaderMeta('<meta name="verify-v1" content="'.$GLOBALS['_dnet']['web']['google_verify'].'" />'."\n");
}

// render without HTML-Envelope but get default Meta-data from template and set it as content replacement.
$tmpl->setContent("MetaHead", $tmpl->getHeader());

echo $tmpl->Render(false);

?>

I have LAMPP installed and the index file is installed under '/opt/lampp/htdocs/stats/' and the settings.inc.php is located at '/opt/lampp/htdocs/stats/includes/'.
I changed the permission for the '/opt/lampp/htdocs/stats/' to everyone via 'sudo chmod ugo+rwx /opt/lampp/htdocs/stats/'.

However I still get the original error when trying to access the webpage using http://127.0.0.1/stats/index.php.

Any assistance would be greatly appreciated.

Jay
 

Fallen Kell

Diamond Member
Oct 9, 1999
6,249
561
126
It has been a while since I setup a LAMP stack, but if I recall from back when I last did one, you need to modify the apache config file (httpd.conf) so that it knows what to do with PHP. You need to add the MIME types with "AddType" commands and also have it load the PHP module with a "LoadModule" command. Lookup a tutorial on a LAMP stack (short for Linux, Apache, MySQL, PHP). Otherwise, you get errors like the above such as permission denied or failed to execute.

If you have done all that (or your installation did it for you), I would also check the permissions on "/opt/lampp/htdocs/stats/loader.inc.php". I don't think you need or should have world writable on anything down here (in fact, you are possibly opening yourself up to remote attack if you do). I would also check the ownership of these files. I believe they should be owned by the same user as the process that runs your apache daemon (so "sudo chmod -R o-w /opt/lampp/htdocs").
 
Last edited: