php编译安装

1.基础依赖包

yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y

2.libiconv

mkdir -p /home/wcp/tools
cd /home/wcp/tools
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

 tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make  && make install
cd ../

3.php 相关扩展库的epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo 

4.安装依赖进入目录

yum -y install libmcrypt-devel mhash mcrypt
rpm -qa libmcrypt-devel mhash mcrypt

cd /home/oldboy/tools/
tar xf php-5.6.28.tar.gz
cd php-5.6.28

5.指定安装

./configure \
--prefix=/application/php-5.6.28 \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no

安装报错:

报错内容:configure: error: mcrypt.h not found. Please reinstall libmcrypt

解决方法:

yum install -y epel-release
yum install -y libmcrypt-devel
两个不能一起安装,因为CentOs6默认的yum源没有 libmcrypt-devel这个包,只能借助epel的yum源,所以先安装epel,再安装
libmcrypt

报错:

./stdio.h:1010:2: error: invalid preprocessing directive #_GL_WARN_ON_USE
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
make[2]: *** [progname.o] Error 1font
make[2]: Leaving directory `/home/chen/tools/libiconv-1.14/srclib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/chen/tools/libiconv-1.14/srclib'
make: *** [all] Error 2

解决:

编辑/home/chen/tools/libiconv-1.14/srclib下的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

6.编译

make && make install

6.1防错

ln -s /user/mysql/lib/libmysqlclient.so.18  /usr/lib64/
touch ext/phar/phar.phar
make
make install

6.2 创建软连接

ln -s /application/php-5.6.28/ /application/php

6.3配置php解析文件

cd /home/wcp/tools/php-5.6.28
cp php.ini-production /application/php/lib/php.ini

6.4 启动php-fpm

/application/php/sbin/php-fpm
lsof -i :9000
ps -ef|grep php-fpm
ls -lrt  /usr/lib64/ 


编译信息详解

./configure \
--prefix=/application/php-5.6.28 \   #指定安装位置
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \        #打开对freetype字体库的支持
--with-jpeg-dir \           #打开jpeg 图片支持
--with-png-dir \             #打开png 图片支持
--with-zlib \                  #打开zlib库的支持,用于http压缩传输
--with-libxml-dir=/usr \         #打开libxml2库的支持
--enable-xml \                  #
--disable-rpath \               #关闭额外的运行库文件
--enable-bcmath \                #打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-shmop \                  #
--enable-sysvsem \                #可以让php处理相关的ipc函数
--enable-inline-optimization \      # 优化线程
--with-curl \                         #打开curl浏览工具的支持
--enable-mbregex \                    #
--enable-fpm \                        #打开php-fpm补丁后才有这个参数,CGI方式安装启动程序
--enable-mbstring \                   #多字节多字符的支持
--with-mcrypt \                       #mcrypt算法扩展
--with-gd \                       #打开gd库的支持
--enable-gd-native-ttf \          #支持TrueType字符串函数库
--with-openssl \                   #openssl的支持,加密传输https时用到的
--with-mhash \                     #mhash算法扩展
--enable-pcntl \                   #freeTDS需要用到的,可能是链接mssql 才用到
--enable-sockets \                 #打开 sockets 支持
--with-xmlrpc \                    #打开xml-rpc的c语言 
--enable-soap \                    #
--enable-short-tags \               #
--enable-static \                   #
--with-xsl \                         #打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 
--with-fpm-user=www \                # 
--with-fpm-group=www \                # 
--enable-ftp \                       #打开ftp的支持 
--enable-opcache=no                    #



猜你喜欢

转载自blog.csdn.net/wanchaopeng/article/details/80845933
今日推荐