• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI4 on shared hosting return error 500

#1
Hi all,

I have some problem to try the new CI4 on the main shared hosting I use for me and customers.

This is the FTP main root and what I can or cant do with it:
- cgi-bin
- conf
- htdocs
- .htaccess


So...
1. I can't upload files inside root.
2. This is the .htaccess content:
Code:
ErrorDocument 403 /__tmp/index.shtml
AddHandler php7.0-script .php
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
3. I can upload all inside htdocs
4. I can upload inside cgi-bin folder too.
5. PHP version, currently 7.2 (7.3-7.4 not available)


First try;
put all files inside htdocs, than load
- website.tld/public/
- website.tld/public/home/
- website.tld/public/index.php/home

Error 500

Second try:
put public contents inside htdocs
put all other inside cgi-bin
index.php > added cgi-bin/ on path definition
Error 500

I prefer the second way, to put only public content inside htdocs, but I can't find any way to make it working correctly...

I tried also to remove ci4 public .htaccess, nothing.


Thank you for any suggestion.



PS: If someone what to suggest some ready to go domain that give no issues with initial ci4 files, please let me know in PM, just not to advertise here external websites...
Reply

#2
Hi, do you have access to your cPanel(?) error logs? And can you check writable\logs folder.
Reply

#3
No logs, this is the panel pages (not cpanel):

Manage FTP/Panel pass
Manage Pop/Imap accounts
Alias/Forward mails
DNS service
Redirects
Reset all
Create or edit db
Config PHP version
HTTPS/HTTP/2

Webmail
File manager (same folders as FTP, no logs)
PhpMyAdmin
Setup wordpress
Backup
Autofix

Used space and service status
Server info
PHP info
CGI/PERL info


Inside "conf" folder there is php.ini, I tried to uncomment this one:
error_log = php_errors.log

And reload ci4 public/ but nothing appear inside any folder...
Reply

#4
Have you asked the host provider if they can change it so you can upload to the main root?

If they say no, get a new provider.
Reply

#5
Done, their reply:

- Can't upload in main root;
- Don't give error logs;
- I must debug it (without logs/info about the error) or I must pay their tech dude to solve the issue.

Any suggestion about not so expansive provider for small websites will be appreciated (in PM). If someone would suggest, in the meanwhile, something to try before provider change that could solve the issue, let me know. Thank you!
Reply

#6
(03-02-2020, 06:41 AM)Waithere Wrote: Done, their reply:

- Can't upload in main root;
- Don't give error logs;
- I must debug it (without logs/info about the error) or I must pay their tech dude to solve the issue.

Any suggestion about not so expansive provider for small websites will be appreciated (in PM). If someone would suggest, in the meanwhile, something to try before provider change that could solve the issue, let me know. Thank you!

Just to be sure we are all using the same terminology, "main root" is the same folder level as htdocs and conf?

Or asked another way, you cannot create folders alongside htdocs and conf?
Reply

#7
>Or asked another way, you cannot create folders alongside htdocs and conf?


Exactly, I cant create folders alongside htdocs and conf.

I can put files inside htdocs or conf or cgi-bin.

With CI3 it worked with public files inside htdocs, and all other folders (app/sys) inside cgi-bin.

The main problem here is about CI don't work also if I put all the CI4 files inside htdocs and I try to load website.tld/public/.

I think If I can solve this, than I can use cgi-bin or conf for "not public" ci folders.
Reply

#8
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

#9
Thank you John_Betong!

All your post made me think about that simple mistake (but not soo clear before, considering previous errors).

In my case, now it works like this:



Just with these edits:
Old: $pathsPath = FCPATH . '../app/Config/Paths.php';
New: $pathsPath = FCPATH . '../cgi-bin/app/Config/Paths.php';

And .htaccess removed (to avoid the 500 error).

Now I'm just not sure about what issues could create the .htaccess removal, and how to debug it. If there's a chance.
I tried to remove part of the file code, section to section, but it always return error 500, until I delete all the file content...
Reply

#10
@Waithere,
> And .htaccess removed (to avoid the 500 error).

The main purpose of the .htaccess file is to redirect every URL to the index.php file. Redirection requires the apache2 "mod_rewrite.c" module to be loaded. If it is not loaded then redirection and pretty URLs will not work. It will be necessary to call "index.php?routing-parameters". .htaccess file is also used to set the either "production", "development" or "test" modes.

Once the Welcome_message page is rendered correctly then try to get logging to create the log file.

Try and introduce PHP errors and see what effect they have on rendering pages and the log items.

The log file can be safely deleted if there are too many entries. A new log file will be created with new errors, warnings or debug entries are raised.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.