1、Apahce 简介
- Apache Http Server 项目是在Windows和Linux/nuix等平台上都可以运行的跨平台开源Http服务器软件
- Apache Http Server 项目的目标是提供安全、高效、可扩展的Http服务
- 官网地址:http://httpd.apache.org
- 官方下载地址:点击进入
2、Apache 安装
Apache分为两种安装方法
- 二进制安装(简单快捷、可使用rpm或者yum源)
- 源码安装 (这种安装的灵活性比较大,可以满足企业的各种需求)
(1)二进制安装
- yum源安装(在线)
[[email protected] ~]# yum -y install httpd //安装httpd 服务 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * c6-media: * extras: mirrors.skyshe.cn * updates: mirrors.cqu.edu.cn c6-media | 4.0 kB 00:00 ... extras | 3.4 kB 00:00 mariadb | 2.9 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 1.3 MB 00:26 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-47.el6.centos will be installed --> Processing Dependency: httpd-tools = 2.2.15-47.el6.centos for package: httpd-2.2.15-47.el6.centos.x86_64 --> Running transaction check ---> Package httpd-tools.x86_64 0:2.2.15-47.el6.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.2.15-47.el6.centos updates 830 k Installing for dependencies: httpd-tools x86_64 2.2.15-47.el6.centos updates 77 k Transaction Summary ================================================================================ Install 2 Package(s) Total download size: 907 k Installed size: 3.1 M Downloading Packages: (1/2): httpd-2.2.15-47.el6.centos.x86_64.rpm | 830 kB 00:05 (2/2): httpd-tools-2.2.15-47.el6.centos.x86_64.rpm | 77 kB 00:01 -------------------------------------------------------------------------------- Total 113 kB/s | 907 kB 00:08 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : httpd-tools-2.2.15-47.el6.centos.x86_64 1/2 Installing : httpd-2.2.15-47.el6.centos.x86_64 2/2 Verifying : httpd-tools-2.2.15-47.el6.centos.x86_64 1/2 Verifying : httpd-2.2.15-47.el6.centos.x86_64 2/2 Installed: httpd.x86_64 0:2.2.15-47.el6.centos Dependency Installed: httpd-tools.x86_64 0:2.2.15-47.el6.centos Complete!
[[email protected] ~]# yum list | grep httpd //查询是否安装成功 @代表已经安装 httpd.x86_64 2.2.15-47.el6.centos @updates httpd-tools.x86_64 2.2.15-47.el6.centos @updates
[[email protected] ~]# service httpd start //启动服务 Starting httpd: httpd: apr_sockaddr_info_get() failed for vforbox httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName [ OK ] //启动时候会报错。说明http无法确定服务器域名称,可以修改主配置文件的ServerName项来解决,该提示可以忽略 [[email protected] ~]# netstat -lntup | grep 80 //查看是否正在被监听,监听说明启动成功 tcp 0 0 :::80 :::* LISTEN 10237/httpd [[email protected] ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT //将http服务80端口加入至防火墙允许规则
- 测试
- 在客户端使用浏览器访问该Web服务器,看到了如下,说明服务器可以被正常访问了。
=================================================================================================== 分 割 线 ===================================================================================================
(2)源码安装
- 由于安装方式是源码安装,所以这里安装Apache Http Server 之前需要安装很多依赖的软件包
- rpm包直接使用yum安装,有些还是需要去官方下载源码包来进行手动编译安装的
[[email protected] ~]# yum -y install gcc autoconf automake make pcre pcre-devel openssl openssl-devel //安装Apache所依赖的软件 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * c6-media: * extras: mirrors.neusoft.edu.cn * updates: mirrors.cqu.edu.cn Setting up Install Process Package gcc-4.4.7-16.el6.x86_64 already installed and latest version Package 1:make-3.81-20.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed ---> Package automake.noarch 0:1.11.1-4.el6 will be installed ---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated ---> Package openssl.x86_64 0:1.0.1e-42.el6 will be an update ---> Package openssl-devel.x86_64 0:1.0.1e-42.el6 will be installed --> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-42.el6.x86_64 ---> Package pcre.x86_64 0:7.8-6.el6 will be updated ---> Package pcre.x86_64 0:7.8-7.el6 will be an update ---> Package pcre-devel.x86_64 0:7.8-7.el6 will be installed --> Running transaction check ---> Package krb5-devel.x86_64 0:1.10.3-42.el6 will be installed --> Processing Dependency: krb5-libs = 1.10.3-42.el6 for package: krb5-devel-1.10.3-42.el6.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-42.el6.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-42.el6.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-42.el6.x86_64 --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be installed --> Processing Dependency: keyutils-libs = 1.4-5.el6 for package: keyutils-libs-devel-1.4-5.el6.x86_64 ---> Package krb5-libs.x86_64 0:1.10.3-10.el6_4.6 will be updated ---> Package krb5-libs.x86_64 0:1.10.3-42.el6 will be an update ---> Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be installed --> Processing Dependency: libcom_err = 1.41.12-22.el6 for package: libcom_err-devel-1.41.12-22.el6.x86_64 ---> Package libselinux-devel.x86_64 0:2.0.94-5.8.el6 will be installed --> Processing Dependency: libselinux = 2.0.94-5.8.el6 for package: libselinux-devel-2.0.94-5.8.el6.x86_64 --> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-5.8.el6.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-5.8.el6.x86_64 --> Running transaction check ---> Package keyutils-libs.x86_64 0:1.4-4.el6 will be updated ---> Package keyutils-libs.x86_64 0:1.4-5.el6 will be an update ---> Package libcom_err.x86_64 0:1.41.12-18.el6 will be updated --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-libs-1.41.12-18.el6.x86_64 --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: libss-1.41.12-18.el6.x86_64 --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-1.41.12-18.el6.x86_64 ---> Package libcom_err.x86_64 0:1.41.12-22.el6 will be an update ---> Package libselinux.x86_64 0:2.0.94-5.3.el6_4.1 will be updated --> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-utils-2.0.94-5.3.el6_4.1.x86_64 ---> Package libselinux.x86_64 0:2.0.94-5.8.el6 will be an update ---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed --> Running transaction check ---> Package e2fsprogs.x86_64 0:1.41.12-18.el6 will be updated ---> Package e2fsprogs.x86_64 0:1.41.12-22.el6 will be an update ---> Package e2fsprogs-libs.x86_64 0:1.41.12-18.el6 will be updated ---> Package e2fsprogs-libs.x86_64 0:1.41.12-22.el6 will be an update ---> Package libselinux-utils.x86_64 0:2.0.94-5.3.el6_4.1 will be updated ---> Package libselinux-utils.x86_64 0:2.0.94-5.8.el6 will be an update ---> Package libss.x86_64 0:1.41.12-18.el6 will be updated ---> Package libss.x86_64 0:1.41.12-22.el6 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: autoconf noarch 2.63-5.1.el6 base 781 k automake noarch 1.11.1-4.el6 base 550 k openssl-devel x86_64 1.0.1e-42.el6 base 1.2 M pcre-devel x86_64 7.8-7.el6 base 320 k Updating: openssl x86_64 1.0.1e-42.el6 base 1.5 M pcre x86_64 7.8-7.el6 base 196 k Installing for dependencies: keyutils-libs-devel x86_64 1.4-5.el6 base 29 k krb5-devel x86_64 1.10.3-42.el6 base 502 k libcom_err-devel x86_64 1.41.12-22.el6 base 33 k libselinux-devel x86_64 2.0.94-5.8.el6 base 137 k libsepol-devel x86_64 2.0.41-4.el6 base 64 k Updating for dependencies: e2fsprogs x86_64 1.41.12-22.el6 base 554 k e2fsprogs-libs x86_64 1.41.12-22.el6 base 121 k keyutils-libs x86_64 1.4-5.el6 base 20 k krb5-libs x86_64 1.10.3-42.el6 base 768 k libcom_err x86_64 1.41.12-22.el6 base 37 k libselinux x86_64 2.0.94-5.8.el6 base 108 k libselinux-utils x86_64 2.0.94-5.8.el6 base 82 k libss x86_64 1.41.12-22.el6 base 42 k Transaction Summary ================================================================================ 由于信息太多 下面省略.........
[[email protected] ~]# cd /usr/local/src [[email protected] src]# wget http://mirror.bjtu.edu.cn/apache/httpd/httpd-2.2.31.tar.gz //下载http软件包 [[email protected] src]# wget http://mirror.bjtu.edu.cn/apache/apr/apr-1.5.2.tar.gz //下载http所依赖的包 [[email protected] src]# wget http://mirror.bjtu.edu.cn/apache/apr/apr-util-1.5.4.tar.gz //下载http所依赖的包
时间: 2024-10-11 06:40:20