Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opcache preload for generic php #1

Open
susantha1995 opened this issue Mar 3, 2022 · 3 comments
Open

opcache preload for generic php #1

susantha1995 opened this issue Mar 3, 2022 · 3 comments

Comments

@susantha1995
Copy link

can you tell me a full guide tutorial for adding opcache preloader for generic PHP sites?

@elomonaco
Copy link

you could honestly reuse the class they wrote and just point it to all your vendor folder and src folder, it's just preloading the files your web app will be accessing.

@slaweallx
Copy link

slaweallx commented Nov 5, 2024

Edited...

@slaweallx
Copy link

can you tell me a full guide tutorial for adding opcache preloader for generic PHP sites?

Enable and Configure OPCache with Preloading on Cloudpanel

  1. What is OPCache?
    OPCache helps improve PHP performance by caching precompiled script bytecode in memory, avoiding the need for PHP to load and parse scripts on each request. To make OPCache even more efficient, we can use "preloading" to keep specific classes and files in memory.

  2. Install and Enable OPCache on Cloudpanel

    First, confirm if OPCache is installed:

    php -m | grep opcache
    

If not installed, install OPCache:

sudo apt update
sudo apt install php-opcache

Configure OPCache Settings

Edit the OPCache configuration file:

sudo nano /etc/php/{php_version}/fpm/conf.d/10-opcache.ini

Replace {php_version} with your PHP version (e.g., php8.1). Add or update the following settings:

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.preload=/path/to/preload.php
opcache.preload_user=www-data

Create Preloader Script

Create preload.php to specify frequently used files to be preloaded:

sudo nano /path/to/preload.php

Add your key files or classes:

```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants