0

I'm trying to access my website but it's showing this thing instead of showing a normal home page. I didn't change anything in any files and I didn't even touch the database, yet it started showing this error suddenly:

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

if (version_compare(phpversion(), '5.2.0', '<')===true) {
    echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;">
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
<h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">
Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer.
<a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a>
 Magento using PHP-CGI as a work-around.</p></div>';
    exit;
}

/**
 * Error reporting
 */
error_reporting(E_ALL | E_STRICT);

/**
 * Compilation includes configuration file
 */
define('MAGENTO_ROOT', getcwd());

$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';

if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";
    }
    exit;
}

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

require_once $mageFilename;

#Varien_Profiler::enable();

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);

umask(0);

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

Anyone's having any idea? Please help, please.

Marius
  • 197,939
  • 53
  • 422
  • 830
Mohit Singh
  • 181
  • 2
  • 15
  • check var/log for errors. – Marius Nov 25 '14 at 11:56
  • @Marius- There is no such directory. I just checked it from cPanel. Only Var dircetory is there but no Log folder exists. How can this happen all of a sudden? – Mohit Singh Nov 25 '14 at 12:02
  • Which error is it showing? the above code you pasted is of index.php file of Magento – Dexter Nov 25 '14 at 12:25
  • @Dexter It is showing the same thing. Whenever I'm trying to access my website www.example.com it is showing this thing. Earlier it was working perfectly. – Mohit Singh Nov 25 '14 at 12:28
  • ini_set('display_errors', 1); uncomment this line in index.php of your magento to find the error in browser. – Manikandan Arunachalam Nov 25 '14 at 12:30
  • @Manik By Uncommenting you mean deleting that line, right? – Mohit Singh Nov 25 '14 at 12:32
  • I don't think this is a Magento error, it seems like a server side error. As the code is of index.php file and .php files are not rendered in browser. Contact your server admin for it – Dexter Nov 25 '14 at 12:40
  • just remove # if it exist before ini_set('display_errors', 1); this line. – Manikandan Arunachalam Nov 25 '14 at 12:46
  • I think its like opening your file like nor file:// in browser. – Manikandan Arunachalam Nov 25 '14 at 12:49
  • Go nothing after removing '#'...didn't work @Manik – Mohit Singh Nov 25 '14 at 12:53
  • It's opening like this in all browsers. Screenshot: link – Mohit Singh Nov 25 '14 at 12:57
  • Will reinstalling Magento and linking it to the present Database solve the problem? – Mohit Singh Nov 25 '14 at 13:02
  • 4
    This question appears to be off-topic because it is about how to configure apache – Richard Nov 25 '14 at 13:16
  • @Richard- Please don't mark it as off-topic because not everyone is a Magento genius like you. I don't have too much knowledge with coding and Magento that's why I thought if it is related to coding or some files of Magento. – Mohit Singh Nov 25 '14 at 13:20
  • @ADM- Like I said, not everyone is a coding genius. A lot of people have very little knowledge of PHP and that's why they use Open source software like Magento. Even you might not be an expert in every single field! It's a site where users can post their problems related to Magento and so I did. So please don't try to be over-smart thing that you're the only genius in the world! Even the people who tried to help me out have didn't had the correct idea about the problem and you can see that in above answers. – Mohit Singh Nov 25 '14 at 13:36
  • And why down thumbs for the post? – Mohit Singh Nov 25 '14 at 13:45

1 Answers1

2

You haven't configured apache properly to serve php files, so it's just throwing the source out on the wire.

Richard
  • 1,724
  • 10
  • 18
  • But it was working fine from more than a couple of weeks. How can it suddenly start giving this error? – Mohit Singh Nov 25 '14 at 13:22
  • Indeed, this or your libapache2-mod-php5 installation is flawed. Try do create a new php file with just phpinfo(); in it to check if PHP is working correctly.

    http://stackoverflow.com/questions/6245895/apache2-on-ubuntu-php-files-downloading?rq=1

    – Niels Nov 25 '14 at 13:33
  • The problem is solved! Thanks a ton fella :) – Mohit Singh Nov 25 '14 at 13:41