bolt / core

🧿 Bolt 5 core
https://boltcms.io
MIT License
547 stars 159 forks source link

PHP Error during installation on shared hosting #2524

Open fabz1001 opened 3 years ago

fabz1001 commented 3 years ago

Hello there, I'm trying to install Bolt 4 on a Ionos (1and1) shared hosting. Everything seems to go fine until, near the end I run into this error:

Script php bin/console extensions:configure handling the post-update-cmd event returned with error code 255

Right before that, I see: > php bin/console extensions:configure X-Powered-By: PHP/4.4.9

So I realised that, despite my hosting seems to be running PHP 7.4 (it really is, as I can successfully run php 7 commands), at some point, Bolt detects somehow a much older PHP version, which I suspect it to be the actual physical server's one.

Does anyone know any workarounds for that? I have both SSH and FTP access although pretty limited. Thanks a lot in advance, really.

Details

Question Answer
Relevant Bolt Version 4.1
Install type Composer install
BC Break ?
PHP version 7.4
Web server Apache

Reproduction

Steps to reproduce

Install Bolt 4 on a Ionos shared hosting.

Expected result

Complete the installation just fine.

Actual result

The following error shows up: Script php bin/console extensions:configure handling the post-update-cmd event returned with error code 255.

fabz1001 commented 3 years ago

UPDATE: I've successfully managed to get around that by replacing all the "php extensions....." occurrences with the correct php7.4 path. I then launched composer install and all went through just fine.

Then I faced the following permissions error in the browser:

Forbidden You don't have permission to access this resource. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

So I created an .htaccess to point at project_name/index.php but Bolt Installation error shows up prompting me to move the document root to /public. So I changed my .htaccess to point at project_name/public/index.php and it worked!

The thing is, now only the homepage is working, all the other pages, including /bolt, show Internal Server Error...

I appreciate any help 🙏 .

I-Valchev commented 3 years ago

Hi @romokebi , it sounds like the .htaccess config needs a bit more configuration to work properly on the 1on1 hosting.

Here is the default .htaccess that Bolt arrives with: https://github.com/bolt/project/blob/master/public/.htaccess

Does it help?

fabz1001 commented 3 years ago

Hi @I-Valchev ! Thanks a lot for your support.

I did try the default file but it threw "Internal server error" on every page, unfortunately. The one I used and I have been able to see at least the homepage with is the one I attached below.

Note that I replaced DirectoryIndex index.php with DirectoryIndex project_name/public/index.php.

This is because, as far as I understood, the 1and1's main .htaccess is pointing to htdocs/index.html, while the Bolt project's index.php is in htdocs/project_name/public/. That's why I thought to create an .htaccess in htdocs/ .

To be completely honest, I have no idea whether I did something which makes sense at all, so I'm really hoping I have been able to provide at least enough and useful info for you guys to help me with this problem.

Thank you 🙏

DirectoryIndex project_name/public/index.php project_name/public/index.html project_name/public/index.htm

Options -Indexes

<IfModule mod_negotiation.c>
  Options -MultiViews
</IfModule>

<FilesMatch "\.(dist|db|markdown|md|twig|yaml|yml)|(bower|composer|jsdoc|package)\.json$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
  </IfModule>
</FilesMatch>

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteRule cache/ - [F]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ ./index.php [L]

</IfModule>

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
   RewriteCond %{SCRIPT_FILENAME} -d [OR]
   RewriteCond %{SCRIPT_FILENAME} -f
   RewriteRule "(^|/)\." - [F]
</IfModule>
simongroenewolt commented 3 years ago

I've successfully managed to get around that by replacing all the "php extensions....." occurrences with the correct php7.4 path.

Just a note for the next time you do this, or for future visitors: Assuming you are using a bash (or similar) shell on linux via ssh, you don't have to edit all your scripts if you update the PATH environment variable to point to the correct php version before running the scripts.

This is how I set the correct php version on a plesk-based server that has multiple versions of php installed:

export PATH=/opt/plesk/php/7.3/bin:$PATH;

Just run this in the terminal before you do any other actions (adjusted to your path to the correct php version of course). It will prepend the path to the correct php to your PATH, thereby 'masking' the incorrect version that is also in the path.

For other shell types you can use the same technique, but you might have to adjust the syntax.

Edit: This assumes you don't want to change the default PATH for this user, and/or are OK with setting the PATH every time you log in. You can also make a permanent change by adding the export line to your .bash_profile