Solved

How do I fix this error on my hosting server?

Posted on 2013-06-26
11
419 Views
Last Modified: 2013-06-27
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

0
Comment
Question by:Loganathan Natarajan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 450 total points
ID: 39280254
This is a Notice, not an error.  You can suppress the notice messages.

Run this script, shown here in its entirety, to see the PHP variables available in your installation.  They are at the bottom of the listing.
<?php phpinfo();

Open in new window

0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 50 total points
ID: 39280266
I use this script to find out what server variables are available on a particular server.  Each different web server and even different version returns different server variables.  That server probably does not return 'HTTP_HOST'.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PHP Server Variables</title>
</head>
<body><h1>PHP Server Variables</h1>
<?php

foreach($_SERVER as $key => $value) {
    echo "<b>$key :</b> $value<br />\n";
}
?>
</body>
</html>

Open in new window

0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 39280275
Thanks ray, I will check it.
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 39280280
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?
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 39280287
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.
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 450 total points
ID: 39280305
Yes, sometimes the CRON jobs do not have the same PHP environment as the browser jobs.

Try running this as a CRON job and compare the output to the output from phpinfo() at the browser.  The output will be hard to read, but all the information will be there.  Make the obvious and necessary changes in the to-address

<?php 
ob_start();
phpinfo();
$msg = ob_get_clean();
mail('You@Your.org', 'CRON PHPINFO', $msg);

Open in new window

0
 
LVL 6

Expert Comment

by:Vijay Pratap Singh
ID: 39280330
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.
0
 
LVL 36

Author Closing Comment

by:Loganathan Natarajan
ID: 39280340
Thanks
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39280350
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.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39281028
On my server, $_SERVER['HTTP_HOST'] === $_ENV['HTTP_HOST']
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39282080
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question