Php enable OPcache Ubuntu helps to increase the speed of WordPress and PHP-based applications
Bobcares answers all questions no matter the size, as part of our server management support
Let us take a look at Enabling and configuring Php OPcache on Ubuntu.
Enabling Php Opcache on ubuntu
OPcache is a PHP interpreter Apache module. It improves performance by storing precompiled scripts in shared memory. It is commonly used to improve the performance of WordPress and PHP-based apps. The use of OPcache eliminates the need for PHP to load and parse scripts on each request.
To begin with, Php enables OPcache ubuntu, to establish an SSH connection to the server. Use the following command to open the PHP configuration file. This is the first step in enabling PHP OPcache on Ubuntu.
If the Apache module is used to interpret PHP:
$ sudo nano /etc/php/7.4/apache2/php.ini
If PHP is being interpreted by PHP-FPM or NGINX:
$ sudo nano /etc/php/7.4/fpm/php.ini
To enable the use of OPcache, simply enable the related item by changing the following line:
;opcache.enable=0
with the code gievn below
opcache.enable=1
The user must remove the; initial if it is present. And, the OPache will already be enabled at this point when restarting the web server:
Apache
$ sudo service apache2 restart
PHP-FPM / NGINX:
$ sudo service nginx restart
Create the phpinfo.php file in the folder containing the website and add the following code there to verify that OPcache is functioning properly now.
After that, save the document and open it in a browser. The presence of the OPcache section, as seen in this image, indicates that OPcache is operational.
image
RAM memory to use for Php enable OPcache on ubuntu
In this instance, the user must find the ideal balance between the RAM memory that OPCache will use and the desired speed. Since OPCache also saves the infrequently used instructions, an expanded memory doesn’t always translate into an actual performance improvement. The allocated memory will be wasted as a result, with no improvement in performance.
Note that for general use, it is advised to alter the default value (64 MegaBytes).
;opcache.memory_consumption=64
as follows, into 128 MegaBytes opcache.memory_consumption=128
. The user must then increase this value by confirming the performance of the outcome.
The number of scripts to be stored
The user can specify the number of scripts to be stored in the cache in addition to the memory that is available through OPcache. Normally, this value can be left as default (2000). However, if the user’s application’s hit rate is below 100%, the user can attempt to raise it in accordance with their needs by uncommenting the following line:
;opcache.max_accelerated_files=2000
and boost the value in the following way:
opcache.max_accelerated_files=3000
The frequency of updates
The stored scripts are periodically checked for updates by OPcache. The following instruction can be changed to determine the assessment period: ;opcache_revalidate_freq = 2
, as well as the default setting (in seconds): opcache_revalidate_freq = 100
Applying changes
Restart the webserver to confirm the changes.
Apache: $ sudo service apache2 restart
NGINX: $ sudo service nginx restart
OPcache will then begin to save user scripts. This is the final step in enabling php OPcache in Ubuntu.
[Need assistance with similar queries? We are here to help]
Conclusion
To conclude it is extremely to Php enable OPcache in Ubuntu. A user can easily manage and overview the OPache and its storage usage process easily.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments