[虚拟机安装linux]Linux中安装libiconv使php支持iconv函数教程

更新时间:2019-12-08    来源:apache    手机版     字体:

【www.bbyears.com--apache】


问题:

线上运行的lamp服务器,php不支持iconv函数。

解决方法:

安装libiconv,重新编译apache,使php支持iconv函数,实现utf-8和gb2312编码的转换。

具体步骤:

1、下载libiconv

cd /usr/local/src

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

2、安装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、重新编译php

查找系统之前的php编译参数

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

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

如下:

"--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"

对参数进行修改:

如下

./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-png-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

备注:修改部分


取消原来的--with-iconv=shared

替换为:--with-iconv-dir=/usr/local/libiconv

取消参数两边的单引号

其它不变

cd /usr/local/src/php #进入php安装包目录(注意php版本要和之前一样)

./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-png-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、重启apache使设置生效

service httpd restart #重启

故障解决!

本文来源:http://www.bbyears.com/jiaocheng/82682.html

热门标签

更多>>

本类排行