背景:
阅读新闻
httpd的rpm包及源码安装配置
[日期:2015-01-14] 来源:Linux社区 作者:Linux [字体:]
httpd的rpm包及源码安装配置
1、rpm包安装
系统环境:
[root@zhaochj ~]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
[root@zhaochj ~]# uname -r
2.6.32-358.el6.x86_64
[root@zhaochj ~]# ifconfig | grep Bcast:
inet addr:192.168.0.200 Bcast:192.168.0.255 Mask:255.255.255.0
查看当前yum源中可用的httpd安装包:
[root@zhaochj ~]# yum list all *httpd*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
Available Packages
httpd.x86_64 2.2.15-31.el6.centos updates
httpd-devel.i686 2.2.15-31.el6.centos updates
httpd-devel.x86_64 2.2.15-31.el6.centos updates
httpd-manual.noarch 2.2.15-31.el6.centos updates
httpd-tools.x86_64 2.2.15-31.el6.centos updates
安装httpd:
[root@zhaochj ~]# yum -y install all httpd
查看生成的配置文件:
[root@zhaochj ~]# rpm -qc httpd
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
……
httpd配置相关的目录结构:
[root@zhaochj httpd]# pwd
/etc/httpd
[root@zhaochj httpd]# tree
.
├── conf
│ ├── httpd.conf
│ ├── httpd.conf.back #对原配置文件做备份
│ └── magic
├── conf.d
│ ├── README
│ └── welcome.conf
├── logs -> ../../var/log/httpd
├── modules -> ../../usr/lib64/httpd/modules
└── run -> ../../var/run/httpd
配置hosts文件:
[root@zhaochj httpd]# vim /etc/hosts
192.168.0.200 zhaochj #增加此行
配置主配置文件,启用ServerName:
[root@zhaochj httpd]# vim conf/httpd.conf
ServerName 192.168.1.200:80 #启用ServerName,并修改为
测试配置文件:
[root@zhaochj httpd]# httpd -t
Syntax OK
启用httpd服务:
[root@zhaochj httpd]# service httpd start
Starting httpd: [ OK ]
查看httpd的版本:
[root@zhaochj ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21
查看httpd的使用的MPM,默认是prefork:
[root@zhaochj httpd]# httpd -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
修改MPM为worker,并验证:
[root@zhaochj httpd]# vim /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker #启用此行
[root@zhaochj httpd]# service httpd restart
[root@zhaochj httpd]# ps aux | grep httpd