With a market share of more than 80%, PHP is the go-to scripting language for many programmers when it comes to creating dynamic content. Whether you’re operating your own weblog, running an internet forum, or designing an online shop, it’s likely that the software behind this will be written via PHP. Our PHP tutorial for beginners will introduce you to the basics of the popular scripting...
SEO with rankingCoach from IONOS!
Boost your Google ranking by optimizing your website without prior knowledge!
- Speed improvements in PHP 7
- How OpCode Caching Works
- Preparing to switch to PHP 7
- Update the PHP version in the IONOS control panel
- Enable OPcache via php.ini
- How to check if OPcache is active for your website
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.
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
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=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!