Installing OPcache can improve your site’s performance by decreasing the php execution process when a script is requested. DreamHost permits a user to log into the server through secure shell with user level permissions. Since user level permissions cannot install software, the module will need to be manually compiled.
What Is OPcache?
OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
In short; It will improve php performance by skipping the read and compile steps.
The diagram below is a great visual representation. Once the php file is compile and stored in the memory, each concurrent request for that file is served from memory.
What if my files change?
When changes or updates are performed on your website, the cache will need to be reset. You can either kill the php service or reset the cache through the OPcache API. WordPress users can install the OPcache Dashboard plugin. The OPcache Dashboard plugin will handle resetting your OPcache when core, plugin, or theme files have been updated.
Isn’t OPcache only for php 5.5?
Yes… and no. OPcache comes with php 5.5 and greater. However, you can download the source code and compile it on your server if you use php 5.2 to 5.4.
Installing OPcache on DreamHost for php 5.4
For php 5.5 and greater, use the instructions below.
For the installation steps, you will need to be comfortable with (or willing to learn) command line and already have SSH setup with your shared DreamHost account. The following steps are also under the assumption your site is using php 5.4.
Create a temporary downloads directory and move into the directory.
Download the latest version of OPcache.
Unzip the source and compile.
At this point you should have an opcache.so module within the modules directory. We now need to move the opcache.so file into the php modules directory we created earlier. The opcache.so file can be anywhere on your server, but I just like to keep it within the 5.4 directory for organizational reasons.
Now we will need to create a phprc file to override default DreamHost shared php.ini settings.
Using Nano or Vim, paste the following opcache settings within the phprc file and replace the zend_extension path with the path to your opcache.so file. You can also adjust OPcache the settings to to your liking.
Clean up the downloads folder.
Installing OPcache on DreamHost for php 5.5 and greater
If you are using php 5.5 or greater, you do not need to compile the opcache module. You can simply append the opcache configuration in your phprc file to turn opcache on.
Append the following opcache configuration to your DreamHost phprc file to enable opcache.
Testing the install
To see if the module was installed correctly, you can run the following command. You should see the OPcache settings appear.
Install OPcache Dashboard
To reset the OPcache when WordPress has updates, I use the OPcache Dashboard plugin.