topic 1: CentOS卸载Apache方法
senario 1:
1 首先关闭httpd服务
/etc/init.d/httpd stop
2 列出httpd相关程序包
rpm -qa|grep httpd
列出包如下
httpd-2.2.3-63.el5.centos.1
httpd-manual-2.2.3-63.el5.centos.1
3 卸载包
rpm -e httpd-manual-2.2.3-63.el5.centos.1
rpm -e system-config-httpd-1.3.3.3-1.el5
这样就卸载完成了
senario2:
卸载自带Apache
1、# rpm -qa|grep httpd,查看与httpd相关软件包。
" httpd-2.2.3-11.el5_2.centos.4"
2、然后删除httpd:
"# rpm -e httpd"
出现问题:
" error: Failed dependencies:
httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386"
3、还有一个相关的软件包没有删除,清除之,即:
"#rpm -e gnome-user-share"
4、再删除httpd
"# rpm -e httpd"
#可以使用参数–nodeps的意思就是不管各个程序包间的依赖关系。
"#rpm -e –nodeps httpd //这样不需要删除gnome-user-share了
topic2: install apache
Apache安装
确保先进行了安装Linux必备常用库(linux中必备常用支持库的安装:http://blog.csdn.net/clevercode/article/details/45438401)
#修改防火墙配置:
# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
# service iptables restart
1) 解压
# cd /usr/local/src/apache
# tar zxvf apr-1.5.1.tar.gz
# cd apr-1.5.1
2) 配置
# ./configure --prefix=/usr/local/apr
3) 编译
# make
4)安装
# make install
1)解压
# cd /usr/local/src/apache
# tar zxvf apr-util-1.5.3.tar.gz
# cd apr-util-1.5.3
2)配置
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
3) 编译
# make
4) 安装
# make install
1)解压pcre-8.12.tar.gz
# cd /usr/local/src/apache
# tar zxvf pcre-8.12.tar.gz
2)进入解压后的目录
# cd pcre-8.12
3)配置
# ./configure
4) 编译
# make
5) 安装
# make install
1)解压
# cd /usr/local/src/apache
# tar -zvxf httpd-2.4.tar.gz
# cd httpd-2.4.9
2)编译
# mkdir -p /usr/local/apache2
# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-module=so --enable-rewrite --enable-cgid --enable-cgi
3)编译
# make
4)安装
# make install
# vi /usr/local/apache2/conf/httpd.conf
找到:#ServerName www.example.com:80
修改为:ServerName localhost:80
# vi /usr/local/apache2/conf/httpd.conf
找到:DirectoryIndex index.html
修改为:DirectoryIndex index.html index.php
# vi /usr/local/apache2/conf/httpd.conf
找到:Options Indexes FollowSymLinks
修改为:Options FollowSymLinks
# vi /usr/local/apache2/conf/httpd.conf
找到AllowOverride None
修改为:AllowOverride All #开启apache支持伪静态,有三处都做修改
LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释,开启apache支持伪静态
vi /etc/profile #添加apache服务系统环境变量
在最后添加下面这一行
export PATH=$PATH:/usr/local/apache2/bin
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/init.d/httpd
在#!/bin/sh下面添加以下两行
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
chown daemon.daemon -R /usr/local/apache2/htdocs #更改目录所有者
chmod 700 /usr/local/apache2/htdocs -R #更改apache网站目录权限
# chkconfig httpd on
1)启动
# service httpd start
2)停止
# service httpd stop
3)重启
# service httpd restart
4)查看端口状态
# netstat -an | grep 80