Unable to install Elgg (subdomain, mb_wrapper.php error, "Fatal error in exception handler")

Hi,

I really want to install Elgg and I've been trying to do so for days but no matter what I try, I always get those 2 errors:

Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php on line 239
Fatal error in exception handler. Check log for Exception #1467151571

More details now:

My hosting solution is Siteground, PHP version is 5.6.22.

I'm trying to install elgg on a subdomain, so in public_html/subdomain. I tried both to unzipp the elgg files in /subdomain/elgg and in /subdomain directly

I've tried to upload files, via ftp and cpanel, unzipped before or while on server, always the same result. I also get the same error when trying to install with Softaculous.

I'm trying to install the 2.1.2 version, but got the same error with 1.12.10.

It always go like that:

I upload everything on server, created a .htaccess or modified the existing on for it to feature

RewriteEngine on

I create the eggdata folder at the root. The engine and install folders have temporarily 777 access. I create a database with a user with all piviledge.

When I visit install.php, I already get a first line with "Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php on line 239"

Here is what mb_wrapper.php looks like (line 239 is in bold):

return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
    // if mb functions are available, set internal encoding to UTF8
    if (is_callable('mb_internal_encoding')) {
        mb_internal_encoding("UTF-8");
        if (version_compare('5.6.0', PHP_VERSION, '<')) {
            if (ini_get("mbstring.internal_encoding")) {
                ini_set("mbstring.internal_encoding", 'UTF-8');
            }
        }
    }
};

When I follow the installation instruction on screen, everything would be fine until I fill in database info, then, once I click to go to next step, I get the following error message:

"Fatal error in exception handler. Check log for Exception #1467151571"

Exception number is never the same.

Here is what I get in php_errorlog

Stack trace:
#0 /[path to subdomain folder]/vendor/symfony/http-foundation/Session/Session.php(71): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/ElggSession.php(57): Symfony\Component\HttpFoundation\Session\Session->start()
#2 /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/sessions.php(416): ElggSession->start()
#3 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/BootService.php(143): _elgg_session_boot()
#4 /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php(2043): Elgg\BootService->boot()
#5 [internal function]: Elgg\Application->{closure}('boot', 'system', NULL)
#6 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/EventsService.php(92): call_user_func_array(Object(Closure), Array)
#7 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(257): Elgg\EventsService->trigger('boot', 'system')
#8 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(423): Elgg\Application->bootCore()
#9 /[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(371): Elgg\Application->run()
#10 /[path to subdomain folder]/index.php(8): Elgg\Application::index()
#11 {main}
[28-Jun-2016 18:06:11 America/New_York] PHP WARNING: 2016-06-28 18:06:11 (EDT): "Cannot modify header information - headers already sent by (output started at /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php:239)" in file /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php (line 871)
[28-Jun-2016 18:06:11 America/New_York] PHP WARNING: 2016-06-28 18:06:11 (EDT): "Cannot modify header information - headers already sent by (output started at /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php:239)" in file /[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php (line 872)
[28-Jun-2016 18:06:11 America/New_York] Exception #1467151571 : fatal error in exception handler : Failed to start the session because headers have already been sent by "/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php" at line 239.

And that's it, basically I'm stuck there, no matter how I try to install Elgg.

I'm not a developer, I don't mind messing with code but here I'm short on clues as to what is wrong.

Can someone help me?

  • A php error shouldn't be sent to output, it's that output that breaks the session. The installer probably has code to turn off PHP's display_errors setting. Maybe you've configured PHP to force it on?

  • Thank you for the replies :)

    The thing is, as I said, I am not a developer and I'm using a Siteground server.

    So the mbstring installation page is basically Chinese for me x)

    When I look in cpanel, I only have a "PHP Variables Manager", when I click on it, I can select a folder and it prompts me to type a "variable" to add to "/home/[path to my subdomain folder]/php.ini".

    This php.ini file doesn't appear in my file manager nor on FTP client.

    I know how to access my server via SSH, is this where I should go to follow this tutorial for mbstring?

    The installer probably has code to turn off PHP's display_errors setting. Maybe you've configured PHP to force it on?

    Sure, how should I do that? x)

  • Maybe you want to ask the support of your webhoster about the mbstring php extension. The question is if the mbstring extension is already installed or not. In case it is the problem with installing Elgg might be for some other reason or the extension is not correctly working. If the mbstring extension is not installed, the support should be able to tell you how to install it (maybe they will even install it for you). The installation procedure depends to a certain extend on how the server is configured and administrated, so it's difficult to give any generic advice. If CPanel is available on your server the installation is most likely to be done via WHM (Easy Apache configuration). But in case you have only a shared server hosting plan or no access to WHM you might not be able to add any php extensions on your own anyway. In any case I would suggest to get in contact with the support to clarify the issue with them.

  • Hi, so update after the webhoster support answer: mbstring is actually already installed (libmbfl version 1.3.2.)

  • Problem is not mbstring. It's the display of errors. The installer should prevent that, but it's obviously not. Could be a bug on our end.

  • I upload everything on server, created a .htaccess or modified the existing on for it to feature

    RewriteEngine on

    I don't understand this part. Have you created a .htaccess file on your own or have you used the template htaccess.dist from the install/config subfolder to create the .htaccess file in the install folder? You need to use the template as it's not enough to just enable the rewrite engine as you also need the rewrite rules and the other stuff defined in the template. In Elgg 2.1 the template is in the vendor/elgg/elgg/install/config folder.

    You mentioned that you get a fatal erro with an exception number. The reason why the number is always different is because the number is not an error code but the timestamp when the error occurs. You should find an entry in the error log that contains the exception number and this error log entry might give more info about why the fatal error occurs. I don't know if you have an example log entry posted above that is related to a fatal error - at least I can't connect any of the log entries with a fatal error.

    What I wonder about is that you get the deprecation warning "ini_set(): Use of mbstring.internal_encoding is deprecated" because you say that php 5.6.22 is installed on the server whereas the code of Elgg does only use it if the php version is < 5.6.0. I don't know if the reason might be connected with the above mentioned htaccess file issue or if the correct php version might not be recognised for some other reason by Elgg.

    Are you really trying to install Elgg in a subdomain, i.e. accessing it then with url subdomain.maindomain.url or are you just installing it into a subdirectory (access with url maindomain.url/subdomain)? In the later case any .htaccess available in the document root folder (public_html) might result in issues with Elgg. Even if there's no .htaccess file in the document root folder you might need to adjust the rewrite base in Elgg's .htaccess file (the template contains some lines for that commented out by default). It's not necessary in all cases to change the rewrite base and it would only be necessary when installing Elgg into a subdirectory.

  • I don't understand this part. Have you created a .htaccess file on your own or have you used the template htaccess.dist from the install/config subfolder to create the .htaccess file in the install folder?

    Sorry, my explanation was confusing. I tried different installations along instruction I found online. I tried creating the htaccess myself, taking the one from htaccess.dist, or letting softaculous do its job. In all cases, RewriteEngine has been on.

    Currently, it's the softaculous install and the htaccess is in the subdomain folder and is the one from the template. So yes, it does contain other instructions.

    You should find an entry in the error log that contains the exception number and this error log entry might give more info about why the fatal error occurs.

    I put an example of what I find in the log, above. Tell me if it's the right log file, I can copy/paste it integrally if that helps but it's a bit long.

    Basically php_errorlog found in the subdomain folder starts with:

    text/x-generic php_errorlog
    ASCII English text, with very long lines
    
    [27-Jun-2016 16:56:07 America/New_York] PHP Deprecated:  ini_set(): Use of mbstring.internal_encoding is deprecated in /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php on line 239
    [27-Jun-2016 16:56:07 America/New_York] Exception #1467060967: exception 'RuntimeException' with message 'Failed to start the session because headers have already been sent by "/home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php" at line 239.' in /home/[path to subdomain folder]/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:140
    
    
    And then several variations of that:
    Stack trace:
    #0 /home/[path to subdomain folder]/vendor/symfony/http-foundation/Session/Session.php(71): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
    #1 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/ElggSession.php(57): Symfony\Component\HttpFoundation\Session\Session->start()
    #2 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/sessions.php(416): ElggSession->start()
    #3 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/BootService.php(143): _elgg_session_boot()
    #4 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php(2043): Elgg\BootService->boot()
    #5 [internal function]: Elgg\Application->{closure}('boot', 'system', NULL)
    #6 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/EventsService.php(92): call_user_func_array(Object(Closure), Array)
    #7 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(257): Elgg\EventsService->trigger('boot', 'system')
    #8 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(423): Elgg\Application->bootCore()
    #9 /home/[path to subdomain folder]/vendor/elgg/elgg/engine/classes/Elgg/Application.php(371): Elgg\Application->run()
    #10 /home/[path to subdomain folder]/index.php(8): Elgg\Application::index()
    #11 {main}
    [02-Jul-2016 11:14:08 America/New_York] PHP WARNING: 2016-07-02 11:14:08 (EDT): "Cannot modify header information - headers already sent by (output started at /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php:239)" in file /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php (line 871)
    [02-Jul-2016 11:14:08 America/New_York] PHP WARNING: 2016-07-02 11:14:08 (EDT): "Cannot modify header information - headers already sent by (output started at /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php:239)" in file /home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/elgglib.php (line 872)
    [02-Jul-2016 11:14:08 America/New_York] Exception #1467472448 : fatal error in exception handler : Failed to start the session because headers have already been sent by "/home/[path to subdomain folder]/vendor/elgg/elgg/engine/lib/mb_wrapper.php" at line 239.

    What I wonder about is that you get the deprecation warning "ini_set(): Use of mbstring.internal_encoding is deprecated" because you say that php 5.6.22 is installed on the server whereas the code of Elgg does only use it if the php version is < 5.6.0.

    That puzzles me too, and I get the error even when setting php on version 7 in the cpanel for this subdomain. In any case, the main domain is in 5.6.22 too.

    Are you really trying to install Elgg in a subdomain, i.e. accessing it then with url subdomain.maindomain.url or are you just installing it into a subdirectory (access with url maindomain.url/subdomain)?

    I'm afraid not to get the difference here. When I use softaculous, I select the subdomain I created to install it in.

    When I tried manually, I would unzip all the elgg files in the subdomain folder and create the elgg data folder at root. Then I would access the install.php with the url subdomain.domain.com/elgg/install.php

    Maybe I'm doing something wrong here?

    As for other .htaccess, there is one in root and one in public_html. I have Wordpress installed for my main domain and that was an autoinstall from my hosting provider.

    Thank you for you patience!!! :)

  • fatal error in exception handler : Failed to start the session because headers have already been sent

    Errors being output is the problem. Subdomains, .htaccess, are not the problem. Use phpinfo() to see if ini.display_errors is On. It needs to be Off

     

  • Amazing, that works!

    display_errors was On, I switched it off and now the url of my subdomain leads me to an installed Elgg :)

    Thank you very much :)