編譯安裝PHP 遇到問題解決方法

環境:centos 6.4  X64 最小化安裝

php版本:

PHP 5.5.3 (cli) (built: Sep  3 2013 14:05:33)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies


yum 安裝

rpm -Uvh http://mirror.bjtu.edu.cn/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi install php php-*

yum --enablerepo=remi install mysql*

http://mirror.bjtu.edu.cn/fedora-epel/6/x86_64/

http://rpms.famillecollet.com/enterprise/


編譯安裝

 

安裝前.先安裝些軟件和庫文件

yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

 

下載PHP 源碼包

cd /app/download

wget http://219.239.26.20/download/50550151/73687443/3/gz/48/187/1377323886384_955/php-5.5.3.tar.gz

tar zxf php-5.5.3.tar.gz

 

編譯安裝PHP

cd /app/download/php-5.5.3

./configure --prefix=/apps/php --enable-fpm  --with-mcrypt=/usr/libmcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf  --enable-pdo --with-pdo-mysql --with-gettext --with-curl --with-pdo-mysql --enable-sockets --enable-bcmath --enable-xml --with-bz2 --enable-zip  --with-freetype-dir=/usr/include/freetype2/freetype


運行之後遇到的問題:

error 1

checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.

(看提示就明白 是一個lib庫沒裝  先用 yum search 名字 看是否能搜到名字 ,找到名字後 把軟件包 開發包裝上)

解決辦法

yum install libxml2-devel.x86_64

error 2

checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

這是ssl沒裝

解決辦法

yum  install  openssl.x86_64 openssl-devel.x86_64 -y

error 3

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

這是bzip2軟件包沒有安裝

解決辦法

yum install bzip2-devel.x86_64 -y

error 4

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

curl和curl庫文件沒有安裝

解決辦法

yum install libcurl.x86_64 libcurl-devel.x86_64 -y

error 5

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found

GD庫沒有安裝

解決辦法

yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

error 6

checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

libmcrypt庫沒有安裝 ,要是不能用yun安裝的話  使用下面方法

rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum clean all

yum install libmcrypt libmcrypt-devel mcrypt mhash

(編譯安裝  ./configure --piefix=/usr/local/libmcrypt   make && make install)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

要是錯誤裏面含有mysql的  那是mysql-devel 沒有安裝

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

出現

Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c

+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE.  By continuing this installation |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec

config.status: creating main/build-defs.h

config.status: creating scripts/phpize

config.status: creating scripts/man1/phpize.1

config.status: creating scripts/php-config

config.status: creating scripts/man1/php-config.1

config.status: creating sapi/cli/php.1

config.status: creating sapi/fpm/php-fpm.conf

config.status: creating sapi/fpm/init.d.php-fpm

config.status: creating sapi/fpm/php-fpm.8

config.status: creating sapi/fpm/status.html

config.status: creating main/php_config.h

config.status: executing default commands

表示編譯成功

 

安裝PHP

make  && make install

 

到php的解壓目錄 找出php.ini-production 複製到 /app/php/lib/ 下 文件名改成php.ini

cp /root/php-5.5.3/php.ini-production /app/php/bin/php.ini


[創建並修改php-fpm的配置文件]

cp /app/php/etc/php-fpm.conf.default    /app/php/etc/php-fpm.conf

修改內容:

1 pid = run/php-fpm.pid
2 error_log = log/php-fpm.log
3 log_level = error
4 emergency_restart_interval = 3d
5 user = www
6 group = www
7 listen = 127.0.0.1:9000

 

[創建並添加php-fpm開機啓動服務腳本]

vim /etc/init.d/php-fpm

#!/bin/sh
#chkconfig: - 85 15
#description: php-fpm is PHP FastCGI Process Manage.
#processname:php-fpm
### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/app/php
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/log/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
    try=0
    while test $try -lt 35 ; do
        case "$1" in
            'created')
            if [ -f "$2" ] ; then
                try=''
                break
            fi
            ;;
            'removed')
            if [ ! -f "$2" ] ; then
                try=''
                break
            fi
            ;;
        esac
        echo -n .
        try=`expr $try + 1`
        sleep 1
    done
}
case "$1" in
    start)
        echo -n "Starting php-fpm "
        $php_fpm_BIN $php_opts
        if [ "$?" != 0 ] ; then
            echo " failed"
            exit 1
        fi
        wait_for_pid created $php_fpm_PID
        if [ -n "$try" ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
    ;;
    stop)
        echo -n "Gracefully shutting down php-fpm "
        if [ ! -r $php_fpm_PID ] ; then
            exit 1
        fi
        kill -QUIT `cat $php_fpm_PID`
        wait_for_pid removed $php_fpm_PID
        if [ -n "$try" ] ; then
            echo " failed. Use force-quit"
            exit 1
        else
            echo " done"
        fi
    ;;
    force-quit)
        echo -n "Terminating php-fpm "
        if [ ! -r $php_fpm_PID ] ; then
            echo "warning, no pid file found - php-fpm is not running ?"
            exit 1
        fi
        kill -TERM `cat $php_fpm_PID`
        wait_for_pid removed $php_fpm_PID
        if [ -n "$try" ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    reload)
        echo -n "Reload service php-fpm "
        if [ ! -r $php_fpm_PID ] ; then
            echo "warning, no pid file found - php-fpm is not running ?"
            exit 1
        fi
        kill -USR2 `cat $php_fpm_PID`
        echo " done"
    ;;
    *)
        echo "Usage: $0 {start|stop|force-quit|restart|reload}"
        exit 1
    ;;
esac

 

# chmod 755 /etc/init.d/php-fpm
# chkconfig --add php-fpm           添加 PHP 爲系統服務,並設置爲開機自動啓動
# chkconfig php-fpm on
# chown -R www:www /usr/local/php   給PHP相關文件目錄設置權限

[手動啓動 PHP 命令]
# service php-fpm start

 

 

完成..

發佈了16 篇原創文章 · 獲贊 0 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章