首先安装
yum install epel-release
安装 gcc openssl-devel make cmake pcre-devel
yum install -y vim-enhanced
yum install -y openssl-devel
yum install -y wget
yum install -y bzip2
cd /usr/local/src/
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.12.tar.bz2
wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.bz2
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz
2. 安装apr
tar jxvf apr-1.5.2.tar.bz2
cd apr-1.5.2
./configure --prefix=/usr/local/apr
echo $? 是否为0
make && make install
3. 安装apr-util
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install
4. 安装httpd
yum install gcc make cmake pcre-devel
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install
更改一下 conf/http.conf 路径下的,变为
ServerName www.localhost.com:80
去掉iptables规则
iptables -F
启动
bin/apachectl start
安装jdk
tar zxvf jdk-7u79-linux-x64.tar.gz
mv jdk1.8.0_31 /usr/local/jdk1.8.0_31
vim /etc/profile.d/java.sh //加入如下配置
JAVA_HOME=/usr/local/jdk1.8.0_31
JAVA_BIN=/usr/local/jdk1.8.0_31/bin
JRE_HOME=/usr/local/jdk1.8.0_31/jre
PATH=$PATH:/usr/local/jdk1.8.0_31/bin:/usr/local/jdk1.8.0_31/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_31/jre/lib:/usr/local/jdk1.8.0_31/lib:/usr/local/jdk1.8.0_31/jre/lib/charsets.jar
source /etc/profile.d/java.sh
替换命令:1,$s/1.8.0_31/1.7/g
如果以上配置成功,则下面的命令可以看到java的版本:
java -version
测试小程序
vim welcome.java
public class welcome {
public static void main(String args[]) {
System.out.println("Stay hungry Stay foolish");
}
}
安装tomcat
cd /usr/local/src/
wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.62/bin/apache-tomcat-7.0.62.tar.gz
tar zxvf apache-tomcat-7.0.62.tar.gz
mv apache-tomcat-7.0.62 /usr/local/tomcat
更改 vim /etc/profile.d/java.sh
启动
安装 mod_jk
tar -zxvf tomcat-connectors-1.2.41-src.tar.gz
cd tomcat-connectors-1.2.41-src
cd native/
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-tomcat=/usr/local/tomcat --with-java-home=/usr/local/jdk1.7 --with-jni
make & make install
拷贝几个目录
cp /usr/local/src/tomcat-connectors-1.2.41-src/conf/httpd-jk.conf ./apache2/conf/extra/
cp /usr/local/src/tomcat-connectors-1.2.41-src/conf/uriworkermap.properties ./apache2/conf/
cp /usr/local/src/tomcat-connectors-1.2.41-src/conf/workers.properties ./apache2/conf/
vim /usr/local/apache2/conf/httpd.conf
Include conf/extra/httpd-jk.conf
AddType application/x-httpd-jsp .jsp
修改/usr/local/apache2/conf/extra/httpd-jk.conf
JkMount /*.jsp tomcat
JkMountCopy All
填写jsp的端口 vim conf/workers.properties
worker.list=tomcat
worker.tomcat.type=ajp13
worker.tomcat.host=localho
worker.tomcat.port=8009
由于tomcat默认的主目录是/usr/local/tomcat/webapps/ROOT/,因此应编辑tomcat的主配置文
vim /usr/local/tomcat/conf/server.xml 下添加一行
vim welcome.jsp 测试页面
<%@page language="java" import="java.util.*" %>
Stay hungry Stay foolish !!!
Now the time is: <%out.println(new Date());%>
重启apache和tomcat服务
快捷
cd /usr/local/apache2/
./bin/apachectl start
cd /usr/local/tomcat/
./bin/startup.sh
添加rewrite规则
添加rewrite模块
find . -name mod_rewrite.c
cd modules/mappers/
/usr/local/apache2/bin/apxs -c mod_rewrite.c
/usr/local/apache2/bin/apxs -i -a -n mod_rewrite mod_rewrite.la
vim conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
#
RewriteEngine on
RewriteRule ^/t_(.*).html$ /xx.html?id=$1
重启