Setting Charset on Nginx PHP virtual host

Vincent M. mouseless at
Wed Jul 31 15:29:37 UTC 2019


I tried to set the Charset of a virtual host like this:

server {
         root /var/www/;


         charset iso-8859-1;
         override_charset on;


         location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
                 fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                 charset iso-8859-1;
                 override_charset on;


I have specified charset and overried_charset on both server and 
location and yet, it was still sending headers in UTF-8.

I had to modify the php.ini file from /etc/php/7.2/fpm/php.ini to 
specify in it default_charset = "iso-8859-1".

But I would like to let my php set to UTF-8 and specify on Nginx only 
for only one virtual host iso-8859-1.

On Apache we can do:

     Header set Content-Type "text/html; charset=iso-8859-1"

How to do the same on Nginx?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list