Installing Libiconv in Linux enables PHP to support Iconv function tutorials

Source: Internet
Author: User
Tags curl gettext soap mcrypt openssl pear sqlite


Problem:

A lamp server running on line, PHP does not support iconv functions.

Workaround:

Install LIBICONV, recompile Apache, enable PHP to support Iconv functions, implement UTF-8 and gb2312 encoded conversions.

Specific steps:

1, download Libiconv

Cd/usr/local/src

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz #下载

2. Installation Libiconv

Cd/usr/local/src

Tar zxvf libiconv-1.14.tar.gz #解压

CD libiconv-1.14 #进入安装目录

./configure--prefix=/usr/local/libiconv #配置

Make #编译

Make install #安装

3, recompile PHP

Find the PHP compilation parameters before the system

Cd/usr/local/php/bin #进入php安装目录

./php-i |more #查看php编译参数

As follows:

'--with-pdo_sqlite=shared '--enable-bcmath=shared '--enable-ftp=shared '--enable-mbstring=shared '--with-iconv =shared '--enable-sockets=shared '--enable-zip '--enable-soap=s

Hared '--with-openssl ', '--with-zlib ', '--with-curl=shared '--with-gd=shared '--with-jpeg-dir ', '--with-png-dir ' With-freetype-dir '--with-mcrypt=shared '--with-mhash=shared '--with-mysql=/ho

Me/server/mysql '--with-mysqli=/home/server/mysql/bin/mysql_config '--with-pdo-mysql=/home/server/mysql/bin/ Mysql_config '--without-pear ' '--with-libdir=lib64 '

To modify a parameter:

As follows

./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin /apxs--with-gettext=shared--with-sqlite=shared--with-pdo_sqlite=shared--enable-bcmath=shared--enable-ftp= Shared--enable-mbstring=shared--with-iconv-dir=/usr/local/libiconv--enable-sockets=shared--enable-zip-- enable-soap=shared--with-openssl--with-zlib--with-curl=shared--with-gd=shared--with-jpeg-dir-- With-freetype-dir--with-mcrypt=shared--with-mhash=shared--with-mysql=/home/server/mysql--with-mysqli=/home/ Server/mysql/bin/mysql_config--with-pdo-mysql=/home/server/mysql/bin/mysql_config--without-pear--with-libdir= Lib64

Remarks: Modify part


Cancel the original--with-iconv=shared

To be replaced by:--with-iconv-dir=/usr/local/libiconv

Remove single quotes on both sides of a parameter

Other unchanged

cd/usr/local/src/php #进入php安装包目录 (Note that PHP version should be the same as before)

./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin /apxs--with-gettext=shared--with-sqlite=shared--with-pdo_sqlite=shared--enable-bcmath=shared--enable-ftp= Shared--enable-mbstring=shared--with-iconv-dir=/usr/local/libiconv--enable-sockets=shared--enable-zip-- enable-soap=shared--with-openssl--with-zlib--with-curl=shared--with-gd=shared--with-jpeg-dir-- With-freetype-dir--with-mcrypt=shared--with-mhash=shared--with-mysql=/home/server/mysql--with-mysqli=/home/ Server/mysql/bin/mysql_config--with-pdo-mysql=/home/server/mysql/bin/mysql_config--without-pear--with-libdir= Lib64 #配置

Make #编译

Make install #安装

4, restart Apache to make the settings effective

Service httpd Restart #重启

Fault Resolution!

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.