2011년 2월 7일 월요일

[서버운영] 서버의 인코딩(캐릭터셋) 환경 세팅 개념. encoding, charset, characterset

[출처:phpschool]
[http://blog.solapun.com/css]

1. ssh
file : ~/.bash_profile

export LANG=ko_KR.UTF-8
or
export LANG=ko_KR.EUC-KR

putty, securecrt 등의 ssh client 에서도 맞춰줘야 함.
설정하면? ls 할 때 글자 안깨짐. 끝.


2. ftp
서버설정 없음.
filezilla 에서 사이트관리자에 등록을 하면 문자셋 탭에서 UTF-8 이나 CP949 로 설정하면 됨.
설정하면? ftp 로 볼 때 글자 안깨지고, php 에서 UTF-8 로 파일명 쓸 수 있음.


3. web server (apache 등)
필요 없음. AddDefaultCharset 같은건 다 주석.


4. php
default_charset = utf-8
or
default_charset = x-windows-949


5. html
<br /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br /> or<br /> <meta http-equiv="Content-Type" content="text/html; charset=x-windows-949" /><br />
반드시 head 바로 밑에 meta
title 등 한국어가 위에 나오면 절대 안됨.


6. mysql
file: init 의 mysql 스크립트

--character-set-server=utf8
or
--character-set-server=euckr

옵션 변경
주의할 점은 처음 설치시 해야 한다는 것.
데이터가 있는데 이걸 바꾸면 다 깨짐.

mysql> show variables like 'ch%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

php 에서 접속시 mysql_query('set names utf8'); 하는 것을 추천.
my.cnf 에 character-set-client-handshake = false 하는 방법도 있는데 비추.





utf8이 짱.
http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=58038&sca=&sfl=wr_name%7C%7Csubject&stx=%BC%DB%C8%BF%C1%F8&sop=and&page=5


License : Public Domain
Written by Song Hyo-Jin (shj at xenosi.de)

0 개의 댓글:

댓글 쓰기