Centos 6 + Apache 2.2 + Tomocat 7 + Postgresql 9.3
推荐服务器配置,内存1G以上,硬盘视小说数量而定(参考值6万本100G左右)
注:下面的教程中使用的软件都是64位版的,如果是32位系统请自行查找
安装前阅读
http://www.51yd.org/thread-index-fid-7-tid-66.htm
用root用户登录
安装教程如下:
1.安装apache
用yum安装apache
[root@v157-7-197-211 ~]# yum -y install httpd
适当修改配置文件(可跳过),修改完:wq退出!
[root@v157-7-197-211 ~]# vi /etc/httpd/conf/httpd.conf
#不显示OS类型和版本
ServerTokens OS
↓
ServerTokens Prod
#修改服务器名
#ServerName www.example.com:80
↓
ServerName 92dxs.com:80
#启动.htaccess※本程序未用
AllowOverride None
↓
AllowOverride All
设置开机自动启动
[root@v157-7-197-211 ~]# chkconfig httpd on
启动apache
[root@v157-7-197-211 ~]# service httpd start
OK,启动啦,先告一段落,之后还会改一点
2.修改防火墙,开放80端口
[root@v157-7-197-211 ~]# vi /etc/sysconfig/iptables
添加 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT,保存,重启防火墙
[root@v157-7-197-211 ~]# service iptables restart
3.安装JDK
下载JDK,然后用winscp之类的工具,上传到服务器上
[root@v157-7-197-211 ~]# wget www.51yd.org/jdk-6u45-linux-x64-rpm.bin
[root@v157-7-197-211 ~]# chmod +x jdk-6u45-linux-x64-rpm.bin
[root@v157-7-197-211 ~]# ./jdk-6u45-linux-x64-rpm.bin
查看下java版本,要是下面的这样的就OK啦
[root@v157-7-197-211 ~]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
如果不是的话,执行下面的命令切换下
[root@v157-7-197-211 ~]#alternatives --install /usr/bin/java java /usr/java/default/bin/java 16045
[root@v157-7-197-211 ~]#alternatives --config java
-----------------------------------------------
+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
* 3 /usr/java/default/bin/java
输入3,然后回车,就可以切换jdk啦
删除解压出来的垃圾文件
[root@v157-7-197-211 ~]# rm -f jdk-6u45-linux-amd64.rpm
[root@v157-7-197-211 ~]# rm -f sun-javadb-*.rpm
4.安装TOMCAT
下载TOMCAT 官网地址:http://tomcat.apache.org/download-70.cgi
[root@v157-7-197-211 ~]# wget http://www.51yd.org/apache-tomcat-7.0.55.tar.gz
※如果比较慢的话可以用下面的官方地址下载,如果再慢的话可以自己在网上找一个
wget http://ftp.kddilabs.jp/infosystems/apache/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz
解压缩下载文件
[root@v157-7-197-211 ~]# tar zxvf apache-tomcat-7.0.55.tar.gz
移动tomcat
[root@v157-7-197-211 ~]# mv apache-tomcat-7.0.55 /usr/local/tomcat
编辑环境变量文件
[root@v157-7-197-211 ~]# vi /etc/profile.d/tomcat.sh
添加下面内容
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib
创建启动脚本
[root@v157-7-197-211 ~]# vi /etc/rc.d/init.d/tomcat
内容如下
#!/bin/bash
#
# Startup script for the tomcat
#
# chkconfig: 345 80 15
# description: Tomcat is a Servlet+JSP Engine.
# Source function library.
. /etc/rc.d/init.d/functions
source /etc/profile.d/tomcat.sh
start(){
if [ -f /var/lock/subsys/tomcat ]; then
echo "Tomcat already started!"
exit 1
fi
echo -n "Starting Tomcat:"
/usr/local/tomcat/bin/startup.sh
touch /var/lock/subsys/tomcat
}
stop(){
if [ ! -f /var/lock/subsys/tomcat ]; then
echo "Tomcat already stopped!"
exit 1
fi
echo -n "Shutting down Tomcat:"
/usr/local/tomcat/bin/shutdown.sh
rm -f /var/lock/subsys/tomcat
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/usr/local/tomcat/bin/catalina.sh version
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0
添加可执行权限
[root@v157-7-197-211 ~]# chmod +x /etc/rc.d/init.d/tomcat
启动tomcat
[root@v157-7-197-211 ~]# /etc/rc.d/init.d/tomcat start
开机自动启动
[root@v157-7-197-211 ~]# chkconfig --add tomcat
[root@v157-7-197-211 ~]# chkconfig tomcat on
修改service.xml
[root@v157-7-197-211 ~]# vi /usr/local/tomcat/conf/server.xml
<Connector port="8009" protocol="AJP/1.3"
redirectPort="8443"/>
↓
<Connector port="8009" protocol="AJP/1.3"
redirectPort="8443" URIEncoding="UTF-8" />
5.Apache结合TOMCAT
[root@v157-7-197-211 ~]# vi /etc/httpd/conf.d/proxy_ajp.conf
添加下面内容
ProxyPass / ajp://localhost:8009/
重载配置文件
[root@v157-7-197-211 ~]# /etc/rc.d/init.d/httpd reload
打开IE,输入服务器地址,看一下,tomcat的界面出来啦!
6.安装Postgresql
[root@v157-7-197-211 ~]# yum -y install http://www.51yd.org/pgdg-redhat93-9.3-1.noarch.rpm
[root@v157-7-197-211 ~]# yum -y install postgresql93-server postgresql93-contrib
[root@v157-7-197-211 ~]#service postgresql-9.3 initdb
[root@v157-7-197-211 ~]#chkconfig postgresql-9.3 on
添加本地访问权限
[root@v157-7-197-211 ~]# vi /var/lib/pgsql/9.3/data/pg_hba.conf
修改如下内容
host all all 127.0.0.1/32 ident
↓
host all all 127.0.0.1/32 trust
启动postgresql
[root@v157-7-197-211 ~]# service postgresql-9.3 start
这样环境就安装完成啦,下面开始安装易读系统
http://www.51yd.org/thread-index-fid-1-tid-24.htm
========================
如果需要配置多个站点, 请略过第五步。