I want to run

php /path/to/artisan opcache:optimize

to build laravel cache after php7.2-fpm start or after restart. I have tried to insert it on /etc/init.d/php7.2-fpm in do_start() method but failed the code didn't execute.

please any idea? thanks

  • You are supposed to do this when you deploy a new version of your code. – Michael Hampton Sep 6 '18 at 12:46

solved by editing /lib/systemd/system/php7.2-fpm.service

i add ExecStartPost=/usr/bin/php /path/to/artisan opcache:optimize and then reload daemon

systemctl daemon-reload
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.