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!