APACHE服务安装总结
卸除原有APACHE服务
1.1 验证APACHE服务是否安装 --- 已经安装
[root@localhost sbin]# httpd -v Server version: Apache/2.2.15 (Unix) Server built: Feb 13 2012 22:25:23
2.2 查询rpm安装包 安装信息
# rpm -qa |grep httpd httpd-2.2.15-15.el6.centos.1.i686 httpd-tools-2.2.15-15.el6.centos.1.i686
1.3 删除
#rpm -e gnome-user-share-2.28.2-3.el6.i686 #rpm e php-5.3.3-3.el6_2.8.i686 #rpm -e httpd-2.2.15-15.el6.centos.1.i686 #rpm -e httpd-tools-2.2.15-15.el6.centos.1.i686
1.4 验证APACHE服务是否还存在
# httpd -v bash: /usr/sbin/httpd: No such file or directory
1.5 删除剩余APACHE服务文件
以下为未被卸除的剩余文件
#whereis httpd httpd: /etc/httpd /usr/lib/httpd
删除
#rm -rf /usr/lib/httpd
安装APACHE服务 --- rpm安装包方式安装
2.1 将如下安装包拷贝到目录下
rpm安装包可从系统安装盘上面找到
也可以从RPM资源网站下载到本地环境
http://rpmfind.net/linux/
/usr/dev/apache/
httpd-2.2.15-15.el6.centos.1.i686.rpm
httpd-devel-2.2.15-15.el6.centos.1.i686.rpm
httpd-tools-2.2.15-15.el6.centos.1.i686.rpm由于刚才删除了下面两个安装包 故需要从新下载安装
gnome-user-share-2.28.2-3.el6.i686 php-5.3.3-3.el6_2.8.i686
#rpm -ivh httpd-tools-2.2.15-15.el6.centos.1.i686.rpm #rpm -ivh httpd-2.2.15-15.el6.centos.1.i686.rpm #rpm -ivh gnome-user-share-2.28.2-3.el6.i686 #rpm -ivh php-5.3.3-3.el6_2.8.i686
验证 --- 安装成功
# whereis httpd httpd: /usr/sbin/httpd /usr/sbin/httpd.event /usr/sbin/httpd.worker /etc/httpd /usr/lib/httpd /usr/share/man/man8/httpd.8.gz # httpd -v Server version: Apache/2.2.15 (Unix) Server built: Feb 13 2012 22:25:23
配置APACHE
#vi /etc/httpd/conf/httpd.conf /DirectoryIndex index.html 修改为如下内容 DirectoryIndex index.html index.html.var index.php /DocumentRoot "/opt/APACHE/htdocs" 修改为如下内容 DocumentRoot "/usr/local/htdocs/cici/" /<Directory 修改为如下内容 <Directory "/usr/local/htdocs/cici/"> /Listen 修改为如下内容 Listen 80 /ServerName 修改为如下内容 ServerName localhost /NameVirtualHost 修改为如下内容 NameVirtualHost *:80 /<VirtualHost 修改为如下内容 <VirtualHost *:80> # ServerAdmin [email protected] DocumentRoot /usr/local/htdocs/cici/ # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
启动APACHE服务
/etc/rc.d/init.d/httpd restart
或者
#service httpd start
浏览器访问
http://localhost
出现如下页面即可
Apache 2 Test Pagepowered by CentOS
问题总结
1 启动apache服务出现如下错误
Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf.d/mod_dnssd.conf: Cannot load /etc/httpd/modules/mod_dnssd.so into server: /etc/httpd/modules/mod_dnssd.so: cannot open shared object file: No such file or directory[FAILED]
#ls -r /usr/lib/httpd/modules
列出的文件列表中确实没有mod_dnssd.so这个文件
根本原因缺少mod_dnssd-0.6-2.el6.i686.rpm安装包
拷贝安装包到指定目录#cp /mnt/hgfs/CentOS\&RHEL4/Exchange\ Data/apache/mod_dnssd-0.6-2.el6.i686.rpm /usr/dev/apache/ #cd /usr/dev/apache/
删除原有安装包 -- 如果存在
#rpm -e --nodeps mod_dnssd-0.6-2.el6.i686
再次安装新的安装包
#rpm -ivh mod_dnssd-0.6-2.el6.i686.rpm
验证问题 已经有了该文件
# find / -name "mod_dnssd.so"
/usr/lib/httpd/modules/mod_dnssd.so
2 安装APCHE服务rpm安装包依赖关系 删除顺序
#rpm -e gnome-user-share-2.28.2-3.el6.i686 #rpm e php-5.3.3-3.el6_2.8.i686 #rpm -e httpd-2.2.15-15.el6.centos.1.i686 #rpm -e httpd-tools-2.2.15-15.el6.centos.1.i686
安装顺序
#rpm -ivh httpd-tools-2.2.15-15.el6.centos.1.i686.rpm #rpm -ivh httpd-2.2.15-15.el6.centos.1.i686.rpm
由于刚才删了以下这两个安装包 故需要从新安装
#rpm -ivh gnome-user-share-2.28.2-3.el6.i686 #rpm -ivh php-5.3.3-3.el6_2.8.i686