php7 libiconv,CentOS 7下编译libiconv
libiconv組件安裝好了可以讓我們php支持iconv函數(shù)了,這個函數(shù)的作用就是字符編碼強(qiáng)制轉(zhuǎn)換了,下面和111cn小編一起來看一個Linux中安裝libiconv使php支持iconv函數(shù)的例子吧。
問題:
線上運(yùn)行的lamp服務(wù)器,php不支持iconv函數(shù)。
解決方法:
安裝libiconv,重新編譯apache,使php支持iconv函數(shù),實(shí)現(xiàn)utf-8和gb2312編碼的轉(zhuǎn)換。
具體步驟:
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 #進(jìn)入安裝目錄
./configure –prefix=/usr/local/libiconv #配置
make #編譯
make install #安裝
3、重新編譯php
查找系統(tǒng)之前的php編譯參數(shù)
cd /usr/local/php/bin #進(jìn)入php安裝目錄
./php -i |more #查看php編譯參數(shù)
如下:
‘–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’
對參數(shù)進(jìn)行修改:
如下
./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
取消參數(shù)兩邊的單引號
其它不變
cd /usr/local/src/php #進(jìn)入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使設(shè)置生效
service httpd restart #重啟
故障解決!
學(xué)習(xí)時的痛苦是暫時的 未學(xué)到的痛苦是終生的
原創(chuàng)文章,作者:大眾源碼,如若轉(zhuǎn)載,請注明出處:https://www.dzpc.net/network-digest/789
總結(jié)
以上是生活随笔為你收集整理的php7 libiconv,CentOS 7下编译libiconv的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 其他流的使用
- 下一篇: 随机排列实现 -shuffle算法