Home WebServer PanelFastPanel How to change OPCache parameters on FASTPANEL

How to change OPCache parameters on FASTPANEL

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In the previous article, AZDIGI showed you how to integrate Opcache PHP Extension to FASTPANEL to help speed up your PHP website better.

By default, when we install Opcache PHP Extension on FASTPANEL, OPCache is only allowed to use a relatively low default parameter. In which the RAM usage level only stops at 128MB, the number of php scripts that can cache stops at 10000. And with such a limit, OPCache is easy to use up and limits its optimal capabilities.

So how to increase these parameters? Please follow the end of the article.

II. What is OPcache?

Originally called Zend Optimizer +, OPcache (introduced in PHP 5.5.0) is a powerful PHP extension built to enhance PHP performance, thus increasing overall application performance. It is available as an extension through PECL for PHP versions 5.2, 5.3 and 5.4. It works by storing precompiled script-bytecode in shared memory or RAM, thus eliminating the need for PHP to load and parse the script on each request.

Benefits OPcache brings:

  • Helps reduce %CPU usage for the server.
  • Reduce TTFB of all PHP sites on the server.
  • Increase website loading speed.

III. Change OPCache parameters on FASTPANEL

To change the OPCache parameter on FASTPANEL, we follow the following 3 steps.

Step 1: SSH into your FASTPANEL system

To change the OPCache parameters on FASTPANEL, we first need to SSH or access your VPS or server as root. If you do not know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSH, we continue with step 2 to check the current OPCache parameters.

Step 2: Check the parameters OPCache is using

To check the currently used OPCache parameter, we use the following command:

AZDIGI Tutorial
php -i | grep opcache
    

There will be a lot of configuration information displayed, but in this article, I will tweak the 3 main options and I find the most impactful performance is:

  • opcache.interned_strings_buffer: Amount of memory used to store interlaced strings in megabytes. This configuration directive is ignored in PHP < 5.3.0. But we’re using newer PHP, so we’ll need this configuration.
  • opcache.max_accelerated_files: The maximum number of scripts that OPCache can cache. The minimum value is 200. The maximum value is 100000 in PHP < 5.5.6 and 1000000 in newer versions and the default is 10000. Here I’m using PHP 7.4 so I can use high values, at most 1000000.
  • opcache.memory_consumption: The RAM size allocated to OPcache for use in Megabytes. The minimum allowed value is “8” and the default is “128”.

If you want to learn about all the configurations of OPCache, you can refer to the following link:

Below are my results when running the above command: All parameters are at the default level of OPCache.

change OPCache parameter on FASTPANEL change config

Now that we know the current OPCache parameter in use, we go to the next step to change the OPCache parameter on FASTPANEL.

Step 4: Change the OPCache parameter on FASTPANEL

To change the OPCache parameters on FASTPANEL, we access the FASTPANEL interface => select the FASTPANEL feature list as shown below:

Screen Shot 2020 09 23 at 9.39.34 AM

Then scroll down and select the PHP feature.

image 51

In this section, you select PHP Settings(1). => select the PHP version you use (2) and search with the keyword: opcache.

Screen Shot 2020 10 12 at 2.23.32 AM

Then below you will see a lot of configurations but we should still only tweak the above 3 configurations.

You select the pen 🖋 icon button behind to enter editing mode.

change OPCache parameter on FASTPANEL change config
Before changing the configuration.
change OPCache parameter on FASTPANEL change config
After changing the configuration.

Depending on the amount of RAM of your system and tweak it accordingly. For example, with my VPS, the amount of free RAM is over 3Gb, so I give the parameter opcache.memory_consumption to use 1024M ~ 1Gb of RAM, which is 8 times the original and respectively, you remember to also increase opcache.interned_strings_buffer to 8 times. Since I’m editing PHP 7.4, I’ll set opcache.max_accelerated_files to a maximum of 1000000.

Then drag to the top and select Apply to save all settings.

image 54

Please wait a moment and you will receive a success message as shown below:

image 55

So we have successfully changed the OPCache parameter on FASTPANEL.

Try again with the command php -i | grep opcache in step 3 to see unexpected results. Here is my result.

change OPCache parameter on FASTPANEL change config
The parameters are completely correct as we configured them.

IV. Summary

Hopefully, through this article, you will know how to change the OPCache parameter on FASTPANEL and how to check before and after the change. This change is meaningful for those who run many websites on a VPS with a limited CPU but more RAM.

If you find the article useful, don’t forget to rate 5 stars.

Wishing you success.

In addition, you can check out some other articles about FASTPANEL at the link below:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign