linux系统下安装apache与tomcat
apache的安装
把安装包放到/soft 下
[root@localhost ~]#cd /soft
[root@localhost soft]#tar jxvf httpd-2.2.25.tar.gz //解压apache的压缩包
若报“bzip2: (stdin) is not a bzip2 file”,则将命令改为:tar xvf
[root@localhost soft]#cd httpd-2.2.25 //定位到httpd-2.2.25文件夹下
[root@localhost httpd-2.2.25]#ls //查看显示httpd-2.2.25文件夹下内容
[root@localhost httpd-2.2.25]#./configure --help | more //查看安装apache配置参数
[root@localhost httpd-2.2.25]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路径
若出现“configure failed for srclib/apr”,查看了一下原来是错误开始于srclib/apr文件,检查gcc编译器时提示没发现并且在系统环境变量$PATH中没有合适的c编译器,可以使用yum -y install gcc来安装gcc编译器/或者用rpm包安装,就可继续安装了。
[root@localhost httpd-2.2.25]#make //编译apache
[root@localhost httpd-2.2.25]#make install //安装apache
[root@localhost httpd-2.2.25]#cd /usr/local/apache //进入apache的目录
[root@localhost apache]# cd conf/
[root@localhost conf]#cp -a httpd.conf httpd.conf- //备份apache配置文件
[root@localhost conf]#chkconfig --list httpd //查看httpd服务是否已存在
[root@localhost conf]#chkconfig httpd off //关闭系统自带了httpd的服务,如果存在httpd服务
[root@localhost conf]#service httpd status //查看自带httpd服务状态
[root@localhost conf]#/usr/local/apache/bin/apachectl -k start //linux启动apache命令
若报“-bash apachectl: command not found”,/usr/apache/bin这个路径下有没apachectl?
有的话用./apachectl start,或者,你配下环境变量PATH增加/usr/apache/bin
[root@localhost conf]#netstat -an | grep :80 //查看linux80端口是否开启
[root@localhost conf]#ps -aux | grep httpd //linux下查看apache进程
[root@localhost conf]#cd ../..
[root@localhost local]#cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache //拷贝apache启动脚本
[root@localhost local]#vi /etc/rc.d/init.d/apache //这里是编辑apache启动脚本
在开头的#!/bin/sh 下面加上:#chkconfig: 2345 85 15
[root@localhost local]#chkconfig --add apache //添加apache服务
若报“apache服务不支持 chkconfig”,编辑/etc/rc.d/init.d/apache
#!/bin/bash
#chkconfig:2345 85 15 //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
#description:Apache httpd //此行必写,描述服务.(添加此行)
[root@localhost local]#chkconfig --list apache //列出apache服务
[root@localhost local]#service apache stop //停止apache服务
[root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否关闭
[root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败
[root@localhost local]#service apache start //启动apache服务
打开你的服务器ip地址,看看是否出现了tomcat的默认首页,如果出现的话,那么恭喜你
linux下安装apache已经成功了
tomcat的安装
1)下载apache-tomcat-6.0.37.tar.gz
2)#tar -zxvf apache-tomcat-6.0.37.tar.gz //解压
3)#cp -R apache-tomcat-6.0.37 /usr/local/tomcat //拷贝apache-tomcat-6.0.37到/usr/local/下并重命名为tomcat
4) /usr/local/tomcat/bin/startup.sh //启动tomcat