PHP install FAQ
1.
Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Fix: yum install libxml2 libxml2-devel

aptitude install libxml2-dev (For ubuntu)

2.
Error: configure: error: Cannot find OpenSSL’s
Fix: yum install openssl openssl-devel

3.
Error: Configure: error: Please reinstall the BZip2 distribution
Fix: yum install bzip2 bzip2-devel

4.
Error: Configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
Fix: yum install curl curl-devel (For Redhat & Fedora)

install libcurl4-gnutls-dev (For Ubuntu)

5.
Error: Configure: error: libjpeg.(also) not found.
Fix: yum -y install gd
yum -y install gd-devel
yum install libjpeg libjpeg-devel

6.
Error: Configure: error: libpng.(also) not found.
Fix: yum install libpng libpng-devel

apt-get install libpng12-dev

7) Configure: error: freetype.h not found.
Solutions :
yum install freetype-devel

8) Configure: error: Unable to locate gmp.h

Solutions :
yum install gmp-devel

9) Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!

Solutions :
yum install mysql-devel (For Redhat & Fedora)

apt-get install libmysql++-dev (For Ubuntu)

10) Configure: error: Please reinstall the ncurses distribution

Solutions :
yum install ncurses ncurses-devel

11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Solutions :
yum install unixODBC-devel

  1. --with-pspell=shared
    Error: Configure: error: Cannot find pspell

Fix: yum install pspell-devel

13) --with-mcrypt=shared
Error: configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Fix: yum install libmcrypt-devel

apt-get install libmcrypt-dev

14) Configure: error: snmp.h not found. Check your SNMP installation.

Solutions :

yum install net-snmp net-snmp-devel

15)开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients

16)configure: error: No curses/termcap library found
网上有的说法是:
–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
yum -y install ncurses-devel (for redhat)
apt-get install libncurses5-dev(for debian)

17)configure: error: cannot find output from lex; giving up
yum -y install flex

18)configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev

19)configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev

20) configure: error: Could not find pcre.h in /usr
Fix: yum install pcre-devel

21) configure: error: Could not find libpcre.(a|so) in /usr
Fix: cp /usr/lib/libpcre.a /usr/libpcre.a
Refer: http://bugs.PHP.NET/bug.php?id=1647

  1. --with-db4
    Error: configure: error: DBA: Could not find necessary header file(s).

Fix: yum install gdbm-devel db4-devel
Error: configure: error: Header contains different version
Fix: --with-libdir=lib (--libdir=/usr/lib64, which is wrong)
Refer: http://bugs.php.net/bug.php?id=40707

23) configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing
Fix: yum install libc-client-devel

  1. --enable-intl=shared
    Error: configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

25.--with-ldap=shared
Error: configure: error: Cannot find ldap.h
Fix: yum install openldap-devel
Error: configure: error: Cannot find ldap libraries in /usr/lib64.

26.--with-readline=shared
Error: configure: error: Please reinstall readline - I cannot find readline.h
Fix: yum install readline-devel

27.--with-tidy=shared
Error: configure: error: Cannot find libtidy
Fix: yum install libtidy-devel

28.--with-xsl=shared
Error: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Fix: yum install libxslt-devel

在编译PHP 5.3.6 时会遇到undefined reference to `libiconv_open‘的编译错误,以下是几种解决方法:
一、重新安装libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz cd libiconv- 1.13.1 ./configure
make
make install
二、去除 iconv模块再编译应用:
使用./configure –help查看参数,看具体应用如何去除iconv编译,例如下面是 opencc 的无 iconv的编译方法: opencc: ./configure CFLAGS=-liconv 再如php编译时,可在make时通过zend扩展参数去除libiconv的编译选项 make ZEND_EXTRA_LIBS=’-liconv’ make install
三、iconv重复安装在不同目录,造成include文件iconv.h等重复 通过 find / -name “iconv.h” 如果查找到2个以上返回结果,说明 iconv重复安装了,卸载多余的版本即可正常编译。
本人用第三种方法,确实有不同的版本,
四.
另一种解决方法为去除iconv模块也能正常编译php,如下:
編輯 Makefile 大約 77 行左右的地方:
EXTRA_LIBS = ..... -lcrypt
在最後加上 -liconv,例如:
EXTRA_LIBS = ..... -lcrypt -liconv
再运行make就可以了。

最后用第四种方法解决问题

保存下面的代码到文件sublime_imfix.c(位于~目录)

#include <gtk/gtkimcontext.h>
void gtk_im_context_set_client_window (GtkIMContext *context,
         GdkWindow    *window)
{
 GtkIMContextClass *klass;
 g_return_if_fail (GTK_IS_IM_CONTEXT (context));
 klass = GTK_IM_CONTEXT_GET_CLASS (context);
 if (klass->set_client_window)
   klass->set_client_window (context, window);
 g_object_set_data(G_OBJECT(context),"window",window);
 if(!GDK_IS_WINDOW (window))
   return;
 int width = gdk_window_get_width(window);
 int height = gdk_window_get_height(window);
 if(width != 0 && height !=0)
   gtk_im_context_focus_in(context);
}

将上一步的代码编译成共享库libsublime-imfix.so,命令

cd ~
gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC

然后将libsublime-imfix.so拷贝到sublime_text所在文件夹

修改文件/usr/bin/subl的内容

sudo gedit /usr/bin/subl

#!/bin/sh
exec /opt/sublime_text/sublime_text "$@"

修改为

#!/bin/sh
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"

此时,在命令中执行 subl 将可以使用搜狗for linux的中文输入

sudo mv libsublime-imfix.so /opt/sublime_text/

为了使用鼠标右键打开文件时能够使用中文输入,还需要修改文件sublime_text.desktop的内容。
命令

sudo gedit /usr/share/applications/sublime_text.desktop

将[Desktop Entry]中的字符串

Exec=/opt/sublime_text/sublime_text %F

修改为

Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F"

将[Desktop Action Window]中的字符串

Exec=/opt/sublime_text/sublime_text -n

修改为

Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n"

将[Desktop Action Document]中的字符串

Exec=/opt/sublime_text/sublime_text --command new_file

修改为


Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"

注意:
修改时请注意双引号"",否则会导致不能打开带有空格文件名的文件。
此处仅修改了/usr/share/applications/sublime-text.desktop,但可以正常使用了。
opt/sublime_text/目录下的sublime-text.desktop可以修改,也可不修改。

chkconfig在命令行操作时会经常用到,它可以方便地设置和查询不同运行级上的系统服务chkconfig 语法:

chkconfig [--add] [--del] [--list] [系统服务]
chkconfig [--level/levels] [等级代号] [系统服务] [on/off/reset]
等级代码为:linux系统的运行级别。linux 将操作 环境分为以下7个等级,即
0:关机
1:单用户模式(单用户、无网络)
2:无网络支持的多用户模式(多用户、无网络)
3:有网络支持的多用户模式(多用户、有网络)
4:保留,未使用
5:有网络支持有X-Window支持的多用户模式(多用户、有网络、X-Window界面)
6:重新引导系统,即重启
先用chkconfig list查询apache和mysql服务是否存在,不存在则需要手动添加。
添加apache服务项命令:
chkconfig -add httpd
添加完设置启动项:
chkconfig --level 2345 httpd on

    #先安装libmemcached https://launchpad.net/libmemcached/+download
    cd; \
    wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz; \
    tar zxvf libmemcached*; \
    cd libmemcached*; \
    ./configure; \
    make; \
    make install;
     
    #安装php的igbinary扩展 http://pecl.php.net/package/igbinary
    cd; \
    wget http://pecl.php.net/get/igbinary-1.1.1.tgz; \
    tar zxvf igbinary*; \
    cd igbinary*; \
    /usr/local/php/bin/phpize; \
    ./configure --with-php-config=/usr/local/php/bin/php-config; \
    make; \
    make install; \
    mv /usr/local/php/lib/php/extensions/*/igbinary.so /usr/local/php/lib/php/extensions/;
    vi /usr/local/php/etc/php.ini;
    #添加一行
    extension=igbinary.so
    #退出vim
     
    #安装MEMCACHED扩展正式开始
    cd; \
    wget http://pecl.php.net/get/memcached-2.1.0.tgz; \
    tar zxvf memcached*; \
    cd memcached*; \
    /usr/local/php/bin/phpize; \
    ./configure --enable-memcached-igbinary --enable-memcached-json --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir  --with-libmemcached-dir=/usr/local/libmemcached/; \
    make; \
    make install; \
    mv /usr/local/php/lib/php/extensions/*/memcached.so /usr/local/php/lib/php/extensions/;
    vi /usr/local/php/etc/php.ini;
    #添加一行
    extension=memcached.so
    #退出vim
    kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`    #重启php-fpm