If you are using Drupal on share hosting, you have probably experienced a white screen. You see nothing on the screen. You had might as well be skiing in a blizzard. This generally happens when PHP runs out of memory and is one of the biggest problems with shared hosting.

But do not panic. It is fairly easy to fix in most cases.

Modules

The dreaded white screen seems to happen on the module page in the administration section more often then other pages. The reason is that when accessing this page, Drupal loads all of the modules, whether they are active or not. This puts a massive strain on the poor shared hosting server. The obvious answer here is to remove any modules that you do not use. It is not good enough to simply deactivate them. You must delete them off the server. You can do this by using your ftp programme, navigate to the module folder, select the modules you are not using and hit delete. Make sure you have de-activated them in the module screen first.

Increasing PHP memory

Increasing available memory is the second stage in preventing the white screen. Normally this is done in the php.ini file, but on most shared hosting packages, you do not have access to php.ini. Fortunately you can, in most cases, increase the memory in the .htaccess file. The .htaccess is installed automatically when you first install Drupal, so you do not need to create a new one.

Add the following line to your .htaccess file:

php_value memory_limit 20M

Add it three times, under # PHP 4, Apache 1, # PHP 4, Apache 2 and # PHP 5, Apache 1 and 2 if you do not know which version of PHP and Apache you are running. So the .htaccess file will look like this:

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
  php_value memory_limit 20M
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
  php_value memory_limit 20M
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
  php_value memory_limit 20M
</IfModule>


</IfModule>

You can get away with a limit of 12M most of the time, but if you have a site with a lot of modules installed, then 20M is recommended.

Error reporting

If you are still getting the white screen after completing the first two steps, then it could be because your error reporting is turned off and the issue is not a memory problem.

In order to see errors on the screen, add the following code at the top of the index.php file (in the root directory):

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

/**
* @file
*/

Make sure you add the code inside the <?php tags

Can not access the website

Sometimes your site will crash completely before you get a chance to complete the above stages. You might be presented with a screen full of errors on every page of the site.

This is normally caused by too many modules installed for the available memory. You need to temporarily deactivate the last module (s) that you installed before the problem occurred.

But how do you do this if you can not access the site you ask?! Easy!

Go to phpMyadmin and find the system table. Then find the last module(s) that you installed and click edit. Change the status to 0. That will deactivate the module and give you a chance to fix the memory problems.