Apache+Tomcat+JspRun論壇搭建
一、 所需安裝包
httpd-2.2.11.tar.gz
apache-tomcat-6.0.18.tar.gz
jdk-6u10-linux-i586.tar.gz
jakarta-tomcat-connectors-jk2-src-current.tar.gz
二、 安裝所用包
###install Compile Environment###
for i in gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel ; do yum install -y $i ;done
1、 apache
- #tar xvf httpd-2.2.11.tar.gz
- #cd http-2.2.11
- #./configure –prefix=/usr/local/apache2 –enable-so
- #make
- #make install
2、 tomcat
- #tar xvf apache-tomcat-6.0.18.tar.gz –C /usr/local
- #cd /usr/local
- #ln –s apache-tomcat-6.0.18 tomcat
3、 jdk<java執行環境>
- #mkdir /usr/java
- #cp jdk-6u10-linux-i586.tar.gz /usr/java
- #cd /usr/java
- #tar xvf jdk-6u10-linux-i586.tar.gz
- #vi /etc/profile
最後新增:
- export JAVA_HOME=/usr/java/jdk
- export CLASSPATH=$JAVA_HOME/lib
- export PATH=$JAVA_HOME/bin:$PATH
- export PATH JAVA_HOME CLASSPATH
- #source /etc/profile
4、編譯生成mod_jk<連線apache與tomcat>
- # tar xzvf jakarta-tomcat-connectors-jk2-src-current.tar.gz
- # cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
- # ./configure ——with-apxs2=/usr/local/apache2/bin/apxs
- # make
- # cd ../build/jk2/apache2/
- # /usr/local/apache2/bin/apxs -n jk2 -i mod_jk2.so
- /usr/local/apache2/build/instdso.sh SH_LIBTOOL=`/usr/local /apache2/build/libtool` mod_jk2.so /usr/local/apache2/modules
- /usr/local/apache2/build/libtool --mode=install cp mod_jk2.so /usr/local/apache2/modules/
- cp mod_jk2.so /usr/local/apache2/modules/mod_jk2.so
- Warning! dlname not found in /usr/local/apache2/modules/mod_jk2.so.
- Assuming installing a .so rather than a libtool archive.
5、在/usr/local/apache2/conf/下面建立兩個配置檔案mod_jk2.conf和workers2.properties
# vi mod_jk2.conf
新增以下內容:
- # 指出mod_jk模組工作所需要的工作檔案workers2.properties的位置
- JkWorkersFile /usr/local/apache2/conf/workers2.properties
- # Where to put jk logs
- JkLogFile /usr/local/apache2/logs/mod_jk.log
- # Set the jk log level [debug/error/info]
- JkLogLevel info
- # Select the log format
- JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
- # JkOptions indicate to send SSL KEY SIZE,
- JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
- # JkRequestLogFormat set the request format
- JkRequestLogFormat "%w %V %T"
- # 將所有servlet 和jsp請求通過ajp13的協議送給Tomcat,讓Tomcat來處理
- JkMount /servlet/* worker1
- JkMount /*.jsp worker1
# vi workers2.properties
- # Define the communication channel
- [channel.socket:localhost:8009]
- info=Ajp13 forwarding over socket
- tomcatId=localhost:8009
- # Map the Tomcat examples webapp to the Web server uri space
- [uri:/*.jsp]
- info=Map the whole webapp
6、修改apache配置檔案
最後新增
LoadModule jk2_module modules/mod_jk2.so
7、配置tomcat啟動指令碼
vi /usr/local/tomcat/bin/catalina.sh
在第二行加入以下內容:
- # chkconfig: 345 88 14
- # description: Tomcat Daemon
- # processname: tomcat
- JAVA_HOME=/usr/java/jdk
- CATALINA_HOME=/usr/local/tomcat
然後儲存退出。
- #cp catalina.sh /etc/rc.d/init.d/tomcat
- #chmod 755 /etc/rc.d/init.d/tomcat
- #chkconfig --add tomcat
- #chkconfig --list tomcat
- tomcat 0ff 1ff 2n 3n 4n 5n 6ff
8、配置apache啟動指令碼
#cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
使用編輯器開啟httpd檔案,並在第一行#!/bin/sh下增加兩行文字如下
- # chkconfig: 35 70 30
- # description: Apache
接著註冊該服務
- #chkconfig --add httpd
- #chkconfig httpd on
9、啟動服務<關閉時順序也要httpd—>tomcat>
- #/etc/init.d/httpd start
- #/etc/init.d/tomcat start
測試:http://127.0.0.1 apache
http://127.0.0.1:8080 tomcat
三、搭建jsprun論壇
EasyJspRun!6.0.0_for_linux_UTF8.zip
經過多層解壓縮後,把其中的ROOT目錄拷貝到/usr/local/tomcat/webapps下<拷貝前需改名為jsprun,因為/usr/local/tomcat/webapp 中已經存在tomcat的預設目錄ROOT>
1、Mysql安裝部分省略
…………
2、#cd /usr/local/tomcat/webapps/jsprun
#vi config.properties
修改
dbpw = 123456 連線資料庫的密碼,也可以根據情況修改連線使用者,庫等
# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 160
Server version: 5.0.77-log Source distribution
Type `help;` or `h` for help. Type `c` to clear the buffer.
mysql> create database jsprun; <此庫名即上述配置檔案中指定的>
3、配置apache,完成虛擬主機搭建
#vi /usr/local/apache2/conf/httpd.conf
取消 Include conf/extra/httpd-vhosts.conf 前的#號 註釋
#vi /usr/local/apache2/extra/httpd-vhosts.conf
註釋掉預設的
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot “/usr/local/apache2/docs/dummy-host.example.com”
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog “logs/dummy-host.example.com-error_log”
# CustomLog “logs/dummy-host.example.com-access_log” common
#</VirtualHost>
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot “/usr/local/apache2/docs/dummy-host2.example.com”
# ServerName dummy-host2.example.com
# ErrorLog “logs/dummy-host2.example.com-error_log”
# CustomLog “logs/dummy-host2.example.com-access_log” common
#</VirtualHost>
新建如下:
- <Directory /usr/local/tomcat/webapps/jsprun>
- Order allow,deny
- Allow from all
- </Directory>
- <VirtualHost *:80>
- ServerAdmin abc@163.com
- DocumentRoot "/usr/local/tomcat/webapps/jsprun"
- ServerName http://192.168.0.201
- DirectoryIndex index.html index.jsp
- ErrorLog "logs/jsp-error_log"
- CustomLog "logs/jsp-access_log" common
- </VirtualHost>
4、tomcat配置
找到如下一段:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
在下面新增一行:定義主目錄與apache相同
<Context path="" docBase="/usr/local/tomcat/webapps/jsprun" debug="0"/>
5、瀏覽器開啟
或http://127.0.0.1:8080/install.jsp
按步驟完成安裝………….