Enable Opcache On PHP7/Apache

In this post I will be showing you how to enable opcache on your Linux server. Opcache will basically cache your php scripts and significantly speed up your page load speeds. For this guide  I am using an Ubuntu virt so your php.ini location may differ from mine, other than that the process should still be the same.

Checking If Opcache Is Enabled

Lets get started by checking if its already enabled, to do this we will run the following commands to check php.ini

Check If Opcache Is Enabled

Enabling Opcache On Your Server

If you see the same result as in the screen shot above then it is currently disabled. We can enable it though by replacing ;opcache.enable=0 with opcache.enable=1, make sure you remove the semicolon as-well. To edit this file you can run the following command to open your php.ini in nano, press ctrl+x and then y to save. You may need to install nano if its not already installed or simply use another text editor if you prefer.

After editing your php.ini you will still need to enable the module and restart apache, you can do this by running the following command.

Enable Opcache

I hope you enjoyed this quick and to the point guide, please don’t forget to like/share/comment! =)

Leave a Reply

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