• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

How to change PHP CLI version from 5.4 to highter

bulent

Regular Pleskian
Hi,
I am trying to install a laravel app and when I run

composer install --no-interaction --no-dev --prefer-dist

it says that system do not meet requirements, required version of php is 5.6, but you have 5.4

php -v returns php 5.4

How to change default PHP CLI version to 5.6 or 7

I have tried to run

/opt/plesk/php/5.6/bin/php /path/to/my/app/composer install --no-interaction --no-dev --prefer-dist

but it says coud not open composer...
 
Try to install composer with

# curl -sS https://getcomposer.org/installer | /opt/plesk/php/5.6/bin/php -- --install-dir=/usr/local/bin
# ln -s /usr/local/bin/composer.phar /usr/local/bin/composer

and then use /usr/local/bin/composer
 
Try to install composer with

# curl -sS https://getcomposer.org/installer | /opt/plesk/php/5.6/bin/php -- --install-dir=/usr/local/bin
# ln -s /usr/local/bin/composer.phar /usr/local/bin/composer

and then use /usr/local/bin/composer

First one returned "installed successfully"
Second one return nothing.

When I run

/usr/local/bin/composer install --no-interaction --no-dev --prefer-dist

in app folder, it returns again php version is 5.4 ...
 
Looks like that you need to modify path to php in your composer.json
 
Looks like that you need to modify path to php in your composer.json

I have the code below in composer.json
Code:
{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "mews/purifier": "~2.0",
        "vinkla/hashids": "^2.4",
        "fzaninotto/faker": "~1.4",
        "intervention/image": "^2.3",
        "santigarcor/laratrust": "3.0.*",
        "guzzlehttp/guzzle": "^6.2",
        "chencha/share": "^5.2",
        "larapack/config-writer": "1.*",
        "cviebrock/eloquent-sluggable": "^4.1",
        "grabzit/grabzit":"3.0.0"
    },
    "require-dev": {
        "mockery/mockery": "0.9.*",
        "barryvdh/laravel-debugbar": "^2.2",
        "phpunit/phpunit": "~5.0",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}
And modified PHP starting ones to /opt/plesk/php/5.6/bin/php but it did not help either
Is there safe way to update the default php cli version
 
Good. But I see there:

Forbidden
You don't have permission to access /2015/08/18/using-php-composer-phar-with-non-default-php-install on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Hi @IgorG
As I understand, you cant open the article. Right?

That below is the copy of the article:

Using PHP composer.phar With Non-default PHP Install

By admin on August 18, 2015 in PHP

Composer for PHP is an increasingly popular tool for managing packages within a PHP application. Here’s a link for more information:

https://getcomposer.org/

On many of our Plesk servers we have multiple PHP versions install. The default at /usr/bin/php is provided by the Linux distribution and then there are additional version installed at /opt/plesk/php. Plesk lets us easily select the PHP version for each hosted website. But you can run into problems with composer using the wrong PHP version. A typical composer command might be:

Code:
php composer.phar install
or
Code:
php composer.phar update

To make our alternate PHP version work we need to instead do something like this:

Code:
export PATH=/opt/plesk/php/5.6/bin:$PATH; php composer.phar update

So we override the default PHP by adding our preferred version to the front of the path.

But from all that I run

Code:
export PATH=/opt/plesk/php/5.6/bin:$PATH

and after that I did not have problems with composer
 
Hello,
I marked this treat as unsolved as this solutions mention not worked for me, running Plesk 17.

I also set export and alias in: .bash_profile ans .bashrc
php -v
PHP 5.6.30 (cli) (built: Jan 20 2017 12:09:30)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.7, Copyright (c) 2002-2016, by ionCube Ltd.
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

But running composer from de Plesk GUI say's - phpunit/phpunit 5.3.x-dev requires php ^5.6 || ^7.0 -> your PHP version (5.4.16) does not satisfy that requirement.
 
Last edited:
Back
Top