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
sudo grep opcache.enable ./php.ini
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.
sudo nano php.ini
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.
sudo phpenmod opcache && service apache2 restart && echo Success!
I hope you enjoyed this quick and to the point guide, please don’t forget to like/share/comment! =)