Installing Opcache in Ubuntu 20.04 for Apache and Nginx
The guide below describes how to install Opcache on Ubuntu 20.04 with Apache or Nginx web server installed
We will do everything with the console in a few seconds.
We log into the console and release packages:
Sinstallation method for Apache
1 | apt-get update |
The next step is to install Opcache:
1 | apt-get install php-opcache -y |
The guide below describes how to install Opcache on Ubuntu
edit file
1 | nano /etc/php/7.4/apache2/php.ini |
and add at the end
1 2 3 4 | opcache.enable=1 opcache.memory_consumption=128 opcache.max_accelerated_files=3000 opcache.revalidate_freq=200 |
We are reloading the Apache server
1 | systemctl restart apache2 |
How to install Nginx
We update the repository
1 | apt-get update |
We install the opcache package
1 | apt-get install php-opcache php-fpm -y |
We're editing php.ini
1 | nano /etc/php/7.4/fpm/php.ini |
We add at the end:
1 2 3 4 | opcache.enable=1 opcache.memory_consumption=128 opcache.max_accelerated_files=3000 opcache.revalidate_freq=200 |
We restart the service:
1 | systemctl restart nginx |
1 | systemctl restart php7.4-fpm |