Welcome Guest, Not a member yet? Register   Sign In
CI4 on shared hosting return error 500
#8

(This post was last modified: 03-02-2020, 10:13 PM by John_Betong.)

I get the impression that CI4 defaults to all app, system and writable folders in the index.php parent directory. This can be changed.

Run index.php but point halt/die; at the point where it is calling the app/paths. Change the calling path to wherever your app folder is located and make the necessary changes to the paths.

echo getcwd(); die; frequently to find out the directory and adjust relative paths.

When I am back on the desktop I will check the path file names.

Edit:
Wherever the writable folder is located it needs to be writable:

sudo chmod -R 0777 writable

Edit: - now on desktop

I have set the following paths:
/public_html/index-waithere.php
/public_html/app/
/public_html/system/
/public_html/writable/

Online Demo:
https://ci4-strict.tk/index-waithere.php
https://ci4-strict.tk/index-waithere.php...-the-paths

Code:
<?php DECLARE(STRICT_TYPES=1);

define('CI_DEBUG', FALSE); // bypass (bool) app/Config/oot/development.php
  
  # ini_set('display_errors', '1');
  # $_SERVER['CI_ENVIRONMENT'] = 'development'; // bypass .env & .htaccess
  # $useKint = FALSE;

// Valid PHP Version?
$minPHPVersion = '7.2';
if (phpversion() < $minPHPVersion)
{
  die("Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter. Current version: " . phpversion());
}
unset($minPHPVersion);

// Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);

// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
# OLD PATH
  $pathsPath = FCPATH . '../app/Config/Paths.php';
# NEW PATH
  $pathsPath = FCPATH . 'app/Config/Paths.php';
// ^^^ Change this if you move your application folder

/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/

// Ensure the current directory is pointing to the front controller's directory
chdir(__DIR__);

// Load our paths config file
require $pathsPath;
$paths = new Config\Paths();

if( ! empty($_GET) ) :
    echo '<pre><b> BEFORE: </b>'; print_r($paths); echo '</pre><br>';

    $CWD = getcwd();
    $paths->systemDirectory   = $CWD .'/system';
    $paths->appDirectory      = $CWD .'/app';
    $paths->writableDirectory = $CWD .'/writable';
    $paths->testsDirectory    = $CWD .'/tests';
    $paths->viewDirectory     = $CWD .'/app/Views';
  
    echo '<pre><b> AFTER HARD-CODING: </b>'; print_r($paths); echo '</pre><br>';
endif;

// Location of the framework bootstrap file.
$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';

/*
*---------------------------------------------------------------
* LAUNCH THE APPLICATION
*---------------------------------------------------------------
* Now that everything is setup, it's time to actually fire
* up the engines and make this app do its thang.
*/
$app->run();
Reply


Messages In This Thread
RE: CI4 on shared hosting return error 500 - by John_Betong - 03-02-2020, 05:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB