libiconv组件安装好了可以让我们php支持iconv函数了,这个函数的作用就是字符编码强制转换了,下面和111cn小编一起来看一个Linux中安装libiconv使php支持iconv函数的例子吧。
 

问题:

线上运行的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 #重启

故障解决!

Linux下安装libiconv使php支持iconv函数的更多相关文章

  1. Linux下安装PHP的GD支持库

    Linux下安装PHP的GD支持库   1.安装 zlib  wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/zlib-1.2.3.tar.gz ...

  2. centos6.4下安装freetds使php支持mssql

    centos版本:6.4 php版本5.3.17 没有安装之前的情况:nginx+php+mysql+FPM-FCGI 接下来安装步骤如下: 1.打开http://www.freetds.org/,进 ...

  3. linux下安装或升级GCC4.8.2,以支持C++11标准[转]

    在编译kenlm的时候需要安装gcc, 然后还需要安装g++. g++安装命令:sudo apt-get install g++ ----------------------以下为网上转载内容,加上自 ...

  4. Linux下安装php环境并且配置Nginx支持php-fpm模块[www]

    Linux下安装php环境并且配置Nginx支持php-fpm模块 http://www.cnblogs.com/freeweb/p/5425554.html 5分钟搭建 nginx +php --- ...

  5. Linux下安装Apache并以mod_wsgi方式部署django站点

    源码编译方式安装Apache 首先下载Apache源码压缩包,地址为http://mirror.bit.edu.cn/apache/httpd/ 继续下载apr和apr-util压缩包,地址为http ...

  6. (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记

    Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...

  7. Nginx入门篇-基础知识与linux下安装操作

    我们要深刻理解学习NG的原理与安装方法,要切合实际结合业务需求,应用场景进行灵活使用. 一.Nginx知识简述Nginx是一个高性能的HTTP服务器和反向代理服务器,也是一个 IMAP/POP3/SM ...

  8. Ubuntu Linux下安装Oracle JDK

    from://http://blog.csdn.net/gobitan/article/details/24322561 Ubuntu Linux下安装Oracle JDK Dennis Hu 201 ...

  9. RedHat Linux 下安装、测试摄像头

    RedHat Linux 下安装.测试摄像头(全文见附件)     随着视频电话的迅速发展我相信大家一定有过在Windows 下安装摄像头的经历,然而大多数 都不支持Linux .我现以罗技摄像头为例 ...

随机推荐

  1. MT7620a openwrt barrier_breaker编译后wan口dhcp无法获得地址

    前言 我司准备使用openwrt barrier_breaker版本做二次开发.在烧入固件后发现wan口,dhcp无法获得地址.经如下修改后,mt7620a的路由器可以正常获得地址. 修改dts文件 ...

  2. POJ 1556 The Doors【最短路+线段相交】

    思路:暴力判断每个点连成的线段是否被墙挡住,构建图.求最短路. 思路很简单,但是实现比较复杂,模版一定要可靠. #include<stdio.h> #include<string.h ...

  3. python pip install mysql-connector-python

    sudo pip install mysql-connector-python 报错信息:Collecting mysql-connector-python Could not find a vers ...

  4. 在Eclipse彻底删除一个项目

    1. 先必须关闭项目 2. 再从workspace中把项目删除

  5. css中如何设置字体

    来自百度的回答: 建议使用font-family: "Microsoft YaHei";支持UTF-8和GB2312字符集. 不生效的3种情况:1.当此属性定义的是全局样式时,对于 ...

  6. 重构Web Api程序(Api Controller和Entity) 续篇(2)

    一代好的程序,是几经修改与重构出来的.有关此篇Insus.NET对前面所在修改与重构,还是没有觉得很完美简洁.特别对是存在的json文件进行修改或是删除时,我们原先是从文件读取数据,修改或是删除数据, ...

  7. Html5 Egret游戏开发 成语大挑战(九)设置界面和声音管理

    在上一篇中,简单的使用界面元素快速实现了一个游戏中的二级页面,这种直接在游戏页面上做UI的做法并不太好,原因是,UI会让游戏的压力变大,即使它是隐蔽的,如果同样的功能在其它的地方也是一样的,那么就要写 ...

  8. Linux wait函数详解

    wait和waitpid出现的原因 SIGCHLD --当子进程退出的时候,内核会向父进程SIGCHLD信号,子进程的退出是个异步事件(子进程可以在父进程运行的任何时刻终止) --子进程退出时,内核将 ...

  9. JavaScript系列:正则表达式

    function testExecResultType() { var txt = "mom and dad and baby"; var pattern = /mom (and ...

  10. WPF中的数据验证

    数据验证 WPF的Binding使得数据能够在数据源和目标之间流通,在数据流通的中间,便能够对数据做一些处理. 数据转换和数据验证便是在数据从源到目标 or 从目标到源 的时候对数据的验证和转换. V ...