Debian Jessie 8: Additional configuration of Nginx and PHP 7 FPM
Sun, 03/20/2016 - 15:41 — geek17In continuation to the article on the installation of a Nginx web server and PHP 7 FPM, we will make some changes to our basic installation.
The goal is to show you how to proceed, to allow you to edit your own settings according to your needs.
Additional configuration of PHP 7.0 FPM
Let's start with PHP 7.0 FPM configuration.
Open the PHP 7.0 configuration file.
sudo nano /etc/php/7.0/fpm/php.ini
Then we will change the variables below.
date.timezone sets the time zone of our server
upload_max_filesize and post_max_size increase to 32MB the size of a file that can be downloaded via POST in PHP.
upload_max_filesize = 32M
post_max_size = 32M
date.timezone = Europe/Paris
You can change many other variables, as you can see here http://php.net/manual/fr/ini.list.php
Additional configuration of Nginx
Now, open the Nginx configuration file.
sudo nano /etc/nginx/nginx.conf
In this file, look for the { http area that contains the variables that we want to change or add.
Remove the comment character # in front of the line gzip on; to enable html pages to be compressed by default.
The server_tokens off command; will hide the Nginx version to your visitors (better for the security of your site).
And client_max_body_size 32M; allows Nginx to upload files with a limit of 32MB (it is directly linked to the PHP modification done above)
...
http {
gzip on;
client_max_body_size 32M;
server_tokens off;
...
If you want to go further, you can have a look to this Nginx page http://nginx.org/en/docs/http/ngx_http_core_module.html
Check the changes
First, you need to restart PHP 7.0 FPM and Nginx services to enable the changes.
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
Finally, open again your phpinfo page, you will see that your new settings are active.