2

I'm running into a 500 Internal Server Error when trying to install craft (on openshift).

Environment:

The installation starts ok but crashes shortly after:

URL: http://my-domain.com/admin/install

enter image description here Console output:

POST http://my-domain.com/index.php/admin/actions/install/install 500 (Internal Server Error)
send @ jquery-2.2.1.min.js?d=1473694215:4
ajax @ jquery-2.2.1.min.js?d=1473694215:4
postActionRequest @ craft.js:388
(anonymous function) @ install.js:84
f @ jquery-2.2.1.min.js?d=1473694215:2
(anonymous function) @ install.js:152
f @ jquery-2.2.1.min.js?d=1473694215:2
l @ velocity.min.js?d=1473694215:3
k @ velocity.min.js?d=1473694215:3

nginx default configuration:

server {
    root              /var/lib/openshift/xxxxxxx/app-root/runtime/repo//public_html;
    listen            127.0.0.1:8080;
    server_name       mydomain.com;
    index             index.php index.html index.htm ;

    set_real_ip_from  127.0.0.1;
    real_ip_header    X-Forwarded-For;

    # avoid caching by proxies
    add_header        Cache-Control private;

    error_page 404 /index.php;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass   unix:/var/lib/openshift/xxxxxxx/nginx-php7//run/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
        include        openshift_params;

        # uncomment to export all environment variables to fastcgi
        #include        /var/lib/openshift/xxxxxxx/app-root/runtime/repo//config/nginx.d/export_env;
    }

    location ~ ^(.*)$ {
        try_files $uri $uri/ /index.php?p=$uri&$args;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|ttf|ttc|otf|eot|woff)$ {
        try_files $uri /index.php?$query_string;
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    location ~* \.(?:css|js)$ {
        try_files $uri /index.php?$query_string;
        expires 1y;
        add_header Cache-Control "public";
    }

    location = /robots.txt  { access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
    location ~ /\. { access_log off; log_not_found off; deny all; }

    location ~* (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
        deny all;
        access_log off;
        log_not_found off;
    }
}

craft.log:

2016/09/12 15:30:56 [warning] [application] Skipping record /var/lib/openshift/xxxxxxx/app-root/runtime/repo/craft/app/records/BaseRecord.php because it’s abstract or an interface.

The only PHP error I'm seeing (repeated about 6 times during the install):

[12-Sep-2016 16:44:29 UTC] PHP Warning:  strpos(): Empty needle in /var/lib/openshift/xxxxxxx/app-root/runtime/repo/craft/app/bootstrap.php on line 126

I've checked the permissions on all required write-enabled folders are ok, but still can't figure out what's preventing the install.

Can anyone help me identify whats causing this issue?

EDIT:

my craft/config/general.php file:

<?php

// Get environment
require('_env.php');

/**
 * General Configuration
 *
 * All of your system's general configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/general.php
 */

return array(

    // Universal settings
    '*' => array(
        'usePathInfo' => true,
        'omitScriptNameInUrls' => true,
        // 'enableCsrfProtection' => true,
        'environmentVariables' => array(
            'baseUrl'  => $customEnv['baseUrl'],
            'basePath' => $customEnv['basePath'],
        )
    ),

);

my craft/config/_env.php file:

<?php

$customEnv = array(

    // Path info
    'baseUrl'  => 'http://my-domain.com',
    'basePath' => '/var/lib/openshift/xxxxxxx/app-root/runtime/repo//public_html',

    // Database connection info
    'server'   => getenv('OPENSHIFT_MYSQL_DB_HOST'),
    'user'     => getenv('OPENSHIFT_MYSQL_DB_USERNAME'),
    'password' => getenv('OPENSHIFT_MYSQL_DB_PASSWORD'),
    'database' => getenv('OPENSHIFT_APP_NAME'),

    // General config settings
    'general' => array(
        // Config settings for this environment
    ),

);

my craft/config/db.php file:

<?php

// Get environment

// require('_env.php');

/**
 * Database Configuration
 *
 * All of your system's database configuration settings go in here.
 * You can see a list of the default settings in craft/app/etc/config/defaults/db.php
 */

return array(

    // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
        'server' => getenv('OPENSHIFT_MYSQL_DB_HOST'),

        // The database username to connect with.
        'user' => getenv('OPENSHIFT_MYSQL_DB_USERNAME'),

        // The database password to connect with.
        'password' => getenv('OPENSHIFT_MYSQL_DB_PASSWORD'),

        // The name of the database to select.
        'database' => getenv('OPENSHIFT_APP_NAME'),

        // The prefix to use when naming tables. This can be no more than 5 characters.
        'tablePrefix' => 'craft',

);
1

I think this is the causing the installer to trip up:

[12-Sep-2016 16:44:29 UTC] PHP Warning:  strpos(): Empty needle in /var/lib/openshift/xxxxxxx/app-root/runtime/repo/craft/app/bootstrap.php on line 126

My guess is that there is something wrong with your environmental logic in craft/config/general.php (or maybe some off if you've modified Craft's public index.php as well).

I'd start by stripping that down to the basics and adding things back in one at a time until you find the culprit.

  • Thanks for the suggestion. I tried stripping the general.php file down to nothing, but am gettting the same error in the browser console. No PHP errors though (have PHP errors set to show everything). Also didn't make any edits to the public index.php file. – Colin Sep 12 '16 at 17:22
  • Are you defining CRAFT_ENVIRONMENT anywhere? Can you share the contents of your config/general.php file with the sensitive bits stripped in the original question? – Brad Bell Sep 12 '16 at 17:28
  • Added my general.php, db.php and _env.php files. Hope this helps. – Colin Sep 12 '16 at 19:26
1

Turns out that this was an issue with the OpenShift cartridge not Craft (https://github.com/pinodex/openshift-cartridge-nginx-php7/issues/8).

The PHP session.save_path value was set to a different (non-existent) directory than that which is created/defined when the cartridge is deployed.

The craft.log error (dev mode):

2016/09/12 20:10:55 [error] [php] session_regenerate_id(): open(/var/lib/openshift/xxxxxxx/app-root/data//php-session/sess_vdm5q1ulu7285qmi6g86jnph87, O_RDWR) failed: No such file or directory (2) (/var/lib/openshift/xxxxxxx/app-root/runtime/repo/craft/app/framework/web/CHttpSession.php:185)

Not sure why I didn't get any errors in the PHP error logs.

Creating the php-session directory fixes the issue, but the cartridge needs to be updated.

TL:DR PHP session settings issue caused by the OpenShift cartridge not Craft.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.