centos7编译php-5.6.11

[安装依赖]

yum -y install epel-release
yum groupinstall "development tools"
yum -y install mhash mhash-devel mcrypt
yum -y install zlib zlib-devel libjpeg libjpeg-devel freetype freetype-devel gd gd-devel curl curl-devel libxml2 libxml2-devel libxslt libxslt-devel libmcrypt libmcrypt-devel libc-client-devel postgresql-devel
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
[安装libiconv]
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar xvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv

make &&make install

(这个这个软件本身存在的一个Bug,通过Google,发现一个解决该问题的补丁,内容如下:
1.--- srclib/stdio.in.h.orig 2011-08-07 16:42:06.000000000 +0300
2.+++ srclib/stdio.in.h 2013-01-10 15:53:03.000000000 +0200
3.@@ -695,7 +695,9 @@
4.
7.-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
8.+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
9.+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
10.+#endif
11. #endif

PS:内容中的"+"表示新增的内容,"-"表示删除的内容!

那我们只要进行如下操作即可解决这个问题:1. 切换到srclib目录下:
1.$cd srclib
2. 修改stdio.in.h文件:
1.$vi stdio.in.h
通过搜索,定位到_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");这一行,然后在这一行的前后加上条件编译即可,修改后的内容如下:


#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
#endif
3\保存退出,然后再进行make, make install便可顺利安装^-^
)

[编译php]

wget http://php.net/distributions/php-5.6.11.tar.gz

tar xvf php-5.6.11.tar.gz

cd php-5.6.11

./configure --prefix=/usr/local/php \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--with-curl \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--with-kerberos \
--with-imap=/usr/local/php-imap \
--with-imap-ssl \
--with-pcre-regex \
--enable-exif \
--enable-mbregex \
--enable-sysvshm \
--enable-inline-optimization \
--disable-rpath \
--with-pgsql \
--enable-calendar \
--with-zlib-dir \
--enable-xmlreader \
--enable-xmlwriter \
--enable-static \
--with-xsl \
--enable-ftp \
--enable-opcache \
--disable-fileinfo

make&&make install

(如ext/standard/.libs/basic_functions.o: In function `zm_startup_basic':/usr/local/soft/php-5.6.11/ext/standard/basic_functions.c:3664: undefined reference to `zm_startup_dns'错误,可能是编译过,make clean 后再编译即可)

(./configure --prefix=/usr/local/php --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --with-pcre-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt=/usr/local/libmcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --with-zlib --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --enable-ftp --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache=no --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-fileinfo --with-imap=/usr/local/php-imap)

[添加环境变量]

export PATH=/usr/local/php/bin:$PATH

vim /etc/profile

最后一行添加

export PATH="/usr/local/php/bin:$PATH"

source /etc/profile
[复制配置文件]

cp php.ini-production /usr/local/php/etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[将 php-fpm 配置为服务]

#!/bin/bash
#
# Startup script for the PHP-FPM server.
#
# chkconfig: 345 85 15
# description: PHP is an HTML-embedded scripting language
# processname: php-fpm
# config: /usr/local/php/etc/php.ini
# Source function library.
. /etc/rc.d/init.d/functions
PHP_PATH=/usr/local
DESC="php-fpm daemon"
NAME=php-fpm
DAEMON=$PHP_PATH/php/sbin/$NAME
CONFIGFILE=$PHP_PATH/php/etc/php-fpm.conf
INI_CONFIGFILE=$PHP_PATH/php/etc/php.ini
PIDFILE=$PHP_PATH/php/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
rh_start() {
$DAEMON -y $CONFIGFILE -c $INI_CONFIGFILE || echo -n " already running"
}
rh_stop() {
kill -QUIT `cat $PIDFILE` || echo -n " not running"
}
rh_reload() {
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
rh_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
rh_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
rh_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
rh_stop
sleep 1
rh_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3
;;
esac
exit 0

chmod +x /etc/init.d/php-fpm
service php-fpm restart
chkconfig --level 35 php-fpm on

nginx.conf补上

location ~ .*\.(php|php5)?$ { 
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /var/www/blog$fastcgi_script_name;
  include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  expires 30d;
}
location ~ .*\.(js|css)?$ {
  expires 12h;
}
access_log off;

补充模块办法(以加IMAP为例):

./configure --with-php-config=/usr/local/php5/bin/php-config --with-imap=/usr/lib64 --with-imap-ssl --with-kerberos make;make install vi /etc/php.d/imap.ini extension = /usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/imap.so service php-fpm restart

转载于:https://www.cnblogs.com/phpgod/p/5568752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值