Link to home
Start Free TrialLog in
Avatar of aarmstr2
aarmstr2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Internal Server Error 500 - PHP Production Server Only

I keep getting an Internal server error 500 when trying to run my PHP web app, it works fine on my dev server (Zend Server CE on Windows) but not on the production server (Apache on Ubuntu). Other projects run fine on the production server. I have a suspicion that it may be to do with the way I am including files. For example I have a small script below which handles a POST and is supposed to process accordingly but fails. I've checked the PHP error log, Apache error log with no results. I've tried to reduce the code to the point where I am just using the setters, and it still fails. I'm completey stumped! Please help!
## Includes
set_include_path($_SERVER['DOCUMENT_ROOT'] . "/onlinebookingv4/scripts/php");
include_once("/controllers/session.controller.php");

## POST/GET
if ($_SERVER['REQUEST_METHOD'] == "POST") {
	
	SessionController::set_username($_REQUEST['txt-username']);  
	SessionController::set_password($_REQUEST['txt-password']);  
		
	SessionController::validate_user();
	
}

Open in new window

Avatar of Aegil
Aegil
Flag of United Kingdom of Great Britain and Northern Ireland image

include_once("/controllers/session.controller.php");
set_include_path($_SERVER['DOCUMENT_ROOT'] . "/onlinebookingv4/scripts/php");


These path is looking at the root of the drive. Linux paths start at / where as windows is C:/


you need to use a relative path unless you are actually using a folder /onlinebookingv4 in the root of the drive
Avatar of aarmstr2

ASKER

Relative to the current document?

e.g.

include_once("/scripts/php/controllers/session.controller.php");
ASKER CERTIFIED SOLUTION
Avatar of Aegil
Aegil
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
include_once("controllers/session.controller.php");
set_include_path($_SERVER['DOCUMENT_ROOT'] . "onlinebookingv4/scripts/php");

This would be the correct settings on the basis that the controllers and onlinebookingv4 folders are both in the same directory as the file.php that this code is being ran from
It's not necessary a root of the drive.
DOCUMENT_ROOT is a variable defined in server configuration and in many live systems will return nothing at all.

Depends on your system you may want to get your location from:

$_SERVER['SCRIPT_NAME'] or $_SERVER['SCRIPT_FILENAME']

Ok,

attached is a pic of project structure, Aeqil I need to set the include path before incuding the file dont i? niepodoba, its a dedicated server, so I have complete control over it, so $_SERVER['DOCUMENT_ROOT']  is all good :) User generated image
So the intial request come from login.php which has

set_include_path($_SERVER['DOCUMENT_ROOT'] . "onlinebookingv4/scripts/php");
include_once("/bootstrp/all.inc.php");

Open in new window


all.inc.php has

## Includes
set_include_path($_SERVER['DOCUMENT_ROOT'] . "onlinebookingv4/scripts/php");
include_once('/models/server.php');
include_once('/controllers/company.controller.php');
include_once('/controllers/session.controller.php');

## Function Calls

// Set server defaults
Server::set_server("Europe/London");

// Get company details
CompanyController::getCompanyInfo();

// Get account details
SessionController::set_useraccount();

Open in new window


login.php then posts to login.inc.php which has

## Includes
set_include_path($_SERVER['DOCUMENT_ROOT'] . "/onlinebookingv4/scripts/php");
include_once("/controllers/session.controller.php");

## POST/GET
if ($_SERVER['REQUEST_METHOD'] == "POST") {
	
	SessionController::set_username($_REQUEST['txt-username']);  
	SessionController::set_password($_REQUEST['txt-password']);  
		
	SessionController::validate_user();
	
}

Open in new window

Sorted it,

instead of

set_include_path($_SERVER['DOCUMENT_ROOT'] . "/onlinebookingv4/scripts/php");
include_once('/bootstrp/all.inc.php');

Open in new window


it needed to be;-

set_include_path($_SERVER['DOCUMENT_ROOT'] . "/onlinebookingv4/scripts/php/");
include_once('bootstrp/all.inc.php');

Open in new window

Hey,
sorry I didnt get back to you, glad you got it sorted. Usually a good place to look is /var/log/apache2 or /var/log/httpd which can give some help in trouble shooting.

Glad you got it sorted though :)