在IBM的IHS上编译PHP(redhat 5.5 64位的环境)

忙了一天终于在IBM的IHS6.1上编译成功了PHP。特别记录,以作纪念。

网络上有比较多的在IBM的IHS安装PHP的文章,但按每个步骤做,都会出现这样,或那样的问题,言归正传步入主题。

首先需要准备的软件包

  1.     php-5.4.10的源码包,这可以从http://php.net/get/php-5.3.21.tar.bz2/from/a/mirror下载.
  2. zlib-1.2.7:这也可以从官网下载。
  3. mysql-5.1.30-linux-x86_64-glibc23.tar.gz:这个到网络上搜搜应该有.
  4. gcc的版本是:
    [root@maocuhui local]# gcc --version
    gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
  5. l查看libpng是否有安装,没有就用yum安装.
    [root@maocuhui local]# yum list libpng
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Installed Packages
    libpng.i386                   2:1.2.10-7.1.el5_3.2                  installed
    libpng.x86_64                 2:1.2.10-7.1.el5_3.2                  installed
  6. 查看freeType是否安装,没有就用yum安装.
    [root@maocuhui local]# yum list freeType
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Installed Packages
    freetype.i386               2.2.1-21.el5_3                             installed
    freetype.x86_64             2.2.1-21.el5_3                             installed
  7. 查看GD是否安装
    [root@maocuhui local]# yum list GD
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Installed Packages
    gd.i386                     2.0.33-9.4.el5_4.2                           installed
    gd.x86_64                   2.0.33-9.4.el5_4.2                           installed
  8. 查看libxml2是否安装
    [root@maocuhui local]# yum list GD
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Installed Packages
    gd.i386                  2.0.33-9.4.el5_4.2  installed
    gd.x86_64                2.0.33-9.4.el5_4.2                                                installed

开始安装软件

  1. 安装mysql:
    # 将mysql-5.1.30-linux-x86_64-glibc23.tar.gz 拷贝到/usr/local目录下
    #tar zxvf mysql-5.1.30-linux-x86_64-glibc23.tar.gz //解压
    # ln -s mysql-5.1.30-linux-x86_64-glibc23 mysql //链接
    # groupadd mysql //增加组
    # useradd -g mysql mysql //增加用户
    # cd mysql //改变目录
    # scripts/mysql_install_db -user=mysql //安装
    # chown -R root . //权限
    # chown -R mysql data //权限
    # chgrp -R mysql . //权限
    # bin/mysqld_safe -user=mysql & //第一次运行
    # bin/mysqladmin -u root password XXXXXX // 改mysql 的root 密码为 XXXXXX
    # cp support-files/mysql.server /etc/rc.d/init.d/mysqld //系统启动时自动运行:
    # chkconfig -add mysqld //系统启动时自动运行:
    # /etc/rc.d/init.d/mysqld restart //测试一把
  2. 安装zlib包
    tar -xzvf zlib-1.2.7.gz.tar
    ./configure --prefix=/usr/local
    make
    make install
  3. 安装PHP,这个关键的来了.
    由于IBM的 IHS,即使在64的linux下,但文件也是32位格式的(我不知道为啥,这个折腾了很久,害我编译处理的libPHP5.so是64的).检查的方法可以这样.
    [root@maocuhui zlib-1.2.7]# file /opt/IBM/HTTPServer/bin/httpd 
    /opt/IBM/HTTPServer/bin/httpd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
    for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, 
    not stripped
    下面开始安装PHP。
    1.将PHP5.4解压缩出来.
    [root@maocuhui knowledgeroot]# cd php-5.4.10/
    #这个export很关键,表示编译处理的so是32位的,跟IHS符合,不然编译处理的so就是64位了。
    [root@maocuhui php-5.4.10]# export CFLAGS="-m32"
    # 参数解释
    #-prefix=/opt/php,表示将php安装到/opt/php目录下.
    # -with-apxs2=/opt/IBM/HTTPServer/bin/apxs,要编译的IBM的IHS。
    #-with-mysql,表示mysql参与编译,这里默认mysql的路径是从:/usr/local/mysql,
    这里就是我为什么上面安装mysql的时候将mysql安装到这个目录。
    但如果是使用yum 安装mysql正常也是可以的。就是将参数修改为:-with-mysql=/usr
    #-with-libdir=/lib64:表示在64位机器上安装,这样在寻找一些lib包的时候,就到/lib64/的目录下查找。
    不然会报很多错的。
    # -with-config-file-path=/opt/IBM/HTTPServer/conf,这个没什么好说的指向IHS的配置文件目录.
    #-enable-maintainer-zts,这个很关键,表示采用线程安装方式安装。不然IHS加载不了.
    [root@maocuhui php-5.4.10]# ./configure -prefix=/opt/php 
    -with-apxs2=/opt/IBM/HTTPServer/bin/apxs -with-mysql -with-libdir=/lib64 
     -with-config-file-path=/opt/IBM/HTTPServer/conf -enable-maintainer-zts
    #等待1,2分钟后,confiure就完了。如果中间有报一些mysql之类的错误,肯定是mysql没有安装好,接着:
    [root@maocuhui php-5.4.10]# make
    #兄弟们,等待3,4分钟吧。如果make的过程中出现错误,解决完错误后,
    千万要记住执行一下:make clean.兄弟就是没有执行这个命令就又折腾了2,3个小时.
    #make过程如果一切顺利的话,接着就:
    [root@maocuhui php-5.4.10]# make install
    #会自动将libs/libphp5.so 拷贝到 /opt/IBMIHS/modules目录下.
    #可以验证一下编译的libphp5.so是不是32位的.
    [root@maocuhui php-5.4.10]# file /opt/IBM/HTTPServer/modules/libphp5.so 
    /opt/IBM/HTTPServer/modules/libphp5.so: ELF 32-bit LSB shared object,
     Intel 80386, version 1 (SYSV), not stripped
    #然后将php.ini拷贝到/opt/IBM/HTTPServer/conf/目录下
    [root@maocuhui php-5.4.10]# cp php.ini-production /opt/IBM/HTTPServer/conf/php.ini
    #到这里安装就完成了。
    下面修改一下http.conf的配置文件
    [root@maocuhui php-5.4.10]# cd /opt/IBM/HTTPServer/conf/
    [root@maocuhui conf]# ls
    admin.conf               admin.passwd         httpd.conf.bak      ldap.prop.sample  mime.types
    admin.conf.07:11:45_058  httpd.conf           httpd.conf.default  magic             mime.types.default
    admin.conf.default       httpd.conf_20130116  httpd.conf.sample   magic.default     php.ini
    [root@maocuhui conf]# vi httpd.conf
    
    您可以将这几行添加到任何位置,但是最好是将这三行内容添加到配置文件的所有 LoadModule 语句之后:
    LoadModule php5_module modules/libphp5.so
    AddType application/x-httpd-php .php .php3 .phtml
    AddType application/x-httpd-php-source .phps
    
    保存退出.
    重启IHS:
    [root@maocuhui conf]# cd ../bin/
    [root@maocuhui bin]# ./apachectl -k restart
    [Fri Jan 18 21:07:22 2013] [warn] module php5_module i
    s already loaded, skipping
    httpd: Could not determine the server's fully qualified domain name,
     using 192.168.0.221 for ServerName
    [root@maocuhui bin]#
    OK,大功告成.

转载于:https://my.oschina.net/condy/blog/103024

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值