Home » Php » caching – Execute PHP script after php-fpm master process is restarted

caching – Execute PHP script after php-fpm master process is restarted

Posted by: admin July 12, 2020 Leave a comment

Questions:

Say I have a script to populate the PHP APC cache when PHP is restarted, the cache is empty.

Is it possible to create a mechanism to autorun some kind of script when the master php-fpm process is started?

How to&Answers:

Open php-fpm

vim /etc/init.d/php-fpm

In the file, find the start function, add your commands at the end.

start () {
    ...
    # Your commands here
}

Save and restart php-fpm

Answer:

I have one article for you please once read it, It might be helpful to you Link

Open php-frm through CMD

Ubantu sudo gedit /etc/init.d/php-fpm

You put the code under following function.

function start {
   /* 
     Your code here
   */
}