1

I want migrate old website (php 5.6) from Debian 8.10 to Ubuntu 16.04.3 server.

The apache configuration have been exported in the new server and mysql database is hosted on another server : no change.

After migration, the accents characters from database are displayed as is : 'é'. The problem appear only for data get in database.

These characters are displayed also as is in database, but on the old website, it's correctly displayed in web browser.

Database is mariaDB 10.0.31 and the collation : latin1.

I can't touch the database and php code.

PHP / apache configurations are the same. Juste the hosted system is different. Why the characters are interpreted differently ?

I tried in vhost configuration these options : CharsetDefault UTF-8 AddDefaultCharset UTF-8 AddCharset UTF-8 .utf8

I also tried change locale : en_US.UTF-8 fr_FR.UTF-8

But no change effect...

Any idea ?

Thank you for your help !

Old configuration : PHP 5.6.30-0+deb8u1 Apache/2.4.10 Debian 8.10

New configuration : PHP 5.6.32-1+ubuntu16.04.1+deb.sury.org+2 Apache/2.4.18 Ubuntu 16.04.3

Virtual host :

    <VirtualHost *:80>
        ServerAdmin webmaster@HIDDEN.fr
        DocumentRoot /var/www-HIDDEN
        ServerName yyy.HIDDEN.fr

        ScriptAlias /cgi-bin/ /var/www/cgi-bin/

        <Directory /var/HIDDEN/>
                AllowOverride All
                Options Indexes FollowSymLinks
                Require all granted
                Order allow,deny
                allow from all
        </Directory>

        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php
                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_value include_path .
        </IfModule>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Locale on the new server :

root@ubuntu16:~# locale
LANG=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

Locale on the old server :

root@debian8:~# locale
LANG=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

But, same probleme with this value : en_US.UTF-8

  • What does the command `locale` output? – Gunnar Hjalmarsson Dec 20 '17 at 21:23
  • I test install php5-mysqlnd package on old system and the problem appear! – user5525652 Dec 21 '17 at 13:40
  • This is probably over my head. But maybe the old server has charset `ISO-8859-1`, while the default charset in apache2 is `UTF-8`. In that case you may need to set the charset to `ISO-8859-1`, ether as default for the whole server, or only when serving the pages with information from that database. – Gunnar Hjalmarsson Dec 21 '17 at 14:18
  • Ok, after read this : https://stackoverflow.com/questions/31348162/mysql-change-default-character-set-latin1-to-utf8 I put "character-set-server=utf8" in "[mysqld]" on a DB test server, and it work. But I have no idea if put this configuration on DB production server. – user5525652 Dec 21 '17 at 17:45

0 Answers0