ppc64架构上源码编译php

发布时间:2020-07-21 23:49:14 作者:555kdie
来源:网络 阅读:915

     公司共有几十台服务器,已经架起了cacti整合nagios架构的监控系统,为了可以对比监控的数据的准确性,准备搭建zabbix的监控平台。服务器已经没多少空闲的了,就在一台IBM的机器上虚拟化的几台虚拟机,使用其中的一台虚拟机搭建zabbix监控平台。

    按照了搭建zabbix的方法,使用RPM包的方式大家爱你LAMP平台,从网上下载php-bcmath和php-mbstring RPM包安装,出现了错误的提示,提示是系统架构不同,使用命令uname -m 查看机器的硬件架构,输出的不是熟知的x86_64、x64,而是ppc64,由于使用的php-bcmath和php-mbstring都是x86_64平台下。网上在各个RPM包站点中搜查,都没有找到适合的版本,决定采用php源码包的安装,而apache和mysql保留使用系统自带的RPM包。


操作系统:RedHat 6.4

PHP版本:php-5.4.19.tar.gz

用到的软件包:fontconfig-2.4.2.tar.gz、freetype-2.3.5.tar.gz、gd-2.0.33.tar.gz、jpegsrc.v6b.tar.gz、libpng-1.2.18.tar.gz、libxml2-2.6.32.tar.gz、zlib-1.2.3.tar.gz


一、安装php前置包,支持GD库

1、安装 zlib

tar zlib-1.2.3.tar.gz

cd zlib-1.2.3

CFLAGS="-O3 -fPIC" ./configure        //一行命令,必须加前面的编译环境参数编译,不然报错

make

make install


2、安装 libpng

tar zxvf libpng-1.2.18.tar.tar

cd libpng-1.2.18

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

make

make install


3、安装jpeg

mkdir /usr/local/jpeg

mkdir /usr/local/jpeg/bin

mkdir /usr/local/jpeg/lib

mkdir /usr/local/jpeg/include

mkdir /usr/local/jpeg/man

mkdir /usr/local/jpeg/man/man1

tar zxf jpegsrc.v6b.tar.gz 

cd jpeg-6b

./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

make

make install


make可能会报错

./libtool --mode=compile gcc -O2  -I. -c ./jcapimin.c

make: ./libtool:命令未找到

make: *** [jcapimin.lo] 错误 127

解决方法:

 首先看有没有安装 及 libtool-ltdl-devel

rpm -qa | grep libtool


有网络yum源的直接用yum安装 yum -y install libtool-ltdl-devel,无网络yum源的,由于系统自带的rpm包中无这个包,使用源码安装的方式:

tar zxf libtool-2.2.6a.tar.gz 

cd libtool-2.2.6

./configure

make

make install


 然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.)


cp /usr/local/share/libtool/config/config.sub .

cp /usr/local/share/libtool/config/config.guess .


也就是把config里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件

make clean 再重新configure 

没有权限的时候先建立对应的文件夹,再次make install就行了


4、 安装 freetype

tar zxvf freetype-2.3.5.tar.gz

cd freetype-2.3.5

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

make

make install


5、安装libxml2

tar –zxvf libxml2-2.6.32.tar.gz 

cd libxml2-2.6.32

./configure

make

make install


6、安装 Fontconfig

vim /etc/profile

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

source /etc/profile

tar -zxvf fontconfig-2.4.2.tar.gz

cd fontconfig-2.4.2

./configure --with-freetype-config=/usr/local/freetype/bin/freetype-config 

make

make install


6、安装GD

tar -zxvf gd-2.0.34.tar.gz

cd gd-2.0.34

./configure --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ --with-jpeg=/usr/local/jpeg/


必须是显示是这些信息:

** Configuration summary for gd 2.0.33:


   Support for PNG library:          yes

   Support for JPEG library:         yes

   Support for Freetype 2.x library: yes

   Support for Fontconfig library:   yes

   Support for Xpm library:          no

   Support for pthreads:             yes


make

make install


make出错显示没有找到libpng.h头文件

方法:

解决办法:

vi gd_png.c

#include “png.h”

替换成:

#include “/usr/local/libpng/include/png.h”

然后再make就可以了


二、安装PHP

1、为了是源码包安装的PHP可以适应RPM包安装的apache和mysql,使用了RPM安装LAMP平台,然后获取PHP的编译参数的方法。

 yum -y install  httpd  mysql-server  mysql  php php-mysql  php-pdo 

然后启动apache和mysql,在html目录下创建一个以.php为后缀文件,写入如下内容:

<?php

phpinfo();  

?>

在相应的机器上输入http://IP地址/文件名,根据输出的PHP信息,在configuration栏复制配置信息,注意去掉但引号。根据版本支持的配置命令和自己的需要改写配置参数,由于之前已经做了修改,所以直接进行下一步。


2、安装php

yum -y install  httpd  mysql-server  mysql

tar zxf php-5.4.19.tar.gz -C /usr/src/

cd /usr/src/php-5.4.19/


php编译参数:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-openssl --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-shmop --enable-calendar --enable-xml --with-apxs2=/usr/sbin/apxs --without-mysql --without-gd --disable-dom --disable-dba --without-unixODBC --enable-pdo --disable-xmlreader --disable-xmlwriter --disable-phar --disable-fileinfo --disable-json --without-pspell --disable-wddx --without-curl --disable-posix --disable-sysvmsg --disable-sysvshm --disable-sysvsem --enable-mbstring --enable-bcmath --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd  --with-gd=/usr/local/ --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/ --enable-xmlwriter --enable-xmlreader


配置出现的错误:

./configure: line 8410: /usr/sbin/apxs: No such file or directory

yum install -y httpd-devel


configure: error: Cannot find OpenSSL's <evp.h>

yum -y install openssl-devel


onfigure: error: Please reinstall the BZip2 distribution

yum install bzip2-devel  


configure: error: Unable to locate gmp.h

yum install gmp-devel


make

make install


make时5.4版本有一个BUG:

/usr/src/php-5.4.19/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_stream_ctxfree’中:

/usr/src/php-5.4.19/ext/gd/gd_ctx.c:67: 错误:‘struct gdIOCtx’没有名为‘data’的成员

/usr/src/php-5.4.19/ext/gd/gd_ctx.c:68: 错误:‘struct gdIOCtx’没有名为‘data’的成员

/usr/src/php-5.4.19/ext/gd/gd_ctx.c:69: 错误:‘struct gdIOCtx’没有名为‘data’的成员

In file included from /usr/src/php-5.4.19/ext/gd/gd.c:103:

/usr/src/php-5.4.19/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_output_ctx’中:

/usr/src/php-5.4.19/ext/gd/gd_ctx.c:153: 错误:‘gdIOCtx’没有名为‘data’的成员

make: *** [ext/gd/gd.lo] 错误 1

修复:

vim /usr/local/include/gd_io.h 


  /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */

  int (*seek) (struct gdIOCtx *, const int);


  long (*tell) (struct gdIOCtx *);


  void (*gd_free) (struct gdIOCtx *);

  void (*data);//增加这句


}

gdIOCtx;


安装PHP后为使用方便增加这个命令:

ln –s /usr/local/php/bin/* /usr/local/bin/


3、配置apache,并启动apache、mysql

vim /etc/httpd/conf/httpd.conf

AddHandler php5-script .php

AddType text/html .php

DirectoryIndex index.php


service httpd start  

service mysqld start

chkconfig --level 35 httpd on

chkconfig --level 35 mysqld on


4、测试php

vim /var/www/html/test1.php

<?php

phpinfo();  

?>

输出php 5.4的信息,表示php 5.4能被apache调用


vim /var/www/html/test2.php

<?php

$link=mysql_connect('127.0.0.1','test','');    

if($link) echo "恭喜你,数据库连接成功啦 !!"; 

mysql_close();     

不过把127.0.0.1替换成localhost后,数据库就连接失败,没找到解决的方法。



这样LAMP平台就搭建好了,解决的RPM包安装PHP时缺少必要的主件,可以放心的安装zabbix软件了。


软件包地址:http://down.51cto.com/data/1905529


推荐阅读:
  1. Thrift 源码编译
  2. CentOS7中源码编译安装LAMP架构

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php zabbix pp

上一篇:详细到没朋友,一文帮你理清Linux 用户与用户组关系~

下一篇:exchange 2013 批量新建邮箱用户

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》