在CentOS下安装apche+tomcat+mysql+php

 

在CentOS下安装apche+tomcat+mysql+php
 
本例中所用到的软件
Apache 2.2
Sun的JDK-1_5_0_12-linux-i586
MySQL: mysql-5.0.41-linux-i686
PHP 5.2.3
Tomcat 5.028

 

tomcat-connectors-1.2.23

 

本例中将所有软件装入/home/www文件夹中

 

 

 

安装apache

 

进入源码包所在的文件夹(本例中为/home/install)

 

#cd /home/install

 

#tar zxvf httpd-2.2.4.tar.gz

 

#cd httpd-2.2.4

 

#./configure --prefix=/home/www/apache --enable-module=most --enable-shared=max --enable-so

 

#make && make install
创建一个启动脚本:

 

#vi /etc/rc.d/init.d/httpd

# 获取网络配置
#!/bin/bash
# Startup script for the Apache Web Server
# 包含函数库
. /etc/rc.d/init.d/functions
# 获取网络配置
. /etc/sysconfig/network
# 检测 NETWORKING 是否为 "yes"
[ "${NETWORKING}" = "no" ] && exit 0
# apache安装目录
APACHE=/home/www/apache
# 启动服务函数
start() {
echo $"Starting httpd service: "
$APACHE/bin/apachectl start
RETVAL=$?
echo
}
# 关闭服务函数
stop() {
echo $"Stopping httpd service: "
$APACHE/bin/apachectl stop
RETVAL=$?
echo
}
# 根据参数选择调用
case "$1" in
 start)
start
;
 stop)
stop
;;
 restart)
stop
start
;;
 *)
echo $"Usage: $0 start|stop|restart"
exit 1
esac
exit 0
#chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
 

 

 

#chmod 755 httpd
将其添加为系统服务。

 

#chkconfig –level 345 httpd on
重启apache服务.

 

#service httpd restart

 

 
安装Mysql.
解压、进入源码目录

 

#groupadd mysql

 

#useradd –g mysql mysql
移动目录至/home/www下

 

#cd /home/www/mysql

 

#scripts/mysql_install_db –user=mysql

 

#chown –R root .

 

#chown –R myssql data

 

#chgrp –R mysql .

 

#bin/mysqld_safe –user=mysql &
这样Mysql 就已经成功启动,下面为root用户设置密码

 

#./bin/mysqladmin –u root password
添加mysql为系统服务.

 

#cp support-files/mysql.server /etc/init.d/mysql

 

#vi /etc/init.d/mysql
修改其内容

basedir=/home/www/mysql
datadir=/home/www/mysql/data

 

 

#chkconfig –level 345 mysql on
#service mysql restart
 
安装php
解压、进入php源码目录
#cd php 5.2.3
#./configure--prefix=/home/www/php --with-mysql=/home/www/mysql --with-apxs2=/home/www/apache/bin/apxs
#make && make install
#cp php.ini-dist /usr/local/lib/php.ini
#vi /home/www/apache/conf/httpd.conf
添加

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3

 
重启apache.写入一test.php

<?
Phpinfo()
?>

 
测试php模块是否正常
 
安装JDK
进入下载目录
#chmod +x jdk-1_5_0_12-linux-i586-rpm.bin
#./jdk-1_5_0_12-linux-i586-rpm.bin
按空格键,阅读使用许可,然后输入yes
安装完成后,J2DK的默认安装目录是/usr/java/jdk-1_5_0_12,为了方便操作,建立一个符号链接。
#ln –s /usr/java/jdk-1_5_0_12 /usr/jdk
安装tomcat
解压tomcat
# tar jakarta-tomcat-5.0.28.tar.gz –C /home/www
#cd /home/www
#mv jakarta-tomcat-5.0.28 tomcat
#cd tomcat
#chmod +x bin/*.sh
修改bin目录下的startup.sh和shutdown.sh。添加以下内容
 

export JAVA_HOME=/usr/jdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib

 
添加以下内容至/etc/rc.d/rc.local
#vi /etc/rc.d/rc.local

/home/www/tomcat/bin/startup.sh

 
整合apache和tomcat
#cp mod_jk-1.2.21-apache-2.2.x-linux-i686.so /home/www/apache/modules/mod_jk.so
解压tomcat-connectors-1.2.23-src.tar.gz
#tar zxvf tomcat-connectors-1.2.23-src.tar.gz
#cd tomcat-connectors-1.2.23/native
# ./configure --with-apxs=/home/www/apache/bin/apxs
#make && make install
完成后,在httpd.conf下添加如下内容

#add mod_jk module
LoadModule jk_module modules/mod_jk.so
# Update this path to match your modules location
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to #httpd.conf)
  JkWorkersFile /home/www/apache/conf/workers.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
  JkLogFile     /home/www/apache/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"
# Send everything for context /examples to worker named worker1 (ajp13)
  JkMount  /*.jsp worker1

 
在到conf目录下新建一个workers.properties文件。内容如下:

# Define 1 real worker using ajp13
  worker.list=worker1
# Set properties for worker1 (ajp13)
  worker.worker1.type=ajp13
  worker.worker1.host=localhost
  worker.worker1.port=8009
  worker.worker1.lbfactor=50
  worker.worker1.cachesize=10
  worker.worker1.cache_timeout=600
  worker.worker1.socket_keepalive=1
  worker.worker1.reclycle_timeout=300
 

 
修改tomcat的配置文件server.xml与apache的路径整合
在  <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
这样的语句下添加:
        <Context path="" docBase="/home/www/apache/htdocs" debug="0"/>
这样就完成了所有的安装

你可能感兴趣的:(tomcat,mysql,PHP,centos,apche)