메뉴 건너뛰기

2014.04.29 19:58

문자셋 설정, charset

조회 수 7480 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

아파치 웹서버 설정파일에 문자셋을 지정할 수 있다.

하지만 HTML 문서등을 작성할때 문자셋을 지정하면 이 값이 다른 값보다 우선시된다.

php 설정에서도 기본 문자셋을 지정할 수 있다.


서버에서 문자셋 설정하기

 

Apache 웹서버 UTF-8 설정

httpd.conf 에 추가하면 되는데 리눅스 배포판 별로 다르다.
AddDefaultCharset UTF-8 


PHP UTF-8 설정

php.ini 에서 다음과 같이 수정 한다.

[PHP]

default_charset = "UTF-8"

output_handler = mb_output_handler


[mbstring]

mbstring.language = UTF-8

mbstring.internal_encoding = UTF-8

mbstring.http_input = auto

mbstring.http_output = UTF-8                    

mbstring.encoding_translation = On

mbstring.detect_order = auto

mbstring.substitute_character = none;


[PHP_MBSTRING]

extension=php_mbstring.dll


MySQL UTF-8 설정

my.cnf 파일을 수정한다.

[client]

default-character-set = utf8


[mysqld]

character-set-client-handshake=FALSE

init_connect="SET collation_connection = utf8_general_ci"

init_connect="SET NAMES utf8"

character-set-server = utf8 

collation-server = utf8_general_ci


[mysqldump]

default-character-set = utf8


[mysql]

default-character-set = utf8

 

코딩시 직접 문자셋 설정하기

 

HTML 설정

# HTML 파일을 UTF-8로 만들어 저장한다.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


XML 설정

# XML 파일을 UTF-8로 만들어 저장한다.

<?xml version="1.0" encoding="UTF-8" ?>

CSS 설정

# css 파일의 맨 위에 지정한다.

@charset "utf-8";


PHP 설정

# 서버에 지정된 문자셋을 무시한다.

<?php  header("Content-Type: text/html; charset=UTF-8"); ?>


Javascript 설정

# HTML 문서의 문자셋과 상관없이 인식된다.

<script type="text/javascript" src="path/file.js" charset="utf-8"></script>


상황

서버 설정 부분에 


1. httpd.conf 에서 기본언어설정안함 

# AddDefaultCharset UTF-8 


2. php.ini 에서 기본언어설정안함 

; default_charset = "iso-8859-1" 

; default_charset = "utf-8" 


3. my.cnf 에서 캐릭터셋 수정 


[client] 

#password = your_password 

default-character-set=utf8 


[mysqld] 

init_connect=SET collation_connection = utf8_general_ci 

init_connect=SET NAMES utf8 

default-character-set=utf8 

character-set-server=utf8 

collation-server=utf8_general_ci 


[mysql] 

default-character-set=utf8 

================================================== 


위 상태에서 아래 두가지 버전모두 운영이 가능합니다. 


그누보드4 UTF-8 = 한글 입출력 아무이상없음, 

그누보드4 EUC-KR = 한글 정상출력(phpmyadmin 에서만 한글이 깨짐), 


================================================== 


httpd.conf 에서 

AddDefaultCharset UTF-8 로 지정할경우는 


EUC-KR 버전은 한글 깨지는데 브라우저에서 인코딩을 지정하면 정상출력, 

새로고침하면 다시 한글깨짐. 이렇게 되더군요... 


참고하시라고 올려드립니다..

출처 :https://lael.be/116


  1. No Image 26Mar
    by
    2014/03/26 Views 10260 

    웹서버 모니터링 툴 awststs

  2. No Image 26Mar
    by
    2014/03/26 Views 8157 

    apache 컴파일시 동시 접속자 제한 변경하기

  3. No Image 26Mar
    by
    2014/03/26 Views 7536 

    yum으로 phpmyadmin 설치

  4. No Image 26Mar
    by
    2014/03/26 Views 8516 

    싱글모드 부팅 후, fstab read only 발생시

  5. No Image 26Mar
    by
    2014/03/26 Views 7622 

    긴급 스왑 메모리 추가 하기

  6. No Image 26Mar
    by
    2014/03/26 Views 8244 

    리눅스 한글 설정

  7. No Image 26Mar
    by
    2014/03/26 Views 8603 

    iconv 추가 설치

  8. No Image 26Mar
    by
    2014/03/26 Views 7587 

    apache vhost deny 설정

  9. No Image 26Mar
    by
    2014/03/26 Views 7619 

    리눅스 서버 백업 - Crontab

  10. No Image 26Mar
    by
    2014/03/26 Views 7862 

    Linux 시스템 백업과 복원

  11. No Image 26Mar
    by
    2014/03/26 Views 8019 

    리눅스서버 시간 한국 시간(한국표준시;KST)으로 변경

  12. No Image 12Apr
    by
    2014/04/12 Views 7238 

    netstat [option]

  13. No Image 23Apr
    by
    2014/04/23 Views 7776 

    리눅스 Iptables 보안정책

  14. No Image 23Apr
    by
    2014/04/23 Views 7817 

    리눅스 보안 - 시작 프로그램 수동 등록 및 서버 표준시간 설정

  15. No Image 23Apr
    by
    2014/04/23 Views 7665 

    iptables 접속 차단 스크립트

  16. No Image 23Apr
    by
    2014/04/23 Views 8220 

    리눅스 방화벽 iptables 설정

  17. No Image 29Apr
    by
    2014/04/29 Views 7200 

    find - 파일 검색

  18. No Image 29Apr
    by 조쉬
    2014/04/29 Views 7480 

    문자셋 설정, charset

  19. No Image 15May
    by
    2014/05/15 Views 7630 

    리눅스 기본보안설정(1-8)

  20. 리눅스 기본보안설정(9)

Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next
/ 12

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved