Nội dung
In this article, AZDIGI will show you how to disable OPCache on DirectAdmin. Although OPCache brings a lot of benefits, what if you may be asked by your boss or dev team to disable it? This article will be the solution for you.
I. 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.
If you want to integrate Opcache PHP Extension into DirectAdmin, you can refer to the following tutorial:
II. How to disable OPCache on DirectAdmin
To disable OPCache on DirectAdmin, you can follow these 3 steps.
Step 1: SSH into your DirectAdmin system
To disable OPCache on DirectAdmin, we first need to SSH or access your VPS/server with root privileges. If you do not know how to SSH into your VPS/Server, you can refer to the following tutorial:
After successfully SSH, we go to Step 2 to check the OPCache version in use.
Step 2: Check the current OPCache version in use
To check the current OPCache version in use, we use the following command:
php -v
Here is my result.
We continue with Step 3 to execute commands to disable OPCache on DirectAdmin.
Step 3: Commands to disable OPCache on DirectAdmin
After checking the OPCache version in step 2, we execute the following commands to disable OPCache on DirectAdmin:
cd /usr/local/directadmin/custombuild ./build update ./build set opcache no ./build php y
Explanation of the above commands:
- Command 1: Move to custombuild folder.
- Command 2: Update custombuild script.
- Command 3: Adjust OPCache usage status from yes to no.
- Command 4: Reinstall your PHP versions with the new configuration. Option y is always accepted if additional compilation packages are needed.
In this step, when using php -v
command, you will still see OPCache still exist. To disable OPCache, use the following command:
vi /usr/local/phpXX/lib/php.conf.d/10-directadmin.ini
You replace XX with the PHP version that you need to disable OPCache. For example, I only use PHP 7.3 version, I will use the command vi /usr/local/php73/lib/php.conf.d/10-directadmin.ini
to do it.
Here you just need to edit and add #
in front of the line containing the configuration where opcache.so
exists. Here are my illustrations for you to easily visualize.
You can then check again with the php -v
command and you will no longer see OPCache showing up.
So we have succeeded in disabling OPCache on DirectAdmin.
III. Summary
So AZDIGI has shown you how to disable OPCache on DirectAdmin. If you have multiple versions of PHP, then do the same to edit the configuration in step 3 . If you want the best performance for your system, don’t disable OPCache.
Hope this article will be of help to you.
Wishing you success!
See more useful articles about DirectAdmin at the following link:
If you need assistance, you can contact support in the ways below:
- Hotline 247: 028 888 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to: support@azdigi.com