Apache tomcat搭建

Apache tomcat 搭建


1.安装前配置

1.1配置yum

安装光盘mount /dev/cdrom /media

[root@Web2 ~]# cat /etc/yum.repos.d/CentOS-Media.repo

[c6-media]

name=CentOS-$releasever - Media

baseurl=file:///media/

gpgcheck=1

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

1.2 依赖包安装

yum �Cy install *gcc* make vim openssl-devel

1.3防火墙

Selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config

sed -i's/SELINUXTYPE=targeted/#SELINUXTYPE=targeted/g' /etc/selinux/config

iptables

/etc/init.d/iptables stop

chkconfig iptables off

2.安装配置

2.1Apache安装配置

依赖包安装

2.1.1.安装aprapr-util

下载地址:http://mirrors.cnnic.cn/apache/apr/

tar -zxvf apr-1.4.8.tar.gz -C /usr/src/

tar -zxvf apr-util-1.5.2.tar.gz -C /usr/src/

cp -r apr-1.4.8/  /usr/src/httpd-2.4.4/srclib/apr

cp -r apr-util-1.5.2/  /usr/src/httpd-2.4.4/srclib/apr-util

如果不安装apache编译报错如下:

2.1.2.安装pcre

下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

tar -zxvf pcre-8.33.tar.gz -C /usr/src/

cd /usr/src/pcre-8.33

./configure �Cprefix=/usr/local/pcre-8.33 &&make && make install

2.1.3.安装apache

[root@web1 httpd-2.4.4]# ./configure--prefix=/usr/local/apache-2.4.4 \

> --enable-headers \

> --enable-mime-magic \

> --enable-so \

> --enable-rewrite \

> --enable-ssl \

> --enable-suexec \

> --with-included-apr \

> --with-mpm=prefork \

> --with-ssl=/usr/ \

>--with-pcre=/usr/local/pcre-8.33/ \

> --disable-userdir \

> --disable-cgid \

> --disable-cgi

make && make install

2.1.4配置apache

useradd  -s/sbin/nologin -M apache

vim /usr/local/apache-2.4.4/conf/httpd.conf


cp /usr/local/apache-2.4.4/bin/apachectl /etc/init.d/apache

vim /etc/init.d/apache

启动服务:/etc/init.d/apachestart

开机启动:chkconfigapache on

报错如下:

AH00557: httpd: apr_sockaddr_info_get() failed forweb1

AH00558: httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1. Set the 'ServerName'directive globally to suppress this message

解决:

vim /usr/local/apache-2.4.4/conf/httpd.conf

2.2Tomcat安装配置

cd /usr/src/

安装jdk

mv jdk1.7.0_25/  /usr/local/jdk

安装apache-tomcat

mv apache-tomcat-7.0.41/ /usr/local/tomcat-7.0.41

修改环境变量/etc/profile

TOMCAT_HOME=/usr/local/tomcat-7.0.41

JAVA_HOME=/usr/local/jdk

JRE_HOME=$JAVA_HOME/jre

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
使环境变量立刻生效

source /etc/profie

安装tomcat-connectors

cd /usr/src/tomcat-connectors-1.2.37-src/native

./configure--with-apxs=/usr/local/apache-2.4.4/bin/apxs &&make &&make install

查看apache安装目录下modules目录有没有mod_jk.so如果没有手动拷贝

整合apachetomcat

cd /usr/local/apache-2.4.4/conf

[root@web1 conf]# cat mod_jk.conf

JkWorkersFile       conf/extra/workers.properties

JkLogFile       logs/mod_jk.log

JkShmFile       logs/jk-runtime-status

JkLogLevel info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkOptions +ForwardKeySize +ForwardURICompat-ForwardDirectories

JkRequestLogFormat "%w %V %T"

#Sample JkMounts.  Replace these with the paths you would

#like to mount from your JSP server.

#syntax: JkMount ${URL_DIR}/*.jsp worker_name

JkMount               /images/avatar/*            worker1

JkMount               /*.jsp                      worker1

JkMount               /*.page                     worker1

JkMount               /*.cic                       worker1

JkMount               /*.do                       worker1

JkMount               /*.action    

[root@web1 conf]# cat workers.properties

worker.list=worker1    

worker.worker1.port=8009

worker.worker1.host=localhost

worker.worker1.type=ajp13

worker.woker1.lbfactor=1

配置tomcat的主机

docBase指定web的根目录

mkdir /web1

vim /usr/local/tomcat-7.0.41/conf/server.xml


测试页面

启动tomcat /usr/local/tomcat-7.0.41/bin/startup.sh

关闭tomcat /usr/local/tomcat-7.0.41/bin/shutdown.sh



你可能感兴趣的:(tomcat搭建)