软件下载:
--------------------------------
1、jdk-6u20-linux-i586-rpm.bin
http://www.sun.com
2、mysql-5.0.56.tar.gz
http://www.mydql.com
3、apache-tomcat-6.0.28.tar.gz
http://www.apache.org
==========================================
软件配置与安装
------------------------------
1、jdk-6u20-linux-i586-rpm.bin
------------------------------
先卸载以前的JAVA版本
- rpm -qa|grep java
- yum remove java
- cp jdk-6u20-linux-i586-rpm.bin /usr/local
- chmod +x jdk-6u20-linux-i586-rpm.bin
- ./jdk-6u20-linux-i586-rpm.bin
- ln -s /usr/java/jdk1.6.0_20/ /usr/local/java
#vi /etc/profile
在最下面添
- export JAVA_HOME=/usr/java/jdk1.6.0_20
- export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- export PATH=$PATH:$JAVA_HOME/bin
#source /etc/profile
------------------------------
2、Tomcat
------------------------------
- tar zxvf apache-tomcat-6.0.28.tar.gz
- cp apache-tomcat-6.0.28 /usr/local/
- cd usr/local
- mv apache-tomcat-6.0.28 tomcat
- cd tomcat
- chmod +x bin/*
- bin/startup.sh
#vi /etc/profile
最下面加入:
- export CATALINA_HOME=/usr/local/tomcat
开机自启动
# vi /etc/rc.d/rc.local 添加:
- export JAVA_HOME=/usr/java/jdk1.6.0_20
- export PATH=$JAVA_HOME/bin:$PATH
- export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- /usr/local/tomcat/bin/startup.sh
------------------------------
3、mysql-5.0.56.tar.gz
------------------------------
- groupadd mysql
- useradd -g mysql mysql
- tar zvxf mysql-5.0.56.tar.gz
- ./configure --prefix=/usr/local/mysql --with-extra-charsets=all
- make
- make install
- cp support-files/my-medium.cnf /etc/my.cnf
- cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- cd /usr/local/mysql
- bin/mysql_install_db --user=mysql
- chown -R root .
- chown -R mysql var
- chgrp -R mysql .
- /usr/local/mysql/bin/mysqld_safe --user=mysql &
- /usr/local/mysql/bin/mysqladmin -uroot password xxxxx #为root访问设置密码
# vi /etc/rc.d/rc.local //添加到系统自启动
添加:
- /etc/rc.d/init.d/mysqld start
保存并退出
- GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'elain' WITH GRANT OPTION;
//授权远程访问控制权限
--------------------------------
JDBC的安装
- tar -zxvf mysql-connector-java-5.1.13.tar.gz
- cd cd mysql-connector-java-5.1.13
- cp mysql-connector-java-5.1.13-bin.jar /usr/local/tomcat/webapps/ROOT/WEB-INF/lib/
#vi /etc/profile
最下面加入
- export CLASSPATH=$JAVA_HOME/lib:$JRE/lib:/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/mysql-connector-java-5.1.13-bin.jar
source /etc/profile
---------------------------------
6、php-5.2.13.tar.gz
---------------------------------
安装php
- cd /usr/local
- tar -jxvf php-5.2.13.tar.gz
- cd php-5.2.13
- ./configure --prefix=/usr/local/php --with-mysqld=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
- make
- make install
- cp php.ini-dist /usr/local/php/lib/php.ini
---------------------------------
apache与php整合
---------------------------------
编辑httpd.conf文件
# vi /usr/local/apache/conf/httpd.conf
在LoadModule处添加:
- LoadModule php5_module module/libphp5.so
在DirectoryIndex处添加: index.php
在AddType application处添加:
- AddType application/x-httpd-php .php .phtml
- AddType applicatoin/x-httpd-php-source .phps
- ProxyPass / ajp://127.0.0.1:8009/
- ProxyPassReverse / ajp://127.0.0.1:8009/
保存退出
-------------------------------------------
配置Tomcat
在Tomcat/conf/server.xml的中添加:
。
在Tomcat/webapps/test/WEB-INF/web.xml的中添加:
- MySQL Connection Pool
- JDBC for MySQL
- javax.sql.DataSource
- Container
在Tomcat 5.5/webapps/test/META-INF/context.xml的中添加:
重启Tomcat服务器,写一个test.jsp:
- <!doctype html public "-//w3c//dtd html 4.0 transitional//en"
- "http://www.w3.org/TR/REC-html40/strict.dtd">
- <%
- out.print("Start
- ");
- try{
- Context initCtx = new InitialContext();
- Context ctx = (Context) initCtx.lookup("java:comp/env");
- Object obj = (Object) ctx.lookup("JDBC for MySQL");
- javax.sql.DataSource ds = (javax.sql.DataSource)obj;
- Connection conn = ds.getConnection();
- out.print("MySQL connection pool runs perfectly!");
- conn.close();
- }
- catch(Exception ex){
- out.print(ex.getMessage());
- ex.printStackTrace();
- }
- %>
在浏览器中浏览该jsp文件,JSP 解析成功,说明安装正确通过!
转载请注明: 转载自http://www.elain.org
本文链接地址:apache+tomcat安装配置
本文转自 elain2012 51CTO博客,原文链接:http://blog.51cto.com/elain/648355