linux之Apache服务器(一)

这几天看了《树明聊运维》白树明大牛的课程,做了一下总结。

看大牛的: http://book.ayitula.com/webfu-wu-5668-apache-fu-wu.html

下面是我的总结:

一、关于Apache的介绍:.

1.什么是Apache?

Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,

它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是

最流行的Web服务器端软件之一。

apache当前版本:2.4.X

官方网站:www.apache.org

学习手册:http://httpd.apache.org/docs/2.4

2.Apache特点:

Apacheweb服务器软件拥有以下特性:

1.支持最新的HTTP/2通信协议(2.4.17及以后版本)

2.拥有简单而强有力的基于文件的配置过程

3.支持通用网关接口

4.支持基于IP和基于域名的虚拟主机

5.支持多种方式的HTTP认证

6.集成Perl处理模块

7.集成代理服务器模块

8.支持实时监视服务器状态和定制服务器日志

9.支持服务器端包含指令(SSI)

10.支持安全Socket层(SSL)

11.提供用户会话过程的跟踪

12.支持FastCGI

13.通过第三方模块可以支持JavaServlets

14.跨平台

=====================================================

二、部署Apache服务器(源码安装)

安装apr

安装apr-util

安装apr-iconv

安装apache

启动apache

测试apache

MPM

1.安装依赖:

安装依赖:

[root@test ~]# yum -y install gcc

[root@test ~]# yum -y install gcc-c++

[root@test ~]# yum install -y pcre-devel libxml2 expat-devel

2.apr介绍及安装

APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,

主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。在早期

的Apache版本中,应用程序本身必须能够处理各种具体操作系统平台的细节,并针对不同

的平台调用不同的处理函数。

[root@test ~]# wget https://www.apache.org/dist/apr/apr-1.7.0.tar.bz2

[root@test ~]# tar xf apr-1.7.0.tar.bz2

[root@test ~]# cd apr-1.7.0

[root@test apr-1.7.0]# ./configure --prefix=/usr/local/apr

[root@test apr-1.7.0]# make

[root@test apr-1.7.0]# make install

3.APR-util介绍及安装

apr-util该目录中也是包含了一些常用的开发组件。这些组件与apr目录下的相比,它们

与apache的关系更加密切一些。比如存储段和存储段组,加密等等。

[root@test ~]# wget https://www.apache.org/dist/apr/apr-util-1.6.1.tar.bz2

[root@test ~]# tar xf apr-util-1.6.1.tar.bz2

[root@test ~]# cd apr-util-1.6.1

[root@test apr-util-1.6.1]# yum install -y expat-devel

[root@test apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

[root@test apr-util-1.6.1]# make

[root@test apr-util-1.6.1]# make install

4. apr-iconv介绍及安装

apr-iconv包中的文件主要用于实现iconv编码。目前的大部分编码转换过程都是与本地编码相关的。

在进行转换之前必须能够正确地设置本地编码。因此假如两个非本地编码A和B需要转换,则转换过程

大致为A->Local以及Local->B或者B->Local以及Local->A。

[root@test ~]# wget https://www.apache.org/dist/apr/apr-iconv-1.2.2.tar.bz2

[root@test ~]# tar xf apr-iconv-1.2.2.tar.bz2

[root@test ~]# cd apr-iconv-1.2.2

[root@test apr-iconv-1.2.2]# ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr

[root@test apr-iconv-1.2.2]# make

[root@test apr-iconv-1.2.2]#  make install

5.apache安装

[root@test ~]# wget https://www.apache.org/dist/httpd/httpd-2.4.39.tar.gz

[root@test ~]# tar xf httpd-2.4.39.tar.gz

[root@test ~]# cd httpd-2.4.39

[root@test httpd-2.4.39]# ./configure --prefix=/usr/local/apache --enable-mpms-shared=all

--with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so

--enable-remoteip --enable-proxy --enable-proxy-fcgi --enable-proxy-uwsgi --enable-deflate=shared

--enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache

--enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir

--enable-nonportable-atomics --disable-ipv6 --with-sendfile

=====================================================

若是这里出现了报错:

没有发现zlib这个包,

[root@test httpd-2.4.39]# yum -y install zlib-devel

#清除上次执行的操作

[root@test httpd-2.4.39]# make clean 

#再次执行:

[root@test httpd-2.4.39]# ./configure --prefix=/usr/local/apache --enable-mpms-shared=all

--with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so

--enable-remoteip --enable-proxy --enable-proxy-fcgi --enable-proxy-uwsgi --enable-deflate=shared

--enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache

--enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir

--enable-nonportable-atomics --disable-ipv6 --with-sendfile

[root@test httpd-2.4.39]# make

[root@test httpd-2.4.39]# make install

(1)相关指令的详解:

--prefix=/usr/local/apache                                                指定安装目录

--enable-mpms-shared=all --with-mpm=event                开启动态MPM切换       

--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util        指定依赖包apr apr-util安装路径

--enable-so                                       打开 so 模块,so 模块是用来提 dso 支持的 apache 核心模块

--enable-remoteip                            支持基于客户端IP做访问控制                       

--enable-proxy --enable-proxy-fcgi --enable-proxy-uwsgi        启用代理支持PHP Python网站

--enable-deflate=shared                          开启压缩

--enable-expires=shared                          开启客户端缓存

--enable-rewrite=shared                          开启URL重写

--enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache 开启服务器缓存   

--enable-static-support                        支持静态连接

--enable-static-ab                              使用静态连接编译 ab - apache http 服务器性能测试工具

--disable-userdir                              禁用用户主目录提供页面访问

--enable-nonportable-atomics           对新式CPU支持,支持原子的比较交换(compare-and -swap, CAS)操作指令

--disable-ipv6                                  禁用IPV6

--with-sendfile                                开启sendfile 0复制机制

(2)相关目录

[root@test apache]# tree -L 1

├── bin 二进制命令

├── build

├── cgi-bin cgi脚本目录

├── conf 配置文件目录

├── error 错误记录

├── htdocs 默认网站根目录

├── icons 小图标

├── include 一些C语言文件

├── logs 日志目录

├── man 帮助手册

├── manual 在线手册

└── modules 存放apache运行需要的模块

6.apache启动:

(1)查看防火墙和SELinux是否关闭:

[root@test apache]# getenforce

[root@test apache]# systemctl status firewalld

(2)[root@test ~]# /usr/local/apache/bin/httpd

(3)启动和查看端口:

[root@test apache]# cd bin/

[root@test bin]# ./apachectl

[root@test bin]# netstat -ntpl

会出现 80 端口。

7.apache状态测试

[root@test httpd-2.4.39]# yum -y install elinks

[root@test httpd-2.4.39]# /usr/local/apache/bin/apachectl

[root@test ~]#  elinks http://192.168.131.129 -dump

                    It works!

8.关闭apache:

[root@test bin]# killall httpd

=====================================================

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容