Home >Operation and Maintenance >CentOS >How to solve garbled characters in apache environment under centos

How to solve garbled characters in apache environment under centos

王林
王林Original
2020-03-26 14:57:332950browse

How to solve garbled characters in apache environment under centos

Problem description:

When using the Apache server to install the GBK-encoded program in the CentOS system, garbled characters appear.

Analysis:

This is mainly because the character encoding of the Apache server installed by default is UTF-8. If there is no forced encoding in the GBK program, garbled characters will be generated.

(Recommended tutorial: centos tutorial)

Solution:

1. Open the Apache configuration file httpd.conf, such as / by default etc/httpd/conf/httpd.conf

# vi /etc/httpd/conf/httpd.conf

2. Find the AddDefaultCharset configuration item

AddDefaultCharset UTF-8

3. Modify the AddDefaultCharset configuration and turn off the configuration characters, as follows:

AddDefaultCharset Off

4. At the same time, you can also set the default encoding of Apache to GB2312, as follows:

AddDefaultCharset GB2312

Recommended related video tutorials: linux video tutorial

The above is the detailed content of How to solve garbled characters in apache environment under centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn