PHP 7.2.7 & 7.3.0alpha3 CLI for 1&1 Webhosting

Sep 25, 2017 by Johan

1&1 now has native PHP 7.1 CLI support. Continue only if you require PHP 7.2 or 7.3 CLI.

1&1 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.2.7

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

    wget --content-disposition https://mr42.me/dl/php73
    tar xjf php73.tar.bz2
    echo "alias php='LD_LIBRARY_PATH=~/bin/lib ~/bin/php73-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/php72-cli
or
PHP=bin/php73-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/php72-cli or ~/bin/php73-cli directly.

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

  • ctype
  • curl
  • date
  • dom
  • filter
  • gd
  • hash
  • intl
  • json
  • libxml
  • mbstring
  • mysqlnd
  • openssl
  • pcre
  • phar
  • PDO
  • pdo_mysql
  • Phar
  • Reflection
  • SimpleXML
  • SPL
  • tokenizer
  • XMLWriter

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 libraries (libcrypto.so.1.1, libpng16.so.16, libssl.so.1.1) to make it work on a 1&1 environment are copied over from Debian and are not compiled by me.

./configure --enable-static --enable-cli --disable-all --disable-posix --with-curl \
 --enable-phar --with-openssl  --enable-json --enable-intl --enable-mbstring \
 --enable-filter --enable-hash --enable-ctype  --enable-pdo --with-pdo-mysql \
 --enable-tokenizer --enable-xml --enable-libxml --enable-dom --enable-simplexml \
 --enable-xmlwriter --with-gd
make

The libraries can be found in the following packages:


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 but 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.

Permalink · 1 comment · linux, PHP, 1und1 · · · Johan

Johan is a 37-year-old man from The Netherlands, currently living in Germany. His interests are music, universe & space, IT-technology, quantum mechanics, physics and electronics. After high school and college he has been working on IT-support for different companies. He is a fan of science fiction and is always excited to see technology evolve from idea to reality. Especially the developments for quantum computing to real life applications and new discoveries in space can always count on his attention.

361875870


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

· Howie

Leave a Comment

This will never be published.
You may use Markdown Syntax. HTML is not allowed.
CAPTCHA Image
Click on the image to retrieve a new verification code.