1

I have an EC2 instance running RHEL7 with the standard LAMP stack. Everything was working fine when all of a sudden Magento stopped responding. Requests for index.php hang and then time out. Apache still serves other things in the /var/www/html directory so I tried requesting index.php.sample and it gave me this error message:

"Whoops, it looks like you have an invalid PHP version.  Magento supports PHP 5.2.0 or newer."  

Why would I get that error message from index.php.sample but not from index.php?

Restarted the instance and the error persists.

The PHP Version installed is 5.4.16. Curl, mcrypt, and mysql-php are all installed and functioning. Everything listed on phpinfo.php seems like it is the way it should be.

In /app, .htaccess contains only:

Order deny, allow
Deny from all

Relevant parts of httpd.config are as follows:

User apache
Group www-users

<Directory "/var/www/html">
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>

SELinux is disabled and the output of ls -l on /var/www/html looks like this:

-rwxr-xr-x.  1 apache www-users   2834 Dec 10 19:56 api.php
drwxr-sr-x.  6 apache www-users     84 Dec 16 15:22 app
-rwxr-xr-x.  1 apache www-users   2831 Dec 10 19:56 cron.php
-rwxr-xr-x.  1 apache www-users    717 Dec 10 19:56 cron.sh
drwxr-sr-x.  7 apache www-users   4096 Dec 10 19:56 downloader
drwxr-sr-x.  3 apache www-users   4096 Dec 10 19:56 errors
-rwxr-xr-x.  1 apache www-users   1150 Dec 10 19:56 favicon.ico
-rwxr-xr-x.  1 apache www-users   5979 Dec 10 19:56 get.php
drwxr-sr-x.  2 apache www-users     39 Dec 10 19:56 includes
-rwxr-xr-x.  1 apache www-users   2642 Dec 10 19:56 index.php
-rwxr-xr-x.  1 apache www-users   2366 Dec 10 19:56 index.php.sample
-rwxr-xr-x.  1 apache www-users   6441 Dec 10 19:56 install.php
drwxr-sr-x. 12 apache www-users   4096 Dec 10 19:56 js
drwxr-sr-x. 14 apache www-users   4096 Dec 10 19:56 lib
-rwxr-xr-x.  1 apache www-users  10421 Dec 10 19:56 LICENSE_AFL.txt
-rwxr-xr-x.  1 apache www-users  10679 Dec 10 19:56 LICENSE.html
-rwxr-xr-x.  1 apache www-users  10410 Dec 10 19:56 LICENSE.txt
-rwxr-xr-x.  1 apache www-users   1319 Dec 10 19:56 mage
drwxr-sr-x.  6 apache www-users     83 Dec 10 19:56 media
-rwxr-xr-x.  1 apache www-users     20 Dec 10 15:20 phpinfo.php
-rwxr-xr-x.  1 apache www-users    886 Dec 10 19:56 php.ini.sample
drwxr-sr-x.  2 apache www-users     67 Dec 10 19:56 pkginfo
-rwxr-xr-x.  1 apache www-users 585086 Dec 10 19:56 RELEASE_NOTES.txt
drwxr-sr-x.  2 apache www-users     76 Dec 10 19:56 shell
drwsr-sr-x.  5 apache www-users     51 Dec 10 19:56 skin
drwxr-sr-x.  7 apache www-users   4096 Dec 16 15:07 var

Any ideas?

EDIT:

Just thought I would try this out. index.php.sample uses this if statement to check if your php install is new enough:
if (version_compare(phpversion(), '5.2.0', '<')===true)

So I made a php file that reads as follows:

<?php if (version_compare(phpversion(), '5.2.0', '<')===true) { echo 'phpversion returns: ' . phpversion();} else { echo 'This works';} ?> And sure enough it prints This works. Why would act differently in the two PHP files with identical if statements?

2
  • You got your PHP version using command line php -v or phpinfo()? I'm asking it, because I've seen installations where there is one version for CLI and another version for mod/cgi. – Pronto Dec 16 '14 at 21:52
  • I got it from from phpinfo(), but the command line gives me the same info: PHP 5.4.16 (cli) (built: Oct 23 2014 07:19:40) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies – Jim Dec 16 '14 at 22:14
1

Try these steps to find the exact error:

Edit the index.php file and uncomment (by removing leading hash character) the following code:

ini_set('display_errors', 1);

or insert this line somewhere at the top of the file.

Try to increase PHP memory limit up to 256Mb or more by adding the following line into index.php right after ini_set('display_errors',1):

1. ini_set('display_errors', 1);
2. ini_set('memory_limit', '256M');

I think this problem is might with lack of memory limit. To increase the memory limit, add the following line to index.php at last.

Save the modified index.php file.

Refresh Magento Store page in your browser, you should see the PHP error message now.

NOTE: After the issue got resolved, uncomment the line ini_set('display_errors', 1);

1
  • why he needs to enable display_errors???? find your error log ant tail -f , for Gods sake... – user2857 Dec 17 '14 at 19:24
1

Found the problem. Restarting the EC2 instance changed the public ip (which I knew), but Magento's base_url was set to the previous public ip. Therefore index.php was trying to serve a bunch of stuff from a defunct ip and the page hanged and eventually timed out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.