우분투 아파치 기본캐릭터셋 UTF-8 설정

  다른 뜻에 대해서는 CentOS 아파치 기본캐릭터셋 UTF-8 설정 문서를 참조하십시오.
아파치 기본캐릭터셋 UTF-8 설정
아파치 AddDefaultCharset UTF-8

1 확인[ | ]

실제 동작 확인
root@zetawiki:~# echo hello > /var/www/html/greet.html
root@zetawiki:~# curl -s -I http://localhost/greet.html
HTTP/1.1 200 OK
Date: Fri, 02 Oct 2015 06:35:15 GMT
Server: Apache
Last-Modified: Fri, 02 Oct 2015 06:35:07 GMT
ETag: "6-521195d548626"
Accept-Ranges: bytes
Content-Length: 6
Content-Type: text/html
→ 헤더에 캐릭터셋 정보 없음
설정 파일 확인
root@zetawiki:~# grep DefaultCharset /etc/apache2/conf-enabled/charset.conf
# Read the documentation before enabling AddDefaultCharset.
#AddDefaultCharset UTF-8
→ 주석처리되어 있음

2 charset.conf 수정[ | ]

  • /etc/apache2/conf-enabled/charset.conf 파일에 있는 UTF-8 설정 주석 해제
root@zetawiki:~# vi /etc/apache2/conf-enabled/charset.conf
# Read the documentation before enabling AddDefaultCharset.
# In general, it is only a good idea if you know that all your files
# have this encoding. It will override any encoding given in the files
# in meta http-equiv or xml encoding tags.

AddDefaultCharset UTF-8

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

3 아파치 재시작[ | ]

root@zetawiki:~# /etc/init.d/apache2 restart
 * Restarting web server apache2                                                               [ OK ]

4 확인 2[ | ]

root@zetawiki:~# curl -s -I http://localhost/greet.html
HTTP/1.1 200 OK
Date: Fri, 02 Oct 2015 06:44:45 GMT
Server: Apache
Last-Modified: Fri, 02 Oct 2015 06:35:07 GMT
ETag: "6-521195d548626"
Accept-Ranges: bytes
Content-Length: 6
Content-Type: text/html; charset=UTF-8
→ 캐릭터셋이 UTF-8로 나옴

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}