0

I added a new Craft4 install via the command line as per the instrictions. Everything went OK and I got "installed Craft successfully". I can run craft update and it returns all up to date. The database looks like it's all OK.

But in the browser I get the 500 error message: "The server encountered an internal error or misconfiguration and was unable to complete your request." I haven't moved or renamed the web folder, my directory structure looks like the one on the install document page. If I add add a plain text file and call that in the browser it displays OK, so there must be something in the configuration that's wrong.

My web/index.php file doesn't look like any of my existing craft 3 sites. It only has:

/**
 * Craft web bootstrap file
 */

// Load shared bootstrap
require dirname(__DIR__) . '/bootstrap.php';

// Load and run Craft
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();

In past I have run with a directory structure of craft and public_html side by side and my index.php file in public_html would have:

// Define path constants
define('CRAFT_BASE_PATH', dirname(__DIR__,1).'/craft');
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH . '/vendor');```
6
  • Would you check and post the logs? Maybe you see what exactly causes the problem there. Commented Sep 28, 2022 at 13:51
  • There is only a console log that is 416 lines and nothing that I can see showing any errors. If I run craft update in the terminal it adds another 63 lines. I'm not sure how to "post the logs"?
    – Paul Frost
    Commented Sep 28, 2022 at 16:45
  • Apache should generate error logs that will give you the reason for the 500 server error. Most hosting companies will provide these logs in the project/domain folder (or one level above) or if you're on a dedicated server, they can typically be found in: /var/log/apache2/ or sometimes /etc/apache2/logs Commented Sep 28, 2022 at 17:06
  • I'm not seeing anything like that, no apache anywhere. I am using cPanel and this install is on a subdomain. I think the problem is connected with the path in the index.php file. I'm going to post a separate question about how to install on a subdomain.
    – Paul Frost
    Commented Sep 28, 2022 at 17:38
  • If you do not have a web or phperrors log and console.log does not show any errors, we could look at another place. (the logs. while long and confusing, are always a good place to learn where errors occur. Oftentimes you will see a an error and the detailed error message - for example if php threw an error, a file is missing or a path is wrong) Is the folder structure default or did you modify it? Commented Sep 28, 2022 at 19:34

1 Answer 1

1

The problem I had was caused by the wrong permissions set on some files. The permission settings on my cPanel server are quite different to Craft's suggestions. In my case all folders are 755 and files 644, but with some files that need to writable set at 755. Also the permissions for an additional created public_html folder needed to be 750, and this install was in a created subdomain.

Additionally the index.php file in the web folder needed editing to reflect the location of the bootstrap.php file if you move the web folder in the directory structure. The default code is:

require dirname(__DIR__) . '/bootstrap.php';

You need to change this to:

require dirname(__DIR__,1) . '/***/bootstrap.php';

The *** should be replaced by the name of the folder that the bootstrap file is in. The ,1 is how many levels to up in the folder structure from where the index.php is located. In my case the 2 folders are in the same parent folder, so it just need to go up 1 level top find the *** folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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