Link to home
Start Free TrialLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

How do I fix this error on my hosting server?

I have cakephp application which runs on LAMP environment. when i run the below error shows ,

PHP Notice:  Undefined index: HTTP_HOST in /var/www/test234/as/test.php on line 120
TERM environment variable not set.

The php code is,

if ($_SERVER['HTTP_HOST'] == 'xxc34-xx-xx-xx-cc.xxxx-1.amazonaws.com' && !in_array($_SERVER['REMOTE_ADDR'], array('238.12.43.1', '127.0.0.1','192.168.0.100'))) {
	$config['xx']['is_xxx_xx_enabled'] = false;
	
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America 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
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America 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
Avatar of Loganathan Natarajan

ASKER

Thanks ray, I will check it.
One more,  I forgot to tell you,

When I run through browser , there is no Notice...

but when I run through cron job , the above notice printed on the error.log?
I checked it and it is there at the bottom.

I think problem might be when I run through cron job , the above notice printed on the error.log?

If it is Notice, then it is OK.
SOLUTION
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
Its because cake PHP need certain PHP modules that need to be installed and enabled that are not present in your PHP enviornment such as MBstring, PDO etc Please check PHP Cake requirement page and install them.
Running my PHP program above on the command line gives me Environment variables but not $_SERVER web server variables which makes sense because it's not running thru the web server.  That's true on both Windows and Linux.
On my server, $_SERVER['HTTP_HOST'] === $_ENV['HTTP_HOST']
Neither one of the systems where I can run PHP at the command line, 1 Windows, 1 Linux, report the 'HTTP_HOST' in the environment info.