moodle/admin "white screen of death" solutions

moodle/admin "white screen of death" solutions

by emerson loustau -
Number of replies: 15
Many people seem to be battling the "white screen of death" while trying to install/upgrade to version 1.9.7. The solutions to this issue seem to be scattered throughout a number of different threads, so I'm starting this not topic in the hopes that various solutions might be collected.

Here is how I solved it:

I was having trouble getting the installation to finish. Like many other people, it was hanging while creating tables. It sounds like this is usually the result of memory_limit problems. I created a php.ini file with the memory_limit set to 128MB, which allowed the install to finish, but then I got the infamous "white screen of death" at ...moodle/admin/index.php. After chasing my tail for some time, I solved this by placing the same php.ini file in the admin directory. This solution surprised me because I was under the impression that the php.ini in the top moodle directory would affect all the subdirectories. Apparently this is incorrect.

I asked my host (Namecheap) about this and they confirmed that the php.ini file only affects the directory in which it is placed. Perhaps this is a new feature of the latest versions of PHP. They were unable to suggest a way to control those settings globally. Fortunately, the .htaccess file (which is another way to control the same settings) is left blank on my server, so there is no conflict. But this might be something worth checking if my solution doesn't work for you.

Last but not least, I found that after getting the white screen of death, I could fix it by adding the php.ini file in /admin, but there were other problems later. So if you find that this works, start fresh and reinstall moodle with all the necessary php.ini files.

Best of luck.


Average of ratings: -
In reply to emerson loustau

Re: moodle/admin "white screen of death" solutions

by Jean Dowd -

Thank you for starting this thread. Beginners luck made me think installation was easy, but not so. I have tried to install a second instance of Module for another website which appears to be ok until I try to add a course or turn on editing. Either of these actions take me to a blank page.

Then, when I turn on debugging and try to add a course, it refers to specific line numbers in various files. This does not make sense. Why would the files in this install be any different than the original install which works just fine?

This is my latest error message when trying to add a course (there are no other courses):

Fatal error: Cannot redeclare make_log_url() (previously declared in C:\inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\course\lib.php:25) in C:\Inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\course\lib.php on line 54

For one thing - how do I tell where line 54 is? I did a search on Make_log_url and found two instances, but I couldn't tell what was wrong. Don't really know where to go from here. Paid support is way beyond what I can afford.

In reply to Jean Dowd

Re: moodle/admin "white screen of death" solutions

by Mauno Korpelainen -

Jean,

it would be nice to check your php info if you can attach it - I made a quick search to some similar posts and even if the reason did not look clear at least one post had php info attached and magic_quotes_gpc was OFF although it should be ON in php.ini

Most common reason for blank pages is lack of memory - and too low  
memory_limit in php.ini

In reply to Mauno Korpelainen

Re: moodle/admin "white screen of death" solutions

by Jean Dowd -

I hope copying it is all right.

<?PHP  // $Id: phpinfo.php,v 1.9 2007/04/30 17:08:36 skodak Exp $

       // phpinfo.php - shows phpinfo for the current server


    require_once("../config.php");

    require_once($CFG->libdir.'/adminlib.php');


    admin_externalpage_setup('phpinfo');


    admin_externalpage_print_header();


    echo '<div class="phpinfo">';


    ob_start();

    phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES);

    $html = ob_get_contents();

    ob_end_clean();


/// Delete styles from output

    $html = preg_replace('#(\n?<style[^>]*?>.*?</style[^>]*?>)|(\n?<style[^>]*?/>)#is', '', $html);

    $html = preg_replace('#(\n?<head[^>]*?>.*?</head[^>]*?>)|(\n?<head[^>]*?/>)#is', '', $html);

/// Delete DOCTYPE from output

    $html = preg_replace('/<!DOCTYPE html PUBLIC.*?>/is', '', $html);

/// Delete body and html tags

    $html = preg_replace('/<html.*?>.*?<body.*?>/is', '', $html);

    $html = preg_replace('/<\/body><\/html>/is', '', $html);

    echo $html;

    echo '</div>';


    admin_externalpage_print_footer();

?>

In reply to Jean Dowd

Re: moodle/admin "white screen of death" solutions

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In the file course/lib.php the function make_log_url() is declared once. The code looks a bit like this (in 1.9.7 anyway):


function make_log_url($module, $url) {
switch ($module) {
case 'course':
case 'file':
case 'login':
case 'lib':
case 'admin':
case 'calendar':
case 'mnet course':


If you have that's function line twice then the code is corrupted. This is especially likely if you have used FTP to upload your files (notorious for this sort of thing). In any case, I would download a clean copy of Moodle and start over to be safe.
In reply to emerson loustau

Re: moodle/admin "white screen of death" solutions

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In the nicest way possible - I'm not sure this is completely helpful. I try to encourage people not to guess the solution when they get the dreaded white screen. There are so many possible reasons.

The overarching reason is that PHP has encountered an error and given up. What we *should* be doing is encouraging people to go and find out what the error is. The best way to do this is by turning on Debugging which might get you the error printed to the screen (rather than a blank page) and/or check the PHP logs. On a default install PHP error messages normally go to the same place as Apache error messages. You *need* to know how to find and read those!

It's pretty much pointless just trying to guess the reason for a page that does not display.
In reply to Howard Miller

Re: moodle/admin "white screen of death" solutions

by Jean Dowd -

Thank you. You are right. If you don't know the reason something is happening, you aren't likely to find the right solution.

I did download a newest/best copy of course/lib.php, which solved the error I was working on, but now I have a new one.

Fatal error: Cannot redeclare update_category_button() (previously declared in C:\inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\lib\weblib.php:5186) in C:\inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\course\lib.php on line 1975

This is what I found in lib.php:

function update_category_button($categoryid = 0) {
    global $CFG, $USER;

    // Check permissions.
    $context = get_category_or_system_context($categoryid);
    if (!has_any_capability(array('moodle/category:manage', 'moodle/course:create'), $context)) {
        return '';
    }

    // Work out the appropriate action.
    if (!empty($USER->categoryediting)) {
        $label = get_string('turneditingoff');
        $edit = 'off';
    } else {
        $label = get_string('turneditingon');
        $edit = 'on';
    }

    // Generate the button HTML.
    $options = array('categoryedit' => $edit, 'sesskey' => sesskey());
    if ($categoryid) {
        $options['id'] = $categoryid;
        $page = 'category.php';
    } else {
        $page = 'index.php';
    }
    return print_single_button($CFG->wwwroot . '/course/' . $page, $options,
            $label, 'get', '', true);
}

Should I delete the entire function? or address it in "weblib.php"? Unfortunately, I am not intimate with PHP and don't want to make a mistake.

In reply to Jean Dowd

Re: moodle/admin "white screen of death" solutions

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Did you just download the single file or a complete new copy of Moodle (as I suggested)? If one file is corrupt it is very likely that others are? It's not worth the risk/headache.
In reply to Howard Miller

Re: moodle/admin "white screen of death" solutions

by Jean Dowd -
Sorry. This is a very recent download and I have another copy that is working just fine. I will download it again.
In reply to Howard Miller

Re: moodle/admin "white screen of death" solutions

by Jean Dowd -

I have downloaded a new copy of Moodle and installed it on an new virtual dedicated server. It is the only program that lives there. I still get blank pages when trying to enter a course or turn on editing.

Now my latest error message is:

******************************************************

Warning: require_once(C:\inetpub hosts\momentum-communications.com\httpdocs\VetsGroup/lib/setup.php) [function.require-once]: failed to open stream: Invalid argument in C:\Inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\config.php on line 29

Fatal error: require_once() [function.require]: Failed opening required 'C:\inetpub hosts\momentum-communications.com\httpdocs\VetsGroup/lib/setup.php' (include_path='.;./includes;./pear') in C:\Inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup\config.php on line 29

************************************************************

There is no line 29 in config.php.

In reply to Jean Dowd

Re: moodle/admin "white screen of death" solutions

by Mauno Korpelainen -

Small things can matter - something in that path is not correct...

Try to change

C:\inetpub hosts\momentum-communications.com\httpdocs\VetsGroup

to

C:\Inetpub\vhosts\momentum-communications.com\httpdocs\VetsGroup

in $CFG->dirroot of your config.php (see the warning and error message) - and check again also your $CFG->dataroot

Another thing that might have some influence is that according to Whois search your domain is hosted by GoDaddy and in the past many users of moodle have had problems with default settings of GoDaddy sites - yet many people have managed to install moodle successfully also to GoDaddy sites. So if similar errors continue popping up your current host might have even some extra info about some settings that you may need to check when you install moodle - in php.ini files or .htaccess files (for example memory limit), security settings (restrictions), permissions, changing the owner of some folders etc wink

In reply to emerson loustau

Re: moodle/admin "white screen of death" solutions

by Laren Droll -
Me too. I resorted to clean install of moodle 1.9.9+ to no avail.
I was attempting to migrate an existing site from an old server to a more upgraded server with recent versions of php, mysql, etc.

Like others, when I turn on debugging and go to a course I get white screen with following error:

Fatal error: Cannot redeclare make_log_url() (previously declared in /home/polilogue.net/web/public/course/lib.php:30) in ./lib.php on line 97

Same thing if I try edit mode from the home page.

Line 30 of the course/lib.php file is indeed a function for make_log_url() -- I don't understand what ./lib.php on line 97 refers to.

I was able to successfully migrate 4 other moodle sites to this same server with no issues. There is one other moodle with same problem that is v. 1.8.2+ that offers up a slightly different fatal error:

Fatal error: Cannot redeclare print_recent_selector_form() (previously declared in /home/wpialumni.net/web/public/course/lib.php:29) in ./lib.php on line 233

After combing through this thread I am not really finding a solution that works for me. Any suggestions? Happy to provide further info if you tell me.

I did experience white screens on courses on some of the other sites and found that my error was not making moodledata owned by apache webserver -- after correcting that all was well, but same fix on these other 2 sites did not fix it....?

I will keep searching.


Thanks!
In reply to Laren Droll

Re: moodle/admin "white screen of death" solutions

by Laren Droll -
Found the problem in my case and will try to explain... this is yet another cause/solution to the white screen of death problem when going to a course or entering edit mode:

I am on a solaris box similar to other flavors of unix.

My problem was in /etc/group

For my moodle directory I had my group assignment to 'staff'. What I had to do was include the special users for each site in the staff group. In my case each site had a user with same name as the site.

So I edited my /etc/group file's 'staff' group to include all of the site users. You can see who all the site users are in /etc/passwd. It might be better and more secure to have the group assigned to your moodle directory be only the site's own group (same as the site name in my case).

Another cause of the white screen when going to a course is if you have not assigned your moodledata directory so it is owned by the apache user such as 'nobody' or 'www' depending on your platform. So follow those installation instructions carefully!

Hope that helps someone else.
In reply to emerson loustau

Re: moodle/admin "white screen of death" solutions

by Matteo Menapace -

I was getting the following error when trying to create a course:

Fatal error: Cannot redeclare make_log_url() (previously declared in path_to_moodle/course/lib.php:30) in path_to_moodle/course/lib.php on line 97

I solved it by commenting out the line

require_once("lib.php");

in course/index.php, then course/edit.php, and finally course/view.php

I haven't explored the issue in depth, but I assume that somewhere else in the flow lib.php is already being included, so there is no need to require it again..

In reply to Matteo Menapace

Re: moodle/admin "white screen of death" solutions

by Jaswant Tak -

Hi,

Its too delayed reply, but today only I got the same message. I just noticed the error on screen (after enabling debugging mode)

Fatal error: Cannot redeclare make_log_url() (previously declared in C:\inetpub\vhosts\domain\httpdocs\course\lib.php:30) in C:\Inetpub\vhosts\domain\httpdocs\course\lib.php on line 97

If you see the inetpub (the I has a different case), so I corrected my config.php and changed the I to uppercase for $CFG->dirroot  and $CFG->dataroot

Mainly this error will occure if you have a Windows server.

I hope this will help others.

Cheers,

Jaswant