PHP 7 + OPcache speed up websites noticeably

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.

SEO with rankingCoach from IONOS!

Boost your Google ranking by optimizing your website without prior knowledge!

Easy
Tailored to you
24/7 support

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.

Website Check

Update the PHP version in the IONOS control panel

Changing the PHP version usually takes a few seconds to a minute. We recommend that you test your scripts after the change. 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

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.

The path should look like this: /customer/homepages/my-path/htdocs/.opcache

Customize php.ini

Open the main directory of your website via SFTP and open the file php.ini.

Add the following entry here:

opcache.file_cache=/kunden/homepages/mein-pfad/htdocs/.opcache;

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=1;
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.

SSL certificates from IONOS

Protect your domain and gain visitors' trust with an SSL-encrypted website!

Easy activation
Proven safety
24/7 assistance

Wait! We’ve got something for you!
Have a look at our great prices for different domain extensions.


Enter the web address of your choice in the search bar to check its availability.
.org
$1/1st year
then $20/year
.com
$1/1st year
then $15/year
.info
$1/1st year
then $20/year
.me
$1/1st year
then $20/year