Minify在Apache+Tomcat环境的部署–Linux+IHS篇

一、建立本地的Repository
1、在配置器IHS上挂载redhat光盘, 并建立符号连接,
ln -s /media/RHEL_5.4 x86_64 DVD/ /root/rhel-dvd
2、修改yum的源信息
cd /etc/yum.repos.d/
mv rhel-debuginfo.repo rhel-debuginfo.repo.bak
vi rhel-iso.repo
[base]
name=iso
baseurl=file:///root/rhel-dvd/Server
gpgcheck=0

3、清除yum缓存
yum clean all

二、安装PHP
使用yum安装PHP,生成的libphp5.so无法在IHS中无法使用,必须使用源代码编译

安装PHP源代码安装需要的包
yum -y install gcc glibc-devel zlib zlib-devel libxml2 libxml2-devel libpng freetype gd

下载PHP源代码,http://www.php.net/get/php-5.4.16.tar.gz/from/tw1.php.net/mirror
cd /root
tar -xvf php-5.4.16.tar.gz

从源代码编译安装
cd php-5.4.16
# 指定编译PHP为32位版本,与IHS的版本保持一致
export CFLAGS="-m32"
./configure -prefix=/opt/php -with-apxs2=/opt/IBM/HTTPServer/bin/apxs -with-libdir=/lib64 -with-config-file-path=/opt/IBM/HTTPServer/conf -enable-maintainer-zts
make
make install

三、配置IBM HTTP Server
1、查看IHS的版本(IBM的文档中已经声明只为Solaris x64和HP-UX for Itanium环境提供了64位程序)
./apachectl -V
Server version: IBM_HTTP_Server/6.1.0.33 Apache/2.0.47
Server built: May 24 2010 13:33:20
Build level: IHS60/webIHS1021.02
Server's Module Magic Number: 20020903:4
Architecture: 32-bit

2、修改/opt/IBM/HTTPServer/conf/httpd.conf,使IHS中可以使用PHP
cp /opt/IBM/HTTPServer/conf/httpd.conf{,.bak}
#Added by adam, 2013-06-07, for Minify
# 源代码安装PHP,并制定apahce文件夹后,会自动增加下面的加载语句
#LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "/etc"
# 修改文件夹默认打开文件
DirectoryIndex index.html index.php

3、启用mod_rewrite模块
LoadModule rewrite_module modules/mod_rewrite.so
首先找到:
<Directory "/opt/IBM/HTTPServer/htdocs/en_US">
找到AllowOverride语句,按下面的方法修改
# changed by xam, 2013-06-09, for Minify
# AllowOverride None
AllowOverride All

4、检查IHS语法
/opt/IBM/HTTPServer/bin/apachectl -t
或者
/opt/IBM/HTTPServer/bin/apachectl configtest
如果没有错误重启IHS
/opt/IBM/HTTPServer/bin/apachectl restart

5、验证PHP安装是否成功
echo "<?php phpinfo(); ?>" > /opt/IBM/HTTPServer/htdocs/en_US/phpinfo.php
然后在浏览器中打开localhost/phpinfo.php,如果能正常显示php的版本等信息表示PHP环境设置成功。

6、安装Minify
把min文件放到/opt/IBM/HTTPServer/htdocs/en_US

7、将WAS下发布应用的war包复制到Apache的DocumentRoot文件夹下,并修改名称,与应用发布的上下文根保持一致。

注:如果发现httpd无法加载libphp5.php模块,出现下面的错误的话
cannot restore segment prot after reloc: Permission denied
原因是启用SeLiunx,需要下面的执行,或取消SeLiunx
sudo chcon -t texrel_shlib_t /etc/httpd/modules/libphp5.so

Comments are closed.