Cnetos 搭建Apache Web服务器

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

Cnetos 搭建Apache Web服务器的相关文章

搭建Apache Web服务器

1.下载Apache服务器的安装包 地址:http://httpd.apache.org/download.cgi 从http://archive.apache.org/dist/httpd/binaries/win32/ 下载httpd-2.2.25-win32-x86-openssl-0.9.8y.msi 2.直接运行msi包,进行安装. 3.安装完成后,服务器自动运行,在浏览器中输入127.0.0.1,出现以下画面: 在安装路径下可以找到D:\Program Files (x86)\Apa

Linux Apache web服务器 配置详细教程

3 Linux Apache web服务器 v2.4.29学习要点: 1.apache用途,工作模式,httpd.conf的配置重要参数2.虚拟主机 工作模式的参数优化 3.1 Apache 概述: 3.1.1 Apache 概述Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中.同时Apache音译为

keepalived+nginx+tomcat搭建高性能web服务器集群

使用keepalived+nginx+tomcat搭建高性能web服务器集群,系统采用centos6.9,前端用nginx做反向代理实现负载均衡,同时结合keepalived对nginx实现高可用,后端使用两台tomcat做动态jsp解析,实现了动静分离. 搭建环境 准备四台服务器 vip: 192.168.75.130master: 192.168.75.131 (安装nginx做反向代理实现负载匀衡,结合keepalived实现高可用)backup: 192.168.75.132 (同上)w

Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器

Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器 一.搭建NginxWeb服务器     此种方式是用yum安装Nginx,为保证安装成功需在安装之前提前安装epel扩展源.     用yum安装Nginx     关闭系统防火墙           查看Nginx配置文件          安装完成后启动Nginx并查看其运行状态          然后在客户端浏览器里面输入Nginx服务器的IP地址即可验证Nginx工作正常      二.搭建NFS服务器     NFS:网络

步骤详解安装Apache web服务器

1.在上右键è安装 安装后apache web服务器自动启动. 在右下角出现. Apache安装之后有一个默认的网站目录 在浏览器上通过网站就可以访问到该目录下的文件. 2.测试 在浏览器输上请求localhost后看到此界面说明apache安装成功. 为什么可以访问到默认目录下的文件呢? 是因为在apache/conf/httpd.conf中配置了DocumentRoot指向该目录. 现在在该目录放一个PHP文件,通过浏览器访告诉访问该PHP文件. 为什么会出现这种情况呢? 因为web服务器接

Hello Node.js之搭建一个web服务器

Node.js简述 Nodejs 是JavaScript运行时,解释器是C/C++写的,基于ChromeV8引擎, 事件驱动,非阻塞I/O模型.本系列目前参考了Node.js官网,慕课网Scott的Node.js基础,<Node即学即用>图灵系列,以及可能的网上公开资源. Nodejs包管理器是npm 包就是别人写好的库. Nodejs提供了fs,http等内置对象,操作磁盘文件.搭建服务器. 特征:单线程.事件驱动.异步非阻塞I/O模型. Node.js安装 官网安装Node.js,自带np

Apache Web服务器 安装步骤 和遇到的坑

Apache Web服务器是开发放源码的网页服务器,我们看到的网页都是上传到服务器然后呈现给用户的. 在开发中,在自己的电脑上安装Apache Web服务器,你的电脑也会成为服务器,配置文件,访问你的ip地址,就可以查看你共享的页面. 这几天我给自己的电脑安装了Apache Web服务器 在过程中遇到了各种的坑,下面就说一下安装过程和解决坑的方法.安装过程我是以图的形式呈现,更直观明了. Apache Web服务器 安装步骤 1,打开安装包,选择"next".然后接受授权,选择&quo

Ubuntu下部署Apache Web服务器操作手册

Ubuntu下部署Apache Web服务器操作手册 安装 sudo apt install apache2 –y 修改配置 所有配置文件默认为只读,修改时需要修改操作权限: sudo chmod 777 [文件名] 修改/etc/apache2/sites-available路径下的000-default.conf文件中的DocumentRoot /var/www/ 为想要的目录: 修改/etc/apache2路径下的ports.conf文件中的Listen 80 为想要的端口,如8888:

Centos8搭建本地Web服务器

1 概述 系统centos8,利用httpd搭建本地web服务器. 2 安装httpd sudo yum install -y httpd 3 启动服务 service httpd start 4 设置开机启动 先查看有没有设置开机启动: systemctl list-unit-files | grep httpd 没有的话设置: chkconfig httpd on 再确认一下: systemctl list-unit-files | grep httpd 5 访问 再浏览器输入内网ip地址(