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. Altium Designer 出现错误提示(警告)adding items to hidden net GND/VCC

    一般出现这个提示,不是错误. 可以取消net 网格标号 这样就不会报这个警告了. 还可以设置规则,不让它报告. 点击确定,但是再次打开工程时有得警告这个错误了.我想,还是取消NET标注.

  2. Linux shell if [ -n ] 正确使用方法

    if [ str1 = str2 ]  当两个串有相同内容.长度时为真 if [ str1 != str2 ] 当串str1和str2不等时为真 if [ -n str1 ] 当串的长度大于0时为真( ...

  3. nodejs模块——http模块

    http模块主要用于创建http server服务. 本文还用到url模块和path模块,还有fs模块.url模块用于解析url,path模块用于处理和转换文件路径. 一.简单应用 代码如下: // ...

  4. [转]ExtJs4 笔记(13) Ext.menu.Menu 菜单、Ext.draw.Component 绘图、Ext.resizer.Resizer 大小变更

    作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法律 ...

  5. Eclipse 搜索插件 instasearch

    http://marketplace.eclipse.org/content/instasearch

  6. swift三方库

    链接: Swift 有哪些优秀的第三方库? Swift 中AFNetworking 的替代方案 Alamofire Swift2.0后Alamofire的使用方法 [快速学会Swift第三方库] Al ...

  7. CentOS下OpenVPN客户端配置

    CentOS下OpenVPN客户端配置 http://liumissyou.blog.51cto.com/4828343/1762683 1,安装 yum install openvpn -y mkd ...

  8. Vue系列:如何将百度地图包装成Vue的组件

    主要分解为如下步骤: (1)在html文件中引入百度地图, <script type="text/javascript" src="http://api.map.b ...

  9. 树莓派Odroid等卡片式电脑上搭建NAS教程系列5-Samba服务器安装

    本文章首发于浩瀚先森博客,地址: http://www.guohao1206.com/2016/08/23/967.html samba时一款为了实现linux系统中的文件能在windows系统中正常 ...

  10. Redirect和Dispatcher 区别

    使用forward是服务跳转,浏览器不知道它所请求的具体资源来源,浏览器的地址栏不会变:使用redirect,服务端根据逻辑,发送一个状态码,告诉浏览器重新去请求那个地址.所以地址栏显示的是新的URL ...