Skip to main content
Skip table of contents

PHP CLI Version festlegen

Problem

Die Pfadangabe /usr/bin/php liefert die PHP Version in Version 8.2
Sie benötigen jedoch auf der Kommandozeile eine andere PHP Version.

Lösung

Die PHP Binaries der verfügbaren PHP Versionen liegen unter:

Version

PHP 5.6

/opt/php-5.6/bin/php

PHP 7.0

/opt/php-7.0/bin/php

PHP 7.1

/opt/php-7.1/bin/php

PHP 7.2

/opt/php-7.2/bin/php

PHP 7.3

/opt/php-7.3/bin/php

PHP 7.4

/opt/php-7.4/bin/php

PHP 8.0

/opt/php-8.0/bin/php

PHP 8.1

/opt/php-8.1/bin/php

PHP 8.2

/opt/php-8.2/bin/php

PHP 8.3

/opt/php-8.3/bin/php

Entsprechend der gewünschten PHP Version sollten Sie statt /usr/bin/php den Pfad der gewünschten PHP Version ihrem Skriptaufruf voranstellen. Also Beispielsweise:

BASH
/opt/php-8.3/bin/php /var/www/##IHRBENUTERNAME##/htdocs/mein-php-skipt.php

Sofern Ihr Tarif über einen SSH Zugang verfügt, können Sie Ihre Auswahl auch permanent in einer .bashrc Datei (im Ordner /priv) hinterlegen:

.bashrc
BASH
alias php='/opt/php-8.3/bin/php'
export PATH=/opt/php-8.3/bin/php:$PATH

Um die .bashrc ohne Logout/Login neu zu laden, geben Sie folgenden Befehl ein.

CODE
source ~/.bashrc

Im Beispiel unterhalb wird das Script automatisch unter PHP 8.3 ausgeführt.

BASH
php /var/www/##IHRBENUTERNAME##/htdocs/mein-php-skipt.php


Verwandte Artikel



JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.