PHP 7.4.16 & 8.0.3 for 1&1 IONOS

Posted Sep 25, 2017 · Updated Mar 7, 2021

Since I moved away from 1&1 IONOS, updates will be irregular!


1&1 IONOS has been a fairly early adopter to PHP 7 in their Shared Webhosting and provides regular updates to the latest version in every 7.x branch. However, for some reason the latest version available in the shell is runnning behind. This could get you into trouble, for example when using composer, where your desired package has a requirement higher than the version available. This article delivers a solution.

Login to your environment with ssh and follow these steps:

  • PHP 7.4

    wget --content-disposition https://mr42.me/dl/php74
    tar xjf php74.tar.bz2
    echo "alias php='LD_LIBRARY_PATH=~/bin/lib ~/bin/php74-cli'" >> ~/.bashrc
    
  • PHP 8.0

    wget --content-disposition https://mr42.me/dl/php80
    tar xjf php80.tar.bz2
    echo "alias php='LD_LIBRARY_PATH=~/bin/lib ~/bin/php80-cli'" >> ~/.bashrc
    

You can either log out and log back in, or run . ~/.bashrc in order to run php on the command line.

It is also possible to use this PHP version in your cronjobs, after adding 2 lines preceding the jobs themselves.

LD_LIBRARY_PATH=bin/lib
PHP=bin/php74-cli

You can then use $PHP in your cronjob and have an up-to-date version of PHP 7 carry out that job for you. Alternatively you can omit the second line and use ~/bin/php74-cli directly.

A list of available modules are listed below. If you require any other module, please let me know in the comments.

  • bcmath
  • Core
  • ctype1
  • curl
  • date
  • dom
  • fileinfo
  • filter
  • gd
  • hash
  • iconv
  • intl
  • json
  • libxml
  • mbstring
  • mysqlnd
  • openssl
  • pcre
  • PDO
  • pdo_mysql
  • Phar
  • Reflection
  • session
  • SimpleXML
  • soap
  • sockets
  • SPL
  • standard
  • tokenizer
  • xml
  • xmlwriter
  • zip

Update requested by Howie: These binaries are build from the original source code from the PHP website. If you prefer to build them yourself instead of using "wild" binaries from the web (which is totally understandable), you can follow the steps below. The additional library (libonig.so.2) to make it work on a 1&1 environment is copied over from Debian and is not compiled by me.

./configure --enable-static --enable-cli --disable-all --enable-bcmath --disable-posix \
 --with-curl --enable-phar --with-openssl --enable-json  --enable-intl --enable-mbstring \
 --enable-filter --enable-ctype  --enable-pdo --with-pdo-mysql --enable-tokenizer \
 --enable-xml --with-libxml --enable-dom --enable-fileinfo --enable-session \
 --enable-simplexml --enable-soap --enable-sockets --enable-xmlwriter --with-zip \
 --enable-gd --with-iconv --with-pear
make -j 6

The library can be found in the following package:


Update 2: Good news everyone! 1&1 now has PHP 7.0 CLI available on all shared servers worldwide! I will keep PHP 7.1 & 7.2 available and updated for now, but for the majority of users 1&1 provides a solution out of the box.


Update 3: 1&1 now has PHP 7.1 CLI available. For some strange reason they also removed the 7.0 binary, which broke my cronjobs overnight. That last part I am not particularly happy about. I will drop PHP 7.1 and add PHP 7.0 again.


Update 4: PHP 7.3 is around the corner. PHP 7.0 has been removed.


Update 5: PHP 7.3 is now stable. PHP 7.2 has been removed.


Update 6: PHP 7.4 just hit alpha stage and has been added.


Update 7: Howie pointed out that PHP 7.3 is now officially available on IONOS servers. I removed the 7.3 binaries from the page.

Comments

How did you compile the PHP binary?

Hello,
I wanted to use the CLI version of PHP 5.6 (or newer) earlier in 2017 (maybe in March or April) and was told by 1&1 that they were working on it and that it would be available "soon". It is now the end of September 2017 and it is still not available. Other 1&1 customers have also been asking for the newer CLI versions; see https://community.1and1.com/using-php-composer-at-1and1/
So, thank you for posting this. You seem to genuinely want to be helpful, but I am not comfortable running a PHP binary in production without knowing how it was compiled. Can you please post the steps you took to compile your php71.tar.bz2 binary? In addition to letting us feel more comfortable running this in production, it would also enable us to compile newer or different PHP versions (PHP 7.1.10 whenever it's available, or PHP 5.6) without bothering you to update it.
Thanks!
Howie

missing extensions

Hello,

Thank you for your helpful post !
i may need those extensions

PHP extension ext-iconv
PHP extension ext-soap
PHP extension ext-zip

Re: missing extensions

Thanks Skander!
I have updated the binary to include your requested extensions.

missing extension

Hi,

thx for the article,

I need ext-fileinfo

Re: missing extension

Hi Stephan.
The fileinfo extension has been added

Re: missing extension

Hallo nochmal,

bc_math wäre auch toll.

Re: missing extension

Ist jetzt auch dabei

Fehler bei Direktaufruf: cannot open shared object file

Hi Johan,

danke für die super Hilfe. Habe leider ein eigenartiges Phänomen und komm einfach nicht drauf. Habe php73 nach Deiner obigen Anleitung heruntergeladen. Rufe ich es direkt auf über ~/bin/php73-cli kommt der Fehler 'error while loading shared libraries: libzip.so.4: cannot open shared object file: No such file or directory'. Ruf ich es jedoch direkt über php auf, funktioniert es. Der Direktaufruf von php zeigt auch definitiv, dass es PHP 7.3 ist. (Vor der Änderung war es PHP 4.4.9)

Übrigens noch ein Hinweis: Auf meinem 1und1-Server war die ./profile Datei noch nicht in meinem SSH-Homeverzeichnis angelegt. Deshalb hat es beim Login immer wieder die ursprüngliche PHP-Version mit dem Befehl php aufgerufen. Als Inhalt der ./profile hab ich

if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

eingetragen, dann funktioniert der php-Direkt-Aufruf.

Re: Fehler bei Direktaufruf: cannot open shared object file

Hi Thomas,

~/bin/php73-cli won't work indeed, but if you do LD_LIBRARY_PATH=~/bin/lib ~/bin/php73-cli it works. The executable will look for libraries in the default places, but there are a few not present on the server (but included in the download for exactly that reason). With the LD_LIBRARY_PATH it will look in ~/bin/lib as well.

I don't know if .profile was present or not before. Doesn't matter, people can now follow your directions if it isn't there.

PHP 7.3 CLI is now available on 1&1 shared hosting!

Hello Johan,
I just wanted to let you know that 1and1 now has the command line interface version of PHP 7.3 available:
> ls -l /usr/bin | grep php7 | grep cli
-rwxr-xr-x 12 root root 13948192 Jun 4 08:11 php7.1-cli
-rwxr-xr-x 10 root root 16682848 Jul 11 02:04 php7.3-cli

> php7.3-cli --version
PHP 7.3.7 (cli) (built: Jul 11 2019 06:02:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies

I have a cronjob set up on my server that runs once every Monday morning to let me know which PHP versions are available on 1&1. PHP 7.3 CLI became available sometime since last Monday.
Here's the line in my cron config to check the PHP versions:
00 09 * * 1 ls /usr/bin | /bin/grep php | mail -s "1and1 php versions" MY_EMAIL_ADDRESS

Thanks,
Howie

Re: PHP 7.3 CLI is now available on 1&1 shared hosting!

Hi Howie.

That's awesome! I will update the article with this information.
Btw, you can do ls /usr/bin/php7*-cli and omit the grep commando altogether.

Module

can you add socktets module

missing session extension

whene i try to install composer i have this error
Session support cannot be enabled as the session extension is not installed
plz i need help , how can i add session extension

Re: missing session extension

I've never seen the need for sessions in a CLI environment. Can you please share which package(s) you are trying to install?

Re: missing session extension

i have symfony project ,so i need session on this project .
in old php version i found session extension , so can u add this extension ???

Re: missing session extension

ocramius/package

Re: missing session extension

I will try to include it in the next update

Leave a Comment

This will never be published.
You may use Markdown Syntax. HTML is not allowed.