Welcome! Log In Create A New Profile

Advanced

Setting Charset on Nginx PHP virtual host

Vincent M.
July 31, 2019 11:30AM
Hello,

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

server {
        root /var/www/mywebsite.com;

....

        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:

<VirtualHost mywebsite.com:80>
....
    Header set Content-Type "text/html; charset=iso-8859-1"
</VirtualHost>

How to do the same on Nginx?

Thanks,

Vincent.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Setting Charset on Nginx PHP virtual host

Vincent M. July 31, 2019 11:30AM

Re: Setting Charset on Nginx PHP virtual host

Francis Daly August 01, 2019 04:08PM

Re: Setting Charset on Nginx PHP virtual host

Vincent M. August 02, 2019 09:12AM

Re: Setting Charset on Nginx PHP virtual host

Francis Daly August 02, 2019 11:06AM

Re: Setting Charset on Nginx PHP virtual host

Vincent M. August 04, 2019 09:12AM

Re: Setting Charset on Nginx PHP virtual host

Francis Daly August 04, 2019 05:58PM

Re: Setting Charset on Nginx PHP virtual host

Vincent M. August 05, 2019 08:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready