I have a website setup to use PHP 7.4.
That seems to be working at the application level. But at the server (SSH) level, the PHP version is always reported as v 7.1.33.
This causes a major problem with trying to deploy and manage composer projects. Because the PHP version is detected as being incompatible.
Also, if I do a composer install
detects the PHP version as 7.1.33, which is wrong. It’s 7.4.
This results in an error such as this when doing a composer install
:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php >=7.3 but your PHP version (7.1.33) does not satisfy that requirement.
Problem 2
- Installation request for darkaonline/l5-swagger 6.0.4 -> satisfiable by darkaonline/l5-swagger[6.0.4].
- darkaonline/l5-swagger 6.0.4 requires php ^7.2 -> your PHP version (7.1.33) does not satisfy that requirement.
etc.
Or when running other php
commands in the project folder, this error is produced:
# php artisan optimize
PHP Fatal error: Declaration of Symfony\\Component\\Translation\\TranslatorInterface::setLocale($locale) must be compatible with Symfony\\Contracts\\Translation\\LocaleAwareInterface::setLocale(string $locale) in /home/billing.inspiredearth.nz/public_html/vendor/symfony/translation/TranslatorInterface.php on line 24
In LogManager.php line 416:
Use of undefined constant JSON_INVALID_UTF8_SUBSTITUTE - assumed 'JSON_INVALID_UTF8_SUBSTITUTE'
I am told this is due to the PHP version being wrong.
I see other people have reported this issue going back a few years. What’s the way around it?
How to I get the server to report a php version that’s the same as the website settings?
Another related issue is that there appears to be no way to access the website folders without using root
user. But things like Composer shouldn’t be run with the root
user. I’ve brought that up in a separate discussion post.