site/vhost default charset (issue+walkaround)

Discussion in 'Installation/Configuration' started by jbonlinea, Nov 15, 2016.

  1. jbonlinea

    jbonlinea New Member

    Dear all
    As It's my first post here I would like to thank you for the support you've already given to me through your tuto ans posts. I'm new to IPSConfig, and quite a beginer in server administration, I'm doing my best and did quite a few search and try before posting so excuse me if this post wasn't needed

    My config is detailled at the end of the post

    I have two sites (or vhost should I say if I'm right) :
    Site1 is in php7 and needs UTF-8 --> everythnig is fine out of the box
    Site2 is in php5.6 and need ISO-8859-15 --> caracter encoding issues (php/db works)

    Q1) server charset configuration
    I checked the headers sent by the server, they contain "Content-Typetext/html; charset=UTF-8"
    then I checked all the apache conf file but I've never found any "AddCharsetDefault" directive so the default setting "Off" should be taking over
    (the only one was commented in /etc/apache2/conf-enabeled/charset.conf)
    So why my header specifies a charset, namely UTF-8 ?
    How/where can I change it server wide ?
    (it seems I missed something here)

    Q2) vhost charset configuration
    I've try to add "AddCharsetDefault ISO-8859-15" in /etc/apache2/site-enabeled/100-site2.mydomain.com.vhost
    as well as in all the damn conf file I found (while being very cautious to revert one change before doing an other)
    the result stay the same, my header specify UTF-8 ! why ?
    How/where can I change it vhost wide ?
    (again it seems I missed something)

    Q3) .htacces as walkaround (not working)
    I tried to edit the .htacces file in the root folder of my site2 using this "IndexOptions +Charset=ISO-8859-15"
    found here : http://stackoverflow.com/questions/913869/how-to-change-the-default-encoding-to-utf-8-for-apache
    the result stay the same, my header specify UTF-8 !
    Why ?
    I do not need this walkaround to work now, but it seems a usefull trick to integrate an archive site in ISO-8859 within the folder of its more modern repleacement site in UTF-8

    Q4) php header as walkaround (working!!!)
    I added at the begining of my index.php file : "<?php header('Content-Type: text/html; charset=iso-8859-15'); ?>"
    It worked !

    Q5) Ultimate question - what is the best solution ???
    what is the best way to specify that a given site of ISPConfig use a specific charset ?


    Ok I'm happy as I found a way to display correctly my mebsite, but what the fu** ?!
    I would like to understand / learn (both apache and ISPConfig) / find a long term solution

    Thank's in advance

    J.



    Extra Q) what about MySQL and my db seetings
    well, whether the "general parameter", the db and/or the table are set to "Latin1-general_ci", "UTF8_general_ci", "UTF8_unicode_ci", "UTF8mb4_general_ci" or "UTF8mb4_unicode_ci" (in phpmyadmin) the result remains the same...
    so I'm not sure what to do with that, but my day is gone so I wonder wether it is possible to have diffferent MySQL server version/settings for different vhost, like we have different php version !!!


    ps : My configuration
    Ubuntu 16.04.01 LTS - ISPConfig 3.3.1p1 - apache - mysql
    I've installed ISPConfig using the ISPConfig auto-install script (but I've read the perferct server doc as well)
    (the only issue I've encontered was also meet by Atok some days ago, see in the comments here https://www.howtoforge.com/tutorial/ispconfig-automated-install-script/)
    I've installed PHP 5.6 folowing this tuto https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/
    Then I created users (shell, ftp, db) and sites according to my needs
     
  2. Jesse Norell

    Jesse Norell Active Member

    Just guessing here, but changing your php got you a workaround - try specifying the default charset in custom php.ini settings for site2. Eg. on debian 8 php 5.6 I have:
    Code:
    # grep ^default_charset /etc/php5/fpm/php.ini
    default_charset = "UTF-8"
     
  3. jbonlinea

    jbonlinea New Member

    Hi there !
    Thank's Jesse for the tip, it works... with certain constraint
    First,
    doing a change in the php.ini file of my php5.6 install affect all my sites (ISPConfig sites) using php5.6
    It's a good walkaround if you only have one site requireing either php5.6, either ISO-8859-15.
    Bu if you have two or more sites requiering one and only one of theses server settings but not the same one (one site needs php5.6 and an other ISO-8859-59), you're screwed...

    Second,
    as I installed php 5.6 following the tuto for ubuntu 16.04 (which has php 7 as default install) the php.ini file for php 5.6 is in
    Code:
    /opt/php-5.6.25/lib/php.ini
    but that's a look at the tuto+find command solved this out

    In the end
    It seems that the best long term solution would be to be able to :
    - set a defaultcharset for a given ISPConfig site independently of the php version it usess
    or
    - set a default charset for all the files within a given folder

    I'm to much of a beginer to bring further imput but I don't get how to set a default charset for a vhost or throught the .htaccess file (tried to edit the apache .conf file during a whole day, and did few tries on .htaccess file)

    Cheers
     
  4. Jesse Norell

    Jesse Norell Active Member

    Under the website, go to Options tab (as admin, you probably don't have it showing as the client) and paste the custom php.ini setting in the textfield there and save.
     
  5. jbonlinea

    jbonlinea New Member

    Hi dude,
    Actually I found the trick yesterday eve, some hours before your post !

    It work's for all of my pages but one...
    not surewhy ? it's an old site I've basicaly upgraded to use as demo, and this pages was created from a wanewsletter page for subscription... so I don't bother I just use the php header.

    anyway awesome +++
    thank's
     

Share This Page