Use PHP 7 with OpCache to boost your website’s speed

Many of the most popular websites and CMSs will benefit significantly when you switch from PHP 5.6 to PHP 7—performance increases of over 100% are often possible with PHP 7. WordPress websites, for example, run more than twice as fast with PHP 7!


How does PHP 7 boost your website’s speed?

PHP 7 achieves an enormous increase in speed through improvements to the Zend Engine, opcode caching as well as an improved data structure, which reduces memory requirements and ensures more efficient memory management.

OpCache explained

Usually, PHP scripts are compiled at runtime. In this process, part of the computing time is needed to convert the code. With OpCache, this calculation is only performed once, and the pre-compiled, machine-readable (calculated) script is saved in a cache. The script can be loaded from this cache at lightning speed as needed. In most cases, this significantly improves the speed.

Large websites in particular can handle a considerably larger number of requests at the same time when OpCache is enabled—this is especially important for company websites and e-commerce.

A few things to consider before you switch to PHP 7

PHP 7 is generally very compatible with older PHP versions. Nevertheless, we recommend testing websites, plugins and scripts with PHP 7 before employing PHP 7 in live systems.

Example: The introduction of type hints and the now-reserved words “int”, “string” and “float” is currently causing problems for certain CMSs. For instance, version 3.4 of Joomla! is not compatible with PHP 7 because the type designation “string” is used in a manner that is not permitted in PHP 7. The Joomla! community has since corrected this usage and will publish a compatible version, Joomla! 3.5, at the beginning of 2016.

Activating PHP 7 in the 1&1 Control Panel

You can activate PHP 7 for each domain individually and quickly switch between different PHP versions as needed. To activate, select Configure PHP version next to the chosen domain in the 1&1 Control Panel.

Activate PHP 7 in 1&1 Control Panel

Activating OpCache for your websites

Once you have activated PHP 7, you can activate OpCache for your websites. To do this, you create a new folder in your webspace to store the cached files and add some lines to the php.ini in the root folder of your website.

Create a folder for the cached files

Log in to your Webspace using SFTP and create a new folder for the OpCache files in the root directory of your webspace.

Important: To protect the data inside the OpCache, please always create a folder starting with a point. The Apache webserver will automatically protect this folder.

Something like /.opcache will work fine.

Please note: In the next step, you will add a link to this new folder to the php.ini of your website. For this link you must use an absolute path. You can learn how to find the full path to your webspace in the 1&1 Help Center.

The path should look like this:  …/homepages/mypath /htdocs/.opcache

Adjust the php.ini

  • Open the root folder of your website using SFTP.
  • Open the php.ini file.
  • Add this content to your php.ini:;
opcache.file_cache= .../homepages/mypath/htdocs/.opcache;

Please note: For opcache.file_cache= please adjust the path to your opcache folder to use the absolute path to your webspace.

  • Save the php.ini file and upload it to your webspace.

Verify if OpCache is working correctly

After enabling OpCache for your website and accessing the website for a few times, you will find that the /.opcache folder in your webspace will contain new (cached) files. This confirms that OpCache is working for your website.

You might also be interested in

Please rate this post :

19 thoughts on “Use PHP 7 with OpCache to boost your website’s speed

  1. I had an issue configuring OpCache in my 1and1 server.

    I followed this article but drupal 8 kept saying opcache was disabled, and also php opcache_get_status() function returned enabled=false.

    I just fixed it by removing the last line that was supposed to be added to php.ini:

    Hope it helps!

  2. joan says:

    I can’t find the “php.ini” file on my 1and1 ultimate account. Did you create a new one? could somebody explain me this, please?


    1. 1and1help says:

      Hello joan,

      The global php.ini is not accessible from your webspace. Following the instructions in the article, please create a new, custom php.ini and upload it to your webspace.

      Thanks and best,
      Michael, 1&1

  3. Ernie Cole says:

    I do not have a PHP.ini file anywhere in my files directories

    1. 1and1help says:

      Hi Ernie Cole,

      as mentioned above to joan: The global php.ini is not accessible from your webspace. Following the instructions in the article, please create a new, custom php.ini and upload it to your webspace.

      Thanks and best,
      Michael, 1&1

  4. Joseph Mason says:

    I changed this to PH7.0 and it does not work. I wish to remove the content in this domain and put something else there. How do I do it?

    1. 1and1help says:

      Hi Joseph,

      If you would like to remove the content of your website, you may delete the content in the folder where your website is pointed. You may then upload your new content to the same folder and your website will be updated with the new content. This does not directly relate to the version of PHP you are using or the php.ini file.

      If you would like to delete the cached content, you may delete all files found in the .opcache folder or whatever folder you configured. This content will be regenerated when your website is visited next.

      Michael, 1&1

  5. Calah Gowdy says:

    Can I just have someone do this for me? I uploaded a theme to WordPress and tried to upload the demo content, but it told me this:

    max_execution_time: 30 *RECOMMENDED 180
    max_input_vars: 1000 *RECOMMENDED 2000

    I don’t feel comfortable making changes myself. I’ve already upgraded to PHP 7.

    1. 1and1help says:

      Hi Calah,

      you can change the value for “max_input_vars” in your own, local php.ini.

      Just put

      max_input_vars = 2000

      in the already existing php.ini file in your WordPress root path. [Edit: If this does not work- maybe into the php.ini in /wp-content/themes/ as well]

      The value for “max_execution_time” is given by the server and your tariff.. We can’t increase this number for you, sorry. But from my experience, most of the themes should also run smoothly with this setting. To achieve limits like the recommended 180s, you would need to switch to an own 1&1 Managed Server.

      Best regards,
      Michael, 1&1

  6. Vladimir says:

    I updated to PHP v7 and get this error on my webpage: Database connection error (1): The MySQL adapter ‘mysql’ is not available

    I chnaged to PHP 5.5 and all works fine.

    I understand I need to change PHP.INI. How can I do that please?


    1. 1and1help says:

      Hi Vladimir,

      the ‘mysql’ function was removed completely with PHP 7. Please use ‘mysqli’ instead.

      For PHP 5.6 ‘mysql’ still works but it is not recommended to use it anymore (deprecated since PHP 5.5).

      So if you still need to use ‘mysql’, you might stay with PHP 5.6 for now.

      Best regards,
      Michael, 1&1

  7. Luke says:

    I updated to PHP 7.0, but now WordPress is telling me I must increase my PHP memory from 40M to at least 96M in order for my theme (Evanto Jupiter) and Visual Composer to work… Can anyone give me simple steps for this?

    1. 1and1help says:

      Hi Luke,

      the limit for PHP memory is set by the tariff you have. With 40M this seems to be a very old hosting package.

      You can achieve better limits with performing a tariff change in your 1&1 Control Panel:

      For 96M or better, a tariff change into Unlimited Pro would be necessary.

      Best regards,
      Michael, 1&1

  8. Moeeza says:

    I Can not edit php.ini with fileZilla . Can you please help me !

    1. 1and1help says:

      Hi Moeeza,

      what exactly happens? The php.ini can be edited with a text editor like Notepad ++ or other plain text editor software.

      Best regards,
      Michael, 1&1

  9. Pat Read says:

    Hi. I am using PHP 5.2 as I found a year ago that moving to a higher PHP caused the search function to stop working on my website. How can I re-test out a higher PHP but having the option to go back and stick to 5.2 with extended support ? In the control panel there is only the option to switch between 5.5, 5.6 and 7.0. I am worried if I select any of the others in the control panel and find my search doesn’t work that I can’t go back to 5.2 again without waiting for days for support to change it. Our site is very important and I can’t have hours or days of search downtime. Is there any easy and quick way I can test a higher PHP ? But having the option to change it back myself to 5.2 instantly if I find search doesn’t work ? I am using Prestashop 1.4. I realise it is an old build but I have useful modules that don’t work with newer versions of Prestashop and it does everything I need for my older aged customer base.

    1. 1and1help says:

      Hi Pat Read,

      we only offer the older PHP versions from the settings in Control Centre, if the PHP Extended Support option for that specific version is existing in your contract.

      We can book the PHP 5.2 Extended Support with a monthly fee for you if you like. Simply contact us via e-mail ( with your costumer and contract id and mention this posting here.

      Best regads,
      Michael, 1&1

      1. Pat Read says:

        Thanks. I just did a check and my website is indeed using PHP 5.2. So does this mean that will change in January unless I contact support and ask them to keep it ? As I thought I was already on Extended Support for 5.2.

        1. 1and1help says:

          The January situation is only about PHP 5.5.

          Anyway, we can only guarantee you that PHP 5.2 continues to work long term if you order the PHP 5.2 Extended Support.

          Michael, 1&1

Leave a Reply

Your email address will not be published. Required fields are marked *