Apache-tomcat服务器搭建 |
||
Ap-ac-he-to-mc-at-服务器搭建 |
搭建Apache-tomcat服务器需要的工具包有:
安装Apache: 解压Apache源码包: tar zxvf apache.tar.gz �CC /opt/ 配置Apache: ./configure �Cprefix=/usr/local/httpd //添加安装路径 �Cenable-so //启用动态加载模块 编译及安装: Make && make install 安装jdk: ./jdk.bin //安装(解压)【必须有可执行权限】前面是协议读完敲yes 然后在本目录会产生一个jdk.bin解压出来的目录jdk???目录 Mv ./jdk /usr/Java //移动jdk目录到/usr/下并重命名为Java(可自定义) 更改环境变量/etc/profile文件: Vim /etc/profile ………. JAVA_HOME=/usr/java JRE_HOME=/usr/java/jre 或 ${JAVA_HOME}/jre Export JAVA_HOME JRE_HOME ………. 然后退出登录在登录 //重新加载/etc/profile使新增参数生效 安装apache-tomcat服务器: 解压apache-tomcat Tar zxvf ./apache-tomcat �CC /usr/local Tomcat服务器所有配置文件将在/usr/local/apache-tomcat/ Tomcat服务: 启动:/usr/local/apache-tomcat/bin/startup.sh 关闭:/usr/local/apache-tomcat/bin/shutdown.sh Tomcat服务启动后默认网站的端口号是8080 安装Jakarta-tomcat-connectors 解压jakarta-tomcat-connector.tar.gz Tar zxvf Jakarta-tomcat-connectors.tar.gz �CC /opt 进入/opt/Jakarta-tomcat-connects/jk/native Cd /opt/Jakarta-tomcat-connects/jk/native ./buildconf.sh /配置 ./configure �Cwith-apxs=/usr/local/httpd/bin/apxs //添加Apache安装路径 或 ./configure �Cwith-apache=/usr/local/httpd //只能选择一项进行配置 编译及安装 Make && make install Cd apache-2.0 Cp mod-jk.so /usr/local/httpd/modules/ 编辑apache主配置文件: Vim /usr/local/httpd/conf/httpd.conf ………. LoadModule jk_module modules/mod_jk.so //添加mod_jk.so模块 ………. 进入Apache文档目录: Cd /usr/local/httpd/htdocs/ Mkdir jsp //建立JSP目录 然后吧jsp 网页拷到/usr/local/httpd/htdocs/jsp/ 目录下 进入apache配置目录: Cd /usr/local/httpd/conf/ Touch workers.properties //新建文件 Vim workers.properties Worker.list=worker1 //worker列表 Worker.worker1.type=ajp13 //类型为ajp13 Worker.worker1.host=localhost //主机名 Worker.worker1.port=8009 //localhost主机将监听8009端口 Worker.worker1.lbfactor=50 //负载权值 Worker.worker1.cache_timeout=600 //声明JK在cache中保留一个打开的socket的时间 Worker.worker1.socket_keepalive=1 //当防火墙位于web server与Tomcat之间时,防火墙将尝试断开未激活的网络连接。此属性将告诉操作系统在未激活的连接中发送KEEP_ALIVE信息(发送间隔时间依赖于操作系统的设置,一般为120秒),这样将防止防火墙切断未激活的网络连接 Worker.worker1.socket_timeout=300 //连接在未激活的状况下持续多久 保存并退出!!! Touch mod_jk.conf //新建文件 Vim mod_jk.conf JkWorkersFile /usr/local/httpd/conf/workers.properties JkLogFile /usr/local/httpd/logs/mod_jk.log JkLogLevel info JkLogStampFormat “[%a %b %d %H:%M:%S %Y]” JkMount /servlet/* worker1 JkMount /*.jsp worker1 保存退出!!! 编辑Apache主配置文件 Vim /usr/local/httpd/conf/httpd.conf …….. Include /usr/local/httpd/conf/mod_jk.conf ……. 保存退出!!! 进入tomcat配置目录 Cd /usr/local/apache-tomcat/conf/ Vim server.xml 在Host标签里写入: <Context path=”” docBase=”/usr/local/httpd/htdocs/jsp” debug=”0” reloadable=”true” crossContext=”true” /> 例: 启动tomcat:/usr/local/apache-tomcat/bin/startup.sh 在Apache中添加默认文档index.jsp 重启Apache: /usr/local/httpd/bin/apachectl restart Netstat �Catnp //查看启动端口: Apache 80端口 Tomcat 有 8080 以及还有8009 当访问JSP动态网页时tomcat进行转换,服务器默认根目录为: /usr/local/httpd/htdocs/jsp 当访问静态网页时为Apache进行解析,此时的服务器默认根目录为: /usr/local/httpd/htdocs |
Ap-ac-he-to-mc-at-服务器搭建 |