Skip to content

Instantly share code, notes, and snippets.

@danielnunez
Forked from WillSquire/opcache_install.md
Created April 1, 2024 23:53
Show Gist options
  • Select an option

  • Save danielnunez/8682d4bafd7f7c19d77d8c3c34b74f6f to your computer and use it in GitHub Desktop.

Select an option

Save danielnunez/8682d4bafd7f7c19d77d8c3c34b74f6f to your computer and use it in GitHub Desktop.

Revisions

  1. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```

    The following can also be set, but in applications that use code comments as executable code (i.e. symfony's annotation) this will cause problems as it will strip comment out of the pre-compiled byte code:
    ```
    opcache.save_comments=0
    opcache.load_comments=0
  2. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,5 @@ sudo apachectl graceful
    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
    - OpCache information - http://www.sitepoint.com/understanding-opcache/
    - OpCache config suggestions: https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
    - OpCache config suggestions: https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
    - OpCache troubleshooting: https://tideways.io/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises
  3. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,11 @@ opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```

    ```
    opcache.save_comments=0
    opcache.load_comments=0
    ```

    `opcache.max_accelerated_files` should be higher than the amount of PHP files that are going to be cached. Fine tune this by counting the number of `.php` files in your project directory with (note the path used here is the default Apache DocumentRoot path, change as needed):
    ```
    find /usr/local/www/apache24/data -iname *.php|wc -l
    @@ -41,6 +46,11 @@ Check the status of OpCache with:
    php -r 'var_dump(opcache_get_status(false));'
    ```

    Restart Apache:
    ```
    sudo apachectl graceful
    ```

    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
    - OpCache information - http://www.sitepoint.com/understanding-opcache/
  4. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -43,4 +43,5 @@ php -r 'var_dump(opcache_get_status(false));'

    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
    - OpCache information - http://www.sitepoint.com/understanding-opcache/
    - OpCache config suggestions: https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
  5. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,7 @@ opcache.enable_cli=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=4000
    opcache.use_cwd=1
    opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```
  6. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -41,4 +41,5 @@ php -r 'var_dump(opcache_get_status(false));'
    ```

    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
    - OpCache config suggestions: https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
  7. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,11 @@ opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```

    `opcache.max_accelerated_files` should be higher than the amount of PHP files that are going to be cached. Fine tune this by counting the number of `.php` files in your project directory with (note the path used here is the default Apache DocumentRoot path, change as needed):
    ```
    find /usr/local/www/apache24/data -iname *.php|wc -l
    ```

    Check the OpCache running configuration in the command line with:
    ```
    php -r 'var_dump(opcache_get_configuration());'
  8. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -25,10 +25,15 @@ opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```

    Check the OpCache running configuration in the command line with (note `php -r 'var_dump(opcache_get_status());'` can be used to check if OpCache is running, but results in CLI are unreliable):
    Check the OpCache running configuration in the command line with:
    ```
    php -r 'var_dump(opcache_get_configuration());'
    ```

    Check the status of OpCache with:
    ```
    php -r 'var_dump(opcache_get_status(false));'
    ```

    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
  9. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 21 additions and 1 deletion.
    22 changes: 21 additions & 1 deletion opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,34 @@
    OpCache
    =======
    Installation
    ------------
    Install OpCache on FreeBSD with (note `56` resembles the current PHP version 5.6):
    ```
    cd /usr/ports/www/php56-opcache && sudo make config-recursive install distclean
    ```

    Configuration
    -------------
    Open up `php.ini` to configure OpCache settings:
    ```
    sudo ee /usr/local/etc/php.ini
    ```

    Find and uncomment the following directives (by removing the `;` at the front of the directive's line), then set their values to the required value:
    ```
    opcache.enable=1
    opcache.enable_cli=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=4000
    opcache.revalidate_freq=60
    opcache.fast_shutdown=1
    ```

    Check the OpCache running configuration in the command line with (note `php -r 'var_dump(opcache_get_status());'` can be used to check if OpCache is running, but results in CLI are unreliable):
    ```
    php -r 'var_dump(opcache_get_configuration());'
    ```
    ```

    ###References
    - PHP's recommended OpCache settings: http://php.net/manual/en/opcache.installation.php
  10. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,11 @@ Install OpCache on FreeBSD with (note `56` resembles the current PHP version 5.6
    cd /usr/ports/www/php56-opcache && sudo make config-recursive install distclean
    ```

    Open up `php.ini` to configure OpCache settings:
    ```
    sudo ee /usr/local/etc/php.ini
    ```

    Check the OpCache running configuration in the command line with (note `php -r 'var_dump(opcache_get_status());'` can be used to check if OpCache is running, but results in CLI are unreliable):
    ```
    php -r 'var_dump(opcache_get_configuration());'
  11. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    Install OpCache on FreeBSD with (note `56` resembles the current PHP version 5.6):
    ```
    cd /usr/ports/www/php56-opcache && sudo make config-recursive install distclean
    ```

    Check the OpCache running configuration in the command line with (note `php -r 'var_dump(opcache_get_status());'` can be used to check if OpCache is running, but results in CLI are unreliable):
    ```
  12. @WillSquire WillSquire revised this gist Apr 11, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@

    // Check if OpCache is running in the command line with:
    Check the OpCache running configuration in the command line with (note `php -r 'var_dump(opcache_get_status());'` can be used to check if OpCache is running, but results in CLI are unreliable):
    ```
    php -r 'var_dump(opcache_get_status());'
    php -r 'var_dump(opcache_get_configuration());'
    ```
  13. @WillSquire WillSquire created this gist Apr 11, 2016.
    5 changes: 5 additions & 0 deletions opcache_install.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@

    // Check if OpCache is running in the command line with:
    ```
    php -r 'var_dump(opcache_get_status());'
    ```