Fixing Drupal when your website crashes

On September 18, 2013, in Clipboard, Drupal, IT, by Billiet Consulting, Inc
  1. Rebuild your registry
  2. Clear cache
  3. Disable modules in MySql
  4. Run update.php
  5. Clear cache programatically
  6. Register globals (use php.ini file)
  7. Increase memory size (use  setting.php file)

 

Rebuild your registry:  (from https://drupal.org/project/registry_rebuild)

How To Use Registry Rebuild With Drush

This is the preferred technique, and it should work with multisite installs.

  1. You can just drush dl registry_rebuild and drush will download it into your .drush folder. (Alternately, you can obtain the package another way and copy the folder into .drush yourself.)
  2. Make a backup of your database.
  3. On a multisite install, cd into the site you’re rebuilding, as in cd sites/mymultisite
  4. drush rr

How To Use Registry Rebuild Without Drush

This isn’t a module, but it’s just packaged as a module download to make it so
it’s easy to find and people can download it as a package.

  1. Make a backup of your database using any technique you like. drush sql-dump >dump.sqlor mysqldump -uuser -ppassword dbname >dump.sql or use phpMyAdmin or whatever. I know of no way that this procedure can harm your database, but on the other hand if it doesn’t work, you can get me the database and I can improve the module to deal with your situation.
  2. Make a directory for the php file, probably sites/all/modules/registry_rebuild (or for a multisite, sites/mymultisite/modules/registry_rebuild.
  3. *If* your modules are not in sites/all/modules, you will probably have to edit registry_rebuild.php to set DRUPAL_ROOT to what it should be.
  4. Copy the registry_rebuild.php from the package into that directory.
  5. You don’t need to enable it. If you were able to enable it it means you didn’t actually need it.
  6. Either run it from the command line:
       cd sites/all/modules/registry_rebuild
    php registry_rebuild.php

    OR
    point your web browser to

    http://example.com/sites/all/modules/registry_rebuild/registry_rebuild.php

    Changing “example.com” to your own site’s base URL of course.

  7. You should see something like this:
    DRUPAL_ROOT is /home/rfay/workspace/commerce.
    There were 631 files in the registry before and 508 files now.
    If you don't see any crazy fatal errors, your registry has been rebuilt. You will probably want to flush your caches now.
  8. Hopefully you’ll now be able to go about your affairs in peace, updating, clearing cache, etc.

This package comes with no guarantee explicit or implicit.

 

Diable module in MySQL from

 https://drupal.org/node/157632

MySQL Command Line

Step 1: To disable a module via phpMyAdmin you must login to phpMyAdmin. Then you must locate the database where Drupal is installed. Once you have done so look for the “system” table. Click and open it. Click to browse the table. Find the record for the module that is causing the problems and select the edit function. Set the status to “0″ and save.

Step 2:  To update the cache using the mysql command line, type:

DELETE FROM cache_bootstrap WHERE cid='system_list'

 

Run the update.php  at www.yourwebsite.com/update.php

Access denied. You are not authorized to access this page. Log in using either an account with the administer software updates permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to edit settings.php to bypass this access check. To do this:

  1. With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to sites/your_site_name if such directory exists, or else to sites/default which applies otherwise.
  2. There is a line inside your settings.php file that says $update_free_access = FALSE;. Change it to

    $update_free_access = TRUE;

    .

  3. As soon as the update.php script is done, you must change the settings.php file back to its original form with $update_free_access = FALSE;.
  4. To avoid having this problem in the future, remember to log in to your website using either an account with the administer software updates permission or the site maintenance account (the account you created during installation) before you backup your database at the beginning of the update process.

 

Clear cache programatically:

 http://billietconsulting.com/2013/06/clear-drupals-cache/

Here is the code to clear Drupal’s cache.  Place the file in the right underneath the root of your website and name it clear.php for example, so the path will be example.com/clear.php

<?php
// define static var
define(‘DRUPAL_ROOT’, getcwd());
// include bootstrap
include_once(‘./includes/bootstrap.inc’);
// initialize stuff
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// clear cache
drupal_flush_all_caches();
?>

Remove the file once you’re done.

more info here: https://drupal.org/node/42055

 

Register Globals:

create a php.ini  file and place in root folder of your website (also works for sub-websites) like dev.mywebsite.com then place it in the root/subroot (mywebsite/dev folder)

register_globals = off;

Fatal error -> out of memory:

  • Drupal 7: If you need more than 128M, then add the line
    ini_set(‘memory_limit’, ’512M’);
    to your [Drupal 7 root]/sites/default/settings.php file.I have yet to need this much memory, but I did achieve
    a memory increase to 512M using this slightly more complicated
    process that involved temporarily changing the permission level
    for that file at my online webhost.The following applies to an online installation,
    but if your installation is “local” on your computer
    just follow the instructions below and ignore the extra steps
    required for the online installation.I have not tried the Local approach, but I assume
    it would work equally well.

    1. Download a copy of the file “settings.php”
      (if you do not already have a copy on your computer)
      that is located at
      [Drupal 7 root]/sites/default/settings.php
    2. Open the file with your favorite text editor
      (Eg. WordPad, NotePad, etc.).
    3. Add a line of code on a line of its own
      at the bottom of that file…

      ini_set('memory_limit', '512M');

    4. ‘Save’ the file.
    5. Change the file permission level of the settings.php
      file on your server from “0444″ to “0777″;
      otherwise you will not be able to over-write it with
      the newly saved file you have on your computer.In the case of my Drupal 7 installation being on my webhost…

      1. I go to my online webhost account’s control panel (CPanel)
      2. Click on the link for the ‘File Manager’.
      3. Navigate to the file [Drupal 7 root]/sites/default/settings.php
      4. Change the file permission from 0444 to 0777.This might take some poking around for you to figure
        how to do it, but it should be easy enough once you
        find the right thing to click.In my case, double-clicking on the “0444″ allowed me
        to edit the number right there, although
        you should also be able to change the permission number
        by highlighting the file, and clicking a button or link
        called “Change Permissions”; or similar.
    6. Replace the Drupal 7 settings.php file with the one you modified
      by an upload of the file settings.php that you have on your computer
      to the proper location on your webhost server
      using either your control panel (CPanel)
      or your FTP program.
    7. Change the permission level for the file back to 0444

    Additional notes:

      • You can see the amount of memory you are being allowed by going to
        ‘Reports’ > ‘Status report’; and scrolling down to “PHP memory limit”.It should read ’512M’ if you have followed the above steps.

     

      • Replacing the modified settings.php file on my website
        with a copy of the original settings.php file
        returned the “PHP memory limit” to what it had been before.

     

    • I have read that “Restarting the server” is required for local installations
      although I have no experience with that.

    All the best.

  • source: https://drupal.org/node/76156#comment-4583384

 

php.ini

This is the recommended approach if you have access to the server’s php.ini. This will not be possible in some shared hosting environments, though your host may be able to adjust it for you. Note that this change will affect all websites and PHP scripts on the server.

  1. Locate the php.ini file used by your web server. You can click the “more information” link on Drupal’s status page’s PHP section. which shows the phpinfo() page. Locate theConfiguration File (php.ini) Path row on that page. During installation Drupal checks the PHP Memory Limit, and if it is less than 32M (16MB for Drupal 6), an error message also provides the path to the php.ini file.
  2. Edit the memory_limit parameter in the php.ini file (usually in a section called Resource Limits)
    memory_limit = 64M  ; Maximum amount of memory a script may consume (64MB)
    If there is no section already for this, place the above line at the end of the file.
  3. Restart Apache.

php.ini in the Drupal root folder

Add the following line to a php.ini file in your Drupal root folder:
memory_limit = 64M
This will only work if PHP is running as CGI/FastCGI.

 

Latest php.ini file in my sub-website’s root folder looked like this:

extension=pdo.so
extension=pdo_mysql.so

register_globals = off;

and the settings’php had 528M memory

 

http://thedesignspace.net/MT2archives/000849.html#.UjpOI8bry2U

 

Comments are closed.