Question

Why is wordpress site download file instead displaying site?

Posted March 2, 2020 247 views
WordPress

Hi,

Recently I upgraded to Ubuntu 16.04, i struggled to restart Apache2 but finally solved, but now website is downloading instead of display, even wp-admin page also downloading.

Regards,
Raja

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @rajviswas,

The download behavior happens when the server, WebService doesn’t know what to do with the file and just provides you with it to download. This usually happens when your PHP interpreter on your droplet is offline or if you have added some rule in your .htaccess file which changes the default behavior.

To test this, remove the .htaccess file of your website located in your DocumentRoot and see if the website is going to start loading, I bet it will start.

Then if you wish some help with debugging exactly which line causes this issue, post your .htaccess file here and we’ll be able to pinpoint it for you.

Regards,
KDSys

  • Hi,

    I have removed .htaccess file from the DocumentRoot but still problem is same.

    please find the .htaccess code below

    BEGIN WordPress

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUESTFILENAME} !-f
    RewriteCond %{REQUEST
    FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    END WordPress

    Regards,
    Raj

    • Hi @rajviswas,

      Do you have any other .htaccess files configured in the below directories or in the parent directories? You should be able to find out by executing the command

      find / -name .htaccess
      

      If you have, please check them as well.

      If you don’t it would mean you should turn your attention to your PHP and it’s configuration.

      • Thanks for your support but still same problem.

      • Hi,

        When i tried to open index.php then i got following message

        “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”

        Regards,
        Raja

        • Hi @rajviswas,

          Ah, I see, in that case you’ll need to install php-mysql. To do so, can you confirm a few things for me and I’ll provide you with the proper command :

          1. What OS are you using, is it Ubuntu, CentOS,Debian
          2. Which PHP version are you using? You can check it with the php -v command

Hi @rajviswas,

Thank you for the confirmation, in that case, please type in the following command to install the MySQL extension for php 7.4

sudo apt-get install php7.4-mysql

You might not have all the other extensions as well, so you’ll most probably need to install them the same way. Here is an example how to do it

sudo apt-get install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

Regards,
KDSys

  • Hi

    Thanks for your support, its working now but now i am getting following error

    “ There has been a critical error on your website”

    Regards,
    Raja

    • Hi @rajviswas,

      It seems you have some error in your code or there is a PHP extension missing. There are a few ways to check this however, I’ll recommend the following two.

      1. Enable PHP error logging using php.ini
      2. Enable the PHP errors via the index.php file.

      Let’s start with the first point.

      cd /path/to/you/website
      

      If you have an php.ini file there open it, if you don’t create one

      nano php.ini
      

      for creating a new php.ini type in

      touch php.ini && nano php.ini
      

      In there add the following lines

      ; log PHP errors to a file 
      log_errors = on
      error_reporting = 32767
      error_log = /path/to/you/website/error_log
      

      Please note to change the /path/to/you/website/errorlog with the actual one. Restart your apache and open your website. You should now have an errorlog file in your website’s directory stating what the error is. From there you can act on.

      The next solution is a bit easier. Open your index.php file and add to the top right under the <?php tag the following line

      ini_set('display_errors', 1);
      

      This should show the error you are experiencing directly in the browser. As soon as you’ve added the above line, save the file and open your website via the browser. You’ll see the error there.

      Once you have resolved the error, it’s important to remove the above line.

      Regards,
      KDSys

Submit an Answer