锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

新建文本文档 (3)

时间:2023-02-25 18:30:00 pcb传感器进口201a75

httpd

文章目录

  • **httpd**
    • httpd的介绍
    • httpd的版本
    • httpd的功能
    • httpd自带工具程序
    • httpd一些基本命令
    • rpm包安装的httpd程序环境
  • 编译安装httpd-2.4

httpd的介绍

httpd是Apache超文本传输协议(HTTP)服务器主程序。httpd它通常用作开源软件web使用服务器。目前最流行的web服务器软件叫做httpd,httpd还有一个俗称apache,Apache是软件基金会,httpd这也是软件基金会的一个项目。在早期的http server就叫做apache,到了http server 2.0后改名为httpd了。所以有时候会听到apache服务器和httpd其实服务器指的是一个意思。

httpd的版本

  • CentOS默认提供6系列版本httpd-2.2版本的rpm包
  • CentOS默认提供7系列版本httpd-2.4版本的rpm包

httpd的功能

1.可以提前创建过程,以便在有请求时快速处理

2.为一个按需创建适当的过程web对于服务器来说,创建过多的过程消耗了太多的资源,而且不容易管理。

3、web服务器采用模块化设计,核心功能比较小,各种功能是通过模块来实现的,同时也支持运行配置和支持单独编译模块等功能。

支持虚拟主机配置的各种方式。

主要有三种虚机主机:

  • 基于ip的虚机主机

  • 虚机主机基于端口

  • 基于域名的虚拟主机

5.支持用户认证

6、支持基于ip和主机名的ACL

7.支持每个目录的访问控制

8、支持URL重写

9支持路径别名

支持反向代理和负载平衡功能。通常用于tomcat的前端反向代理

httpd自带工具程序

工具 功能
htpasswd basic基于文件实现认证时使用的帐户密码生成工具
apachectl httpd自带服务控制脚本,支持start,stop,restart
apxs 由httpd-devel包提供,扩展httpd使用第三方模块的工具
rotatelogs 日志滚动工具
suexec 访问有特殊权限配置的资源时
ab apache benchmark,httpd压力测试工具

httpd一些基本命令

-l      //查看静态编译模块,列出核心编译的模块。          //它不会列出使用LoadModule动态加载模块的指令 -M      //输出已启用的模块列表,包括服务中的静态编译         作为///DSO动态加载模块 -v      //显示httpd然后退出版本 -V      //显示httpd和apr/apr-util退出版本和编译参数 -X      //以调试模式运行httpd。只启动一个工作过程,而且          ///服务器不与控制台分离 -t      ///检查配置文件是否有语法错误 

rpm包安装的httpd程序环境

文件/目录 对应的功能
/var/log/httpd/access.log 访问日志
/var/log/httpd/error_log 错误日志
/var/www/html/ 网站文档目录
/usr/lib64/httpd/modules/ 模块文件路径
/etc/httpd/conf/httpd.conf 主配置文件
/etc/httpd/conf.modules.d/*.conf 模块配置文件
/etc/httpd/conf.d/*.conf 辅助文件配置

编译安装httpd-2.4

环境开发环境

  • yum安装依赖包,主程序用源代码安装
  安装开发工具包 [root@localhost ~]# yum groups mark install "Development Tools"
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:13:12 ago on Fri Jul 22 13:20:07 2022.
Dependencies resolved.
==============================================================================
 Package           Architecture     Version           Repository         Size
==============================================================================
Installing Groups:
 Development Tools                                                           

Transaction Summary
==============================================================================

Is this ok [y/N]: y
Complete!

创建系统用户Apache
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
[root@localhost ~]# grep apache /etc/group
apache:x:992:

安装一些依赖包
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:16:05 ago on Fri Jul 22 13:20:07 2022.
Dependencies resolved.
==============================================================================
 Package                Arch   Version                         Repo      Size
==============================================================================
Installing:
 expat-devel            x86_64 2.2.5-4.el8                     BaseOS    55 k
 libtool                x86_64 2.4.6-25.el8                    AppSteam 709 k

 
 
 [root@localhost ~]# dnf -y install wget
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:17:13 ago on Fri Jul 22 13:20:07 2022.
Dependencies resolved.
==============================================================================
 Package            Architecture  Version               Repository       Size
==============================================================================
Installing:
 wget               x86_64        1.19.5-10.el8         AppSteam        734 k
Installing dependencies:
 libmetalink        x86_64        0.1.3-7.el8           BaseOS           32 k


 
 
[root@localhost ~]# dnf -y install gcc gcc-c++
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:17:58 ago on Fri Jul 22 13:20:07 2022.
Package gcc-8.5.0-10.el8.x86_64 is already installed.
Dependencies resolved.
==============================================================================
 Package               Architecture Version              Repository      Size
==============================================================================
Installing:
 gcc-c++               x86_64       8.5.0-10.el8         AppSteam        12 M
Installing dependencies:
 libstdc++-devel       x86_64       8.5.0-10.el8         AppSteam       2.0 M
 
 
 
[root@localhost ~]# dnf -y install vim



[root@localhost ~]# dnf  -y install make
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:18:46 ago on Fri Jul 22 13:20:07 2022.
Dependencies resolved.
==============================================================================
 Package       Architecture    Version                  Repository       Size
==============================================================================
Installing:
 make          x86_64          1:4.2.1-11.el8           BaseOS          498 k

使用wget下载apr-1.7.0,apr-util-1.6.1,httpd-2.4.54

[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
--2022-07-22 13:40:58--  https://downloads.apache.org/apr/apr-1.7.0.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093896 (1.0M) [application/x-gzip]
Saving to: 'apr-1.7.0.tar.gz'

apr-1.7.0.tar.gz    100%[=================>]   1.04M   153KB/s    in 7.5s    

2022-07-22 13:41:07 (142 KB/s) - 'apr-1.7.0.tar.gz' saved [1093896/1093896]


[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-07-22 13:41:15--  https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/x-gzip]
Saving to: 'apr-util-1.6.1.tar.gz'

apr-util-1.6.1.tar. 100%[=================>] 541.31K  62.8KB/s    in 8.5s    

2022-07-22 13:41:25 (63.3 KB/s) - 'apr-util-1.6.1.tar.gz' saved [554301/554301]



[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
--2022-07-22 13:41:28--  https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/x-gzip]
Saving to: 'httpd-2.4.54.tar.gz'

httpd-2.4.54.tar.gz 100%[=================>]   9.29M  28.6KB/s    in 6m 37s  

2022-07-22 13:48:06 (24.0 KB/s) - 'httpd-2.4.54.tar.gz' saved [9743277/9743277]


解压这三个包

[root@localhost ~]# tar xf apr-1.7.0.tar.gz -C /usr/local/src/
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz -C /usr/local/src/
[root@localhost ~]# tar xf httpd-2.4.54.tar.gz  -C /usr/local/src/
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
apr-1.7.0        apr-util-1.6.1    httpd-2.4.54

安装apr-1.7.0 apr-util-1.6.1 httpd-2.4.54

[root@localhost ~]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# vi configure
cfgfile="${ofile}T"
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    # $RM "$cfgfile"       //将此行注释,或删除
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make && make install
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config


[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ls
apr-1.7.0  apr-util-1.6.1
[root@localhost src]# cd apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@localhost apr-util-1.6.1]# make && make install
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config



[root@localhost ~]# cd /usr/local/src/httpd-2.4.54/
 [root@localhost httpd-2.4.54]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu


[root@localhost httpd-2.4.54]# make && make install
Making all in srclib
make[1]: Entering directory '/usr/local/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/local/src/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/usr/local/src/httpd-2.4.54/os'

[root@localhost httpd-2.4.54]# cd
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# ls
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules

设置环境变量

[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@localhost ~]# source /etc/profile.d/apache.sh
[root@localhost ~]# which apachectl   //查看环境变量是否成功
/usr/local/apache/bin/apachectl

[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/i

相关文章