LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 732|回复: 0

redhat as 3安装apache,php,mod_jk(集成apache,tomcat),tomcat,mysql

[复制链接]
发表于 2005-2-5 17:07:23 | 显示全部楼层 |阅读模式
这是我以前在公司安装开发环境时的日志。。。

############################################################################


                        Installation Guide v1.03
                                hantsy<hantsy@tom.com>
               

############################################################################

--------------------
Change Log
--------------------
v1.03 (2004-04-20)
Recompile php for java support. Add extra "--with-java=/opt/jdk" option when compiling php...



I.Prepare installation
----------------------
Before installation,please read the following articles.
http://www.galatea.com/flashguides/apache-tomcat-24-unix.xml
http://www.linuxaid.com.cn/articles/1/1/118578677.shtml


II.Begin installation now
-------------------------
1)install apache2.(option)
Firstly,download apache2  source code from www.apache.org...,and prepare compiling...
run terminal now...

[root@localhost ~]mkdir -p src
[root@localhost ~]cd src
[root@localhost src]tar xvf httpd-2.0.48.tar
[root@localhost src]cd httpd-2.0.48
[root@localhost httpd-2.0.48] ./configure --with-layout=Apache  --prefix=/opt/httpd --enable-module=most --enable-mods-shared=most
[root@localhost httpd-2.0.48]make &&make install

2)install php.(option)
Download php source code from php offical web site (http://www.php.net),and compile it by yourself...

[root@localhost src]tar xjvf php-4.3.4.tar.bz2
[root@localhost src]cd php-4.3.4
[root@localhost php-4.3.4]./configure --with-apxs2=/opt/httpd/bin/apxs --prefix=/opt/php --with-java=/opt/jdk

[root@localhost php-4.3.4]make&&make install

3)install jdk
Download the newest jdk form sun web site(http://java.sun.com).
*Note* please download the self-uncompressed edtion...
[root@localhost src]chmod a+x j2sdk-1_4_2_04-linux-i586.bin
[root@localhost src]./j2sdk-1_4_2_04-linux-i586.bin
[root@localhost src]mv j2sdk1.4.2_04 /opt/
[root@localhost src]ln -sf /opt/j2sdk1.4.2_04/         /opt/jdk

4)install tomcat
download tomcat *binary* code from http://jakarta.apache.org...
[root@localhost src]unzip jakarta-tomcat-4.1.30.zip
[root@localhost src]mv jakarta-tomcat-4.1.30 /opt/
[root@localhost src]ln -sf /opt/jakarta-tomcat-4.1.30/ /opt/tomcat

5)set java environment
Creat a simple shell file named "java.sh"...the content is the following...
#begin============================
JAVA_HOME=/opt/jdk
CLASSPATH=.:/opt/jdk/lib:/opt/jdk/jre/lib
PATH=$PATH:/opt/jdk/bin

export JAVA_HOME CLASSPATH PATH

CATALINA_HOME=/opt/tomcat
TOMCAT_HOME=/opt/tomcat

export CATALINA_HOME TOMCAT_HOME
#end==============================

Make sure it can be executed...
[root@localhost src]chmod a+x java.sh
Put it in the directoty /etc/profile.d/
It may be executed by system when system starting...

6)install mod_jk now....
Download the *source code* from http://www.apache.org....
[root@localhost src]unzip jakarta-tomcat-connectors-jk-1.2-src-current.zip
[root@localhost src]cd jakarta-tomcat-connectors-jk-1.2.5-src/jk/native
[root@localhost native]chmod a+x buildconf.sh
[root@localhost native]./buildconf.sh
[root@localhost native]./configure --with-apxs=/opt/httpd/bin/apxs --enable-EAPI
[root@localhost native]make && make install

III.Configuration
------------------

1)apache configuration..

Configure php module ...
After "LoadModule ..." in /opt/httpd/conf/httpd.conf
add the followning string...
#=========================================================
AddType application/x-httpd-php .php
#==========================================================   


Add the following lines to the end of the LoadModule section:  
##file section=================================
  Include /opt/tomcat/conf/auto/mod_jk.conf
##file section=====================================

Hard-code the mod_jk directives in httpd.conf:  
Add the following to the LoadModules section:  

##file section======================================
<IfModule !mod_jk.c>
  LoadModule jk_module modules/mod_jk.so
</IfModule>
##file section=====================================

Add the following to the end of httpd.conf:  

##file section=====================================
<IfModule mod_jk.c>
   JkWorkersFile "/opt/tomcat/conf/jk/workers.properties"
   JkLogFile "/opt/tomcat/logs/mod_jk.log"

   JkLogLevel debug

   JkMount /examples ajp13
   JkMount /examples/* ajp13
</IfModule>
##file section======================================

Modify the "DirectoryIndex " *add* three items "index.htm" , "index.php" ," index.jsp"
It seem likes this:
#==============================================================
DirectoryIndex index.html index.html.var index.php index.jsp index.htm
#==============================================================

*Modify* the default character set to "gb2312",it can help to display chinese by default...
#============================================
AddDefaultCharset gb2312
#===========================================



2)Tomcat configuration.

Edit the file $CATALINA_HOME/conf/server.xml

Verify that the following lines are immediately after the <Server port="8005" ...> declaration
##file section=================================
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
      modJk="/opt/httpd/modules/mod_jk.so" jkDebug="info"
      workersConfig="/opt/tomcat/conf/jk/workers.properties"
      jkLog="/opt/tomcat/logs/mod_jk.log"/>
##file section=================================

Add the following lines after the <Service name="Tomcat-Standalone"> declaration:   
##file section=================================
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
               port="8009" minProcessors="5" maxProcessors="75"
               acceptCount="10" debug="0"/>
##file section=================================

Finally, after any <Host name="localhost"> declarations, add a listener:  
##file section=================================         
<Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
                        append="true"  />
##file section=================================


Create a directory called "jk" under $CATALINA_HOME/conf
Add workers.properties to the jk directory - you can either use one you have in a Tomcat 3.x installation, or copy this one (yes, I removed all the comments):  
#file beign==============================
workers.CATALINA_HOME=/opt/tomcat/
workers.java_home=$(JAVA_HOME)
ps=/

worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp13
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.CATALINA_HOME)$(ps)lib$(ps)tomcat.jar
worker.inprocess.cmd_line=start
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)libjvm.so
worker.inprocess.stdout=$(workers.CATALINA_HOME)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.CATALINA_HOME)$(ps)logs$(ps)inprocess.stderr
#file end============================================






VI.Deploy our application now...
----------------------------------

1)Create three web directories named "myadmin" ,"SRTCRM", "SRTFCS" in /var/www/...If you new an application,
create a new directory,deploy in the newed directory....
**Note**DO NOT FORGET MODIFY /opt/httpd/conf/httpd.conf, add TAG *JkMount** for your application...



2)Edit the /opt/httpd/conf/httpd.conf,add configuration for your application...
add the following code near existed <Directory ....>
#=========section begin====================
Alias /myadmin "/var/www/myadmin"
<Directory /myadmin>
    AllowOverride All
    Options All
    Order allow,deny
    Allow from all
</Directory>
#==========section end====================

modify the mod_jk section....
between <IfModule mod_jk.c> and </IfModule>,add the following at the end....

#=======================
   JkMount /SRTCRM ajp13
   JkMount /SRTCRM/* ajp13

   JkMount /SRTFCS ajp13
   JkMount /SRTFCS/* ajp13
#========================

3)Now configure tomcat for your application...
edit $TOMCAT_HOME/conf/server.xml
add tow context...

#===============================
<Context path="/SRTCRM" docBase="/var/www/SRTCRM" debug="0"
        reloadable="true">
</Context>
<Context path="/SRTFCS" docBase="/var/www/SRTFCS" debug="0"
        reloadable="true">
</Context>
#================================

4)Configure php with mysql now...
[root@localhost ~] cd /var/www/myadmin
edit the file "config.inc.php",modify the mysql parameters (host,port,username,password)by yourself...

It is finished.

5)Install MySQL database...
Download the followning *rpm* packges from www.mysql.com...
MySQL-client-4.0.18-0.i386.rpm
MySQL-devel-4.0.18-0.i386.rpm
MySQL-server-4.0.18-0.i386.rpm
MySQL-shared-compat-4.0.18-0.i386.rpm

[root@localhost ~]cd src
[root@localhost src]rpm -Uvh MySQL*.rpm

Import data...
[root@localhost ~]mysqladmin creat ts2
[root@localhost ~]mysql ts2<data.ddl
[root@localhost ~]mysql -u root -h <serverhost>
mysql>grant all on *.* to root@'%';
mysql>flush privileges;
mysql>\q

V.Test
----------------
Start your server now...
Please start tomcat *firstly*,and start apache later...
[root@localhost ~]cd $TOMCAT_HOME/bin
[root@localhost bin]./startup.sh
[root@localhost ~]cd /opt/httpd/bin

#have a test now,if you see "Syntax OK",your configuration is successfully...
else,please reconfigure apache or tomcat...
[root@localhost bin]./apachectl -t

Start apache...
[root@localhost bin]./apachectl start

Open your browser,enter
http://serverhost/myadmin to access myadmin application..
and http://serverhost/SRTFCS to access SRTFCS application..
and http://serverhost/SRTCRM to access SRTCRM application..

Enjoy!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表