• 一步一步教你如何在linux下配置apache+tomcat(转)


    一步一步教你如何在linux下配置apache+tomcat
     

    一.安装前准备。

    1.   所有组件都安装到/usr/local/e789目录下

    2.   解压缩命令:tar —vxzf 文件名(.tar 或 .tar.gz)

    3.   复制命令:cp 文件名 或cp —Rf 文件夹名

    4.   删除命令:rm 文件名 或 rm —Rf 文件夹名

    5.   编辑文件命令:vi 文件名 :q!不保存退出 :wq 保存退出

    二.安装jdk 1.4.2

    1.   执行二进制文件 ./j2sdk-1_4_2-linux-i586.bin 解压生成j2sdk1.4.2文件夹

    2.   将文件夹改名为jdk142

    3.   配置文件(设置环境变量):/etc/profile

                   JAVA_HOME=/usr/local/e789/jdk142

                   export JAVA_HOME

                   TOMCAT_HOME=/usr/local/e789/tomcat4129

                   export TOMCAT_HOME

                   CATALINA_HOME=/usr/local/e789/tomcat4129

                   export CATALINA_HOME

                   CATALINA_BASE=/usr/local/e789/tomcat4129

                   export CATALINA_BASE      

                   APACHE_HOME=/usr/local/e789/apache2048

                   export APACHE_HOME

                   HTTPD_HOME=/usr/local/e789/apache2048

                   export HTTPD_HOME

                   CLASSPATH=/usr/local/e789/jdk142/lib:/usr/local/e789/jdk142/jre/lib

                   export CLASSPATH

                   PATH=$PAHT:/usr/local/e789/jdk142/bin:/usr/local/e789/jdk142/jre/bin

    三.安装tomcat 4.1.29

    1.   解压缩文件jakarta-tomcat-4.1.29.tar.gz

    2.   将解压后的文件夹改名为tomcat4129

    3.   启动(停止)命令:./bin/startup.sh (shutdown.sh)

    4.   测试tomcat:在ie里输入http://(ip):8080,如果有内容出现,则说明安装成功

    四.安装配置apache 2.0.48

    1.   解压缩文件httpd-2.0.48.tar.gz

    2.   安装:①./configure --with-layout=Apache

                            --prefix=/usr/local/e789/apache2048

                            --enable-module=so

                            --enable-mods-shared=most

                            --with-mpm=prefork

           

                           ②make   

                           ③make install

    3.   配置文件:/usr/local/e789/apache2048/conf/httpd.conf

    DocumentRoot "/usr/local/e789/tomcat4129/webapps"(将发布的目录指向tomcat的webapps目录)

                   <Directory "/usr/local/tomcat4129/webapps">

    4.   启动文件:./bin/httpd -k start (restart/stop)

    5.   测试apache:在ie里输入http://(ip),如果有内容出现,则说明安装成功

    五.安装jk2

    1.   解压缩文件jakarta-tomcat-connectors-jk2-src-current.tar.gz

    2.   将解压后的文件夹改名为jk202

    3.   执行buildconf.sh文件。

    4.   执行configure文件:

    ①./jk/native2/configure --with-apxs2=/usr/local/e789/apache2048/bin/apxs --enable-EAPI

    --with-tomcat41=/usr/local/e789/tomcat4129

              ②make

              ③make install(我做的时候,这个命令不好用)

    六.整和apache和tomcat

    1.   把jkjni.so和mod_jk2.so文件复制到apache的modules目录下

    cp /usr/local/e789/jk202/jk/build/jk2/apache2/*.so /usr/local/e789/apache2048/modules

    2.   把jk2.properties文件复制到tomcat的conf目录下

                cp /usr/local/e789/jk202/jk/conf/jk2.properties /usr/local/e789/tomcat4129/conf

    3.   把worker2.properties文件复制到apache的conf目录下

    cp /usr/local/e789/jk202/jk/conf/worker2.properties /usr/local/e789/apache2048/conf

    4.   编辑jk2.properties文件

    vi /usr/local/tomcat/conf/jk2.properties

                   # list of needed handlers.

                   handler.list=channelSocket,request

                   # Override the default port for the channelSocket

            channelSocket.port=8009

    5.   编辑apache的http.conf

    vi /usr/local/apache/conf/http.conf

                   LoadModule jk2_module modules/mod_jk2.so

                   DirectoryIndex index.html index.html.var index.jsp

    6.   编辑apache/conf/workers2.properties文件

    # only at beginnin. In production uncomment it out
    [logger.apache2]
    level=DEBUG
      
    [shm]
    file=/usr/local/apache/logs/jk2.shm
    size=1048576
      
    # Example socket channel, override port and host.
    [channel.socket:localhost:8009]
    port=8009
    host=127.0.0.1
      
    # define the worker
    [ajp13:localhost:8009]
    channel=channel.socket:localhost:8009
      
    # Uri mapping
    [uri:*.jsp]
    worker=ajp13:localhost:8009
    (负责把*.jsp的文件通过ajp13发送到tomcat处理)  

         7.编辑tomcat的server.xml

    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
         <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"

    port="8009" minProcessors="5" maxProcessors="75"  
         enableLookups="true" redirectPort="8443"

    acceptCount="10" debug="0" connectionTimeout="0"

    useURIValidationHack="false"
         protocolHandlerClassName="org.apache.jk.server.JKCoyoteHandler" />
      
         <!-- Define the top level container in our container hierarchy -->
         <Engine name="Catalina" defaultHost="localhost" debug="0">
      
         <!-- Global logger unless overridden at lower levels -->
         <Logger className="org.apache.catalina.logger.FileLogger"
                   prefix="catalina_log." suffix=".txt"
                   timestamp="true"/>

    8.启动tomcat和apache测试(先启动tomcat)

    9.建立虚拟目录:

    ①      在tomcat/conf/server.xml文件中建立

    <Host name=”10.4.0.33” debug=”0” appBase=”webapps”

    unpackWARs=”true” autoDeploy=”true”

    xmlValidation=”false” xmlNamespaceAware=”false”>

    <Logger className=”org.apache.Catalina.logger.FileLogger”

    directory=”logs” prefix=”filename_log” suffix=”.txt”

    timestamp=”true” />

    <context path=”/dirName” docBase=”/test/www/jsp” debug=”0”

         reloadable=”true />

    </Host>

    docBase为真实目录

    ②      在apache/conf/workers2.properties文件中建立

    [uri:/dirName/*.jsp]

    work=ajp13:localhost:8009

    七.安装mysql4.0.16

    1.   解压缩文件:mysql-debug-4.0.16-pc-linux-i686.tar.gz

    2.   将解压后的目录改为mysql4016

    3.   建立用户:useradd –g root mysql

    passwd –u mysql

    4.   将mysql4016目录的拥有权改成 mysql 用户:chown –R mysql:root mysql4016

    5.   在/usr/local下建立连接文件

    ln –s /usr/local/e789/mysql4016 mysql

    6.   以mysql用户的身份登陆,运行脚本来建立一个初始化数据库:

    su mysql

    ./mysql4016/scripts/mysql_install_db

    exit(回到root身份)

    7.   把启动脚本程序复制到/etc/rc.d/init.d目录里

    cd /etc/rc.d/init.d

    cp /usr/local/mysql/support-files/mysql.server mysql

    8.   运行chkconfig把MySQL添加到系统的启动服务组里面去

    /sbin/chkconfig --del mysql

    /sbin/chkconfig --add mysql

    9.   测试mysql

    启动:/etc/rc.d/init.d/mysql start

                   如果显示Starting mysqld daemon with databases from /var/lib/mysql 则成功

                   (/usr/local/mysql/bin/mysql为mysql客户端程序)

            10.最后更改管理员密码

                   ./bin/mysqladmin -u root password e789

            11.登陆:mysql –u root –p e789

    转至:http://michaeltangbin.iteye.com/blog/386701

  • 相关阅读:
    遗传算法求函数最值(C语言实现)
    AjaxUploader使用
    AjaxUploader使用:FileUploaded及UploadCompleted
    AutoIt
    网站盗链问题及解决方案
    input不保留历史记录
    必备知识:消息处理
    AjaxUploader使用:文件保存到数据库
    AjaxUploader使用:JavaScript APIs
    页面定时跳转
  • 原文地址:https://www.cnblogs.com/xuerong/p/5105456.html
Copyright © 2020-2023  润新知