The text on this page was translated by translation software. A revised version from our editors will be available soon.
PHP 7 accelerates many dynamic websites by over 100% compared to PHP 5.6 through OpCode caching and an optimized Zend engine.
For your visitors, this means a better user experience due to faster page set-up, for your website an improved ranking on Google due to higher page speed.
Speed improvements in PHP 7
PHP 7 achieves the enormous increase in speed primarily through improvements to the Zend Engine, extended OpCode caching, an improved data structure and thus reduced memory requirements and more efficient memory management.
How OpCode Caching Works
Normally PHP scripts are compiled at runtime. Part of the computing time is required to convert the code. With OPcache, this calculation is performed only once and the precompiled, machine-readable (calculated) script is stored in a cache. The script can be loaded from this cache at lightning speed if required. In most cases this leads to considerable speed improvements.
Especially larger websites can handle much more requests simultaneously with OPcache activated - an important advantage for corporate websites and eCommerce applications.
Preparing to switch to PHP 7
PHP 7 offers very good compatibility with older PHP versions - so the probability that existing applications and scripts will work is high. However, we recommend testing websites, plugins and scripts with PHP 7 before using PHP 7 in production environments.
Here is an example: The introduction of type hints and the words "int", "string" and "float" reserved for the first time still causes problems for certain CMS at the beginning. Joomla!, for example, is not compatible with PHP 7 in version 3.4 because it uses the type name "string" in a way that is not allowed in PHP 7. The Joomla! community has meanwhile corrected the use, as you can read here Joomla! 3.5 supports PHP 7 without restrictions.
PHP-Version im 1&1 IONOS Control Panel aktualisieren
Changing the PHP version usually takes a few seconds to a minute. We recommend that you test your scripts after the change. For possible problems we have compiled Frequent Error Messages for PHP Scripts and recommendations for possible solutions. You can undo the changes in your PHP version at any time.
Enable OPcache via php.ini
After switching to PHP 7, you can enable OpCode Caching (OPcache) for your websites. You have to create a new directory for the cache on your webspace and adapt the php.ini in the root directory of your website.
Creating the Web Space Directory for the Cache
Login to your webspace via SFTP
This tutorial shows you how to transfer files securely step by step using FTP.
Create a new directory in the root directory. In the future, the cache for your websites will be stored in this directory.
Please note: In order to protect the data in the cache, you must create a directory with a leading point (e.g.: .. /.opcache). This directory is then automatically protected by your Apache web server.
Store absolute path in php.ini
In the next step you have to enter the absolute path to the created .opcache directory in php.ini. In this tutorial, you will learn how to determine the absolute path (document root) using PHP script.
The path should look like this: /customer/homepages/my-path/htdocs/.opcache
Open the main directory of your website via SFTP and open the file php.ini.
Add the following entry here:
Please note: Use the absolute path to your .opcache directory under opcache.file_cache=.
The entire content of php.ini should look like this after this step.
zend_extension=opcache.so; opcache.enable=1; opcache.memory_consumption=32; opcache.interned_strings_buffer=8; opcache.max_accelerated_files=3000; opcache.revalidate_freq=180; opcache.fast_shutdown=0; opcache.enable_cli=0; opcache.revalidate_path=0; opcache.validate_timestamps=2; opcache.max_file_size=0; opcache.file_cache=/kunden/homepages/mein-pfad/htdocs/.opcache; opcache.file_cache_only=1;
Save the file php.ini and upload it back to your webspace.
How to check if OPcache is active for your website
After you have activated the OPcache for your website and called it a few times, you can simply check whether the cache works correctly.
Log on to your webspace again via SFTP and open the directory ../.opcache you created earlier.
In this directory you should now see the cached contents of your website.
The new 1&1 IONOS Community - hosting knowledge from experts for your success.