本篇以Redhat AS5,内核为Linux 2.6.18-8.el5 为例,其中Redhat/Fedora系列基本一致,其他Linux或者版本均可以参考。
STEP 1
软件下载:
1. jdk1.6.x http://java.sun.com/javase/downloads/index.jsp
2. tomcat6.x http://tomcat.apache.org/download-60.cgi
3. mysql5.x http://dev.mysql.com/downloads/mysql/5.0.html
http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51a-linux-i686.tar.gz/from/pick
4. JDBC connector http://dev.mysql.com/downloads/connector/j/5.1.html
5. apache2.x http://httpd.apache.org/download.cgi
6. php5.x http://www.php.net/downloads.php
7. jk_mod1.2.x http://tomcat.apache.org/download-connectors.cgi
SETP 2
1. JDK安装
1.1 解压并授权
[work@localhost webServer]$ chmod a+r jdk-6u10-beta-linux-i586.bin
*** 一段许可协议 ***
Do you agree to the above license terms? [yes or no]
[work@localhost webServer]$ yes
*** 解压过程 ***
Done.
[work@localhost webServer]$ mv jdk1.6.0_10 /home/work/usr/local/
[work@localhost local]$ ln -s jdk1.6.0_10 jdk
1.2 配置环境变量
编辑/etc/profile文件或者在/etc/profile.d/文件下新建java.sh文件
[work@localhost local]$ vim /etc/profile.d/java.sh
添加内容如下:
#set java 环境变量
JAVA_HOME=/home/work/usr/local/jdk
PATH=$PATH:/$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib
JRE_HOME=$JAVA_HOME/jre
export JAVA_HOME PATH CLASSPATH JRE_HOME
1.3 设置java和javac的符号连接,
[work@localhost local]#cd /usr/bin
[work@localhost local]#su root
[root@localhost bin]# ln -s -f /home/work/usr/local/jdk/jre/bin/java
[root@localhost bin]# ln -s -f /home/work/usr/local/jdk/bin/javac
JDK安装完成,有问题请参考:http://jiarry.bokee.com/2425368.html
2. Tomcat安装
2.1 解压后移动文件夹到指定目录
[work@localhost webServer]$ tar -zxvf apache-tomcat-6.0.16.tar.gz
[work@localhost webServer]$ mv apache-tomcat-6.0.16 /home/work/usr/local/
2.2 配置环境变量
编辑刚新建的/etc/profile.d/java.sh文件
TOMCAT_HOME = /home/work/usr/local/tomcat
export JAVA_HOME PATH CLASSPATH JRE_HOME TOMCAT_HOME
3. 测试安装
3.1 检查环境变量和java版本
[work@localhost ~]$ echo $JAVA_HOME
/home/work/usr/local/jdk
[work@localhost ~]$ echo $PATH
输出的含有/home/work/usr/local/jdk/bin:
[work@localhost ~]$ echo $CLASSPATH
.:/home/work/usr/local/jdk/lib
[work@localhost ~]$ echo $TOMCAT_HOME
/home/work/usr/local/tomcat
[work@localhost ~]$ java -version
3.2 启动tomcat
[work@localhost local]$ sh /home/work/usr/local/tomcat/bin/startup.sh
在浏览器地址栏输入 http://localhost:8080/
3.3 给Tomcat添加项目
3.3.1 修改tomcat/conf/server.xml:
<Context path="/test" reloadable="true" docBase="/home/work/dev/test"
workDir="/home/work/usr/local/tomcat/work/test" />
3.3.2 开启目录浏览:
<param-name>listings</param-name>
<param-value>true</param-value>
3.3.3 开启servlet直接访问,打开注释
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
还有这段
<servlet-mapping>
<servlet-name>invoker</servlet-name>
context.xml文件里<Context>增加privileged
<Context privileged="true">
SETP 3 MySql与JDBC connector
1. 解压缩mysql-5.0.51a-linux-i686.tar.gz
[work@localhost webServer]$ tar -zxvf mysql-5.0.51a-linux-i686.tar.gz
[work@localhost webServer]$ mv mysql-5.0.51a-linux-i686 /home/work/usr/local/
2. 参照INSTALL-BINARY文件安装mysql
2.1 建立一个mysql符号连接
[work@localhost local]$ cd /home/work/usr/local/
[root@localhost local]# ln -s mysql-5.0.51a-linux-i686 mysql
[work@localhost local]$ su root
[root@localhost local]# su -
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
回到/home/work/usr/local/mysql/,更改目录所属为mysql
[root@localhost ~]# cd /home/work/usr/local/mysql/
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
执行脚本生成mysql系统数据库
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
……
出现成功提示之后,授权返还给work,但是data目录仍然给mysql账号
[root@localhost mysql]# chown -R work .
[root@localhost mysql]# chown -R mysql data
2.2 看/var/run/是否有mysqld目录,如果没有就新建。
[root@localhost mysql]# cd /var/run/mysqld
[root@localhost run]# mkdir mysqld
[root@localhost mysqld]# cd mysqld
[root@localhost run]# chown -R mysql mysqld .
[root@localhost run]# chgrp -R mysql mysqld .
[root@localhost mysql]#su mysql
[mysql@localhost mysql]$ vi /var/run/mysqld/mysqld.pid
查看/tmp/下是否有mysql.sock文件,把/home/mysql/mysql.sock做个符号连接到/tmp/临时文件夹下
[root@localhost mysql]# ln -s /home/mysql/mysql.sock /tmp/mysql.sock
[root@localhost tmp]# chown -R mysql mysql.sock
[root@localhost tmp]# chgrp -R mysql mysql.sock
也可以查看一下/etc/my.cnf,检查配置
[root@localhost tmp]# cat /etc/my.cnf
2.3 启动mysql服务
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[root@localhost mysql]# Starting mysqld daemon with databases from /var/lib/mysql
启动成功后,查看一下mysql的进程:
[root@localhost mysql]# ps -el | grep mysqld
4 S 0 14213 13164 0 84 0 - 1171 wait pts/0 00:00:00 mysqld_safe
4 S 502 14241 14213 0 85 0 - 8223 - pts/0 00:00:00 mysqld
1 S 502 14242 14241 0 78 0 - 8223 - pts/0 00:00:00 mysqld
1 S 502 14243 14242 0 85 0 - 8223 rt_sig pts/0 00:00:00 mysqld
[root@localhost tmp]# netstat -na | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
2.4 登录mysql试一下,可用其他账户
[root@localhost mysql]# su work
[work@localhost mysql]$ cd /home/work/usr/local/mysql/
[work@localhost mysql]$ bin/mysql -uroot -p密码
2.5 配置自动启动
[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chmod 777 /etc/init.d/mysqld
[root@localhost init.d]# su -
[root@localhost ~]# chkconfig --add mysqld
mysql配置完成。
3. mysql-connector-java安装
--转自