PHP

From ◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞
(Redirected from PHP5-FPM Configuration)
Jump to: navigation, search

The behavior of your PHP runtime (security, memory, and performance) can be configured using a php.ini file. This is the file that instructs how PHP should behave before executing your PHP application code.[1]

Basics

You can edit your php.ini file directly, however, you can share the same PHP runtime but have different settings per application. With Apache, for example, configure the server to allow access to a .htacess file with specific php declaritives to override the default php.ini settings.

short_open_tag

You can use shorthand <? instead of <?php when opening PHP code.

error_reporting

PHP has many levels of errors: E_ALL, E_NOTICE, E_WARNING, etc. This directive allows you to decide the magnitude of warning. You can convert your errors into exceptions. Doing so, you can catch and handle them. You can do this with the ErrorException class with set_error_handler() function. You can also use this with display_errors when configuring the handling of display errors in production.

Setting error_reporting to E_ALL or -1

php.ini Directives

List of php.ini directives can be seen here.[2][3]

www.conf

sudo nano /etc/php5/fpm/pool.d/www.conf

Uncomment these the following three lines, if not already.

user = www-data
group = www-data
listen.mode = 0660

php.ini

nano /etc/php5/fpm/php.ini

Change strings to match the following.

post_max_size = 50M
upload_max_filesize = 50M
memory_limit = 128M

References

  1. https://blog.appdynamics.com/php/understanding-php-ini/
  2. http://docs.hhvm.com/manual/en/ini.list.php
  3. https://documentation.cpanel.net/display/CKB/How+to+Edit+Your+php.ini+File