Enable Apache2 to support Chinese URLs under the CentOS Server

Source: Internet
Author: User
Tags centos server

Enable Apache2 to support Chinese URLs under the CentOS Server

Some customers cannot support Chinese URLs after using the system template with apache. Today, we take the system template with apache as an example to briefly describe how to make Apache2 support Chinese URLs.
Test environment: centos5.5 + apache2 + mod_encoding
Step 1: Download and decompress the file

12
wget http://www.vpsyou.com/sources/mod_encoding.zipunzip mod_encoding.zip

Step 2: Compile and install iconv_hook. Install iconv_hook before installing mod_encoding.

12345
cd mod_encoding/lib./configuremakesumake install

After completing the above operations, put the iconv_hook related so file under/usr/local/lib.
To search for the so file in the operating system, perform the following operations:
Open the/etc/ld. so. conf file and add a line pointing to the path of iconv_book, that is, "/usr/local/lib" (skip this step if any)

1
vi /etc/ld.so.conf

Join:

1
/usr/local/lib

[Esc], [:], [w], and [q] are saved and exited.
Follow these steps:

12
PATH="$PATH:/sbin"ldconfig

Step 3: Install apxs
When compiling mod_encoding, you must have apxs. httpd-devel includes the apxs tool for creating and installing extension modules. If you have installed Apache, check whether apxs exists under $ {APACHE_HOME}/bin/. If yes, skip this step and you do not need to install the package yourself. If not, you need to manually install httpd-devel.

1
apt-get install http-devel

The apache system template has been installed. The path is/usr/local/apache2/bin/apxs.
Step 4: Compile the mod_encoding Module
To the decompress directory of mod_encoding.zip, that is, mod_encoding

12
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-iconv-hook=/usr/local/includemake

Note that the apxs path is replaced with your own. If you are using our template, you do not need to change it.

1
ls -l mod_encoding.o

Check whether the mod_encoding.o file has been generated. If yes, make continues the following operations.

1
gcc -shared -o mod_encoding.so mod_encoding.o -Wc,-Wall -L/usr/local/lib -Llib -liconv_hook

Generate the mod_encoding.so file and copy it to your module storage directory, which is generally $ {APACHE_HOME}/modules /#

1
 cp mod_encoding.so /usr/local/apache2/modules/mod_encoding.so

Step 5: Configure httpd. conf

1
vi /usr/local/apache2/conf/httpd.conf

Add at the end:

1234567891011121314
LoadModule headers_module modules/mod_headers.soLoadModule encoding_module modules/mod_encoding.so<IfModule mod_headers.c>Header add MS-Author-Via "DAV"</IfModule><IfModule mod_encoding.c>  EncodingEngine    on  NormalizeUsername on  SetServerEncoding GBK  DefaultClientEncoding UTF-8 GBK GB2312  AddClientEncoding "(Microsoft .* DAV $)" UTF-8 GBK GB2312  AddClientEncoding "Microsoft .* DAV" UTF-8 GBK GB2312  AddClientEncoding "Microsoft-WebDAV*" UTF-8 GBK GB2312</IfModule>

If mod_headers.so has been loaded, you can comment it out.
Restart apache

1
service httpd restart

Test URL: http: // 76.164.225.208/ apache2supports Chinese url.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.