编译安装httpd-2.4及httpd常用配置

httpd升级2.4.57及后续问题处理 制作httpd 2.4.57 、升级httpd2.4.57 以及过程中问题处理 阅读详情

编译安装最新版的httpd

1、先在网页里找出源码包

 

 用最新的1.7.0这个源码包(如果用bz2的需要安装bzip来解压)

 

 util也是用最新的(用gz可以直接解压)

 

 2、使用wget下载源码包(对于curl来说太大了,所以用wget)

[root@localhost ~]# yum -y install wget      //先安装wget命令
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:22:30:29 前,执行于 2022年04月14日 星期四 16时02分29秒。
软件包 wget-1.19.5-10.el8.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!
[root@localhost ~]# ls
公共                好看的手机充值单页.zip  视频  文档  音乐  anaconda-ks.cfg
好看的手机充值单页  模板                    图片  下载  桌面  initial-setup-ks.cfg
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz     //用wget命令下载
--2022-04-15 14:36:01--  https://downloads.apache.org/apr/apr-1.7.0.tar.gz
正在解析主机 downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104
正在连接 downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1093896 (1.0M) [application/x-gzip]
正在保存至: “apr-1.7.0.tar.gz”

apr-1.7.0.tar.gz         100%[===============================>]   1.04M  72.8KB/s  用时 17s     

2022-04-15 14:36:34 (63.9 KB/s) - 已保存 “apr-1.7.0.tar.gz” [1093896/1093896])
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-04-15 14:40:38--  https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
正在解析主机 downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f8:10a:201a::2, ...
正在连接 downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:554301 (541K) [application/x-gzip]
正在保存至: “apr-util-1.6.1.tar.gz”

apr-util-1.6.1.tar.gz    100%[===============================>] 541.31K   279KB/s  用时 1.9s    

2022-04-15 14:40:41 (279 KB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])


[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz
--2022-04-15 14:44:19--  https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz
正在解析主机 downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
正在连接 downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9726558 (9.3M) [application/x-gzip]
正在保存至: “httpd-2.4.53.tar.gz”

httpd-2.4.53.tar.gz      100%[===============================>]   9.28M   118KB/s  用时 83s     

2022-04-15 14:45:43 (114 KB/s) - 已保存 “httpd-2.4.53.tar.gz” [9726558/9726558])

编译httpd完整过程

//完整编译过程(最新版本)

//下载wget命令
[root@localhost ~]# yum -y install wget make

//下载源码包
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz

//安装开发环境
[root@localhost ~]# yum groups mark install "Development Tools"
[root@localhost ~]# rpm -qa | grep gcc
libgcc-8.5.0-3.el8.x86_64
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
useradd:用户“apache”已存在
[root@localhost ~]# id apache
uid=48(apache) gid=48(apache) 组=48(apache)
[root@localhost ~]# grep apache /etc/group
apache:x:48:
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool    //安装依赖包

//解压
[root@localhost ~]# tar xf apr-1.7.0.tar.gz 
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost ~]# tar xf httpd-2.4.53.tar.gz 

//编译apr-1.7.0
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# vim configure
$RM "$cfgfile"   //把这个删掉
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install 

//编译apr-util-1.6.1
[root@localhost ~]# 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
[root@localhost apr-util-1.6.1]# make install 

//编译httpd-2.4.53
[root@localhost ~]# cd httpd-2.4.53/
[root@localhost httpd-2.4.53]#  ./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
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install   

//设置环境变量
[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 httpd
/usr/local/apache/bin/httpd

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

//man文档
[root@localhost ~]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/apache/man




启动服务

//怎么来启动使用这个服务
//关闭防火墙
[root@localhost ~]# systemctl disable --now firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 
Permissive
[root@localhost ~]# vim /etc/selinux/config 
SELINUX=disabled   //把这个改为disabled
//启动服务
[root@localhost ~]# ss -antl
State      Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process     
LISTEN     0          128                  0.0.0.0:111               0.0.0.0:*                   
LISTEN     0          128                  0.0.0.0:22                0.0.0.0:*                   
LISTEN     0          5                  127.0.0.1:631               0.0.0.0:*                   
LISTEN     0          128                     [::]:111                  [::]:*                   
LISTEN     0          128                     [::]:22                   [::]:*                   
LISTEN     0          5                      [::1]:631                  [::]:*                   
[root@localhost ~]# which apachectl 
/usr/local/apache/bin/apachectl
[root@localhost ~]# apachectl start      //用这个来启动
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message       //这是个警告,不用管
[root@localhost ~]# ss -antl      //查看到这个已经启动了,可以去用ip地址来搜
State      Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process     
LISTEN     0          128                  0.0.0.0:111               0.0.0.0:*                   
LISTEN     0          128                  0.0.0.0:22                0.0.0.0:*                   
LISTEN     0          5                  127.0.0.1:631               0.0.0.0:*                   
LISTEN     0          128                     [::]:111                  [::]:*                   
LISTEN     0          128                        *:80                      *:*                   
LISTEN     0          128                     [::]:22                   [::]:*                   
LISTEN     0          5                      [::1]:631                  [::]:*       
//关闭服务
[root@localhost ~]# apachectl stop


//如果想关掉这个提醒,可以以下操作
[root@localhost ~]# apachectl start      
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message       //这是个警告,不用管
//操作
[root@localhost ~]# cd /usr/local/apache/conf/    //放配置文件的
[root@localhost conf]# cd
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# ls
bin  build  cgi-bin  conf(配置文件)  error  htdocs (源码安装的放网站的) icons  include  logs(放日志的)  man  manual  modules
[root@localhost apache]# cd conf/
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# vim httpd.conf
#ServerName www.example.com:80    //把#删掉,也就是取消掉注释,这样就不会有那个警告显示出了

//如果想设置成systemctl来控制启动,并且设置开机自启
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# ls sshd.service 
sshd.service
[root@localhost system]# cp sshd.service httpd.service
cp:是否覆盖'httpd.service'? y
[root@localhost system]# vim httpd.service     //配置修改

[Unit]
Description=httpd server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# cd
[root@localhost ~]# systemctl status httpd    //查看一下这个服务,有了
[root@localhost ~]# systemctl start httpd    //现在可以用systemctl来控制启动了
[root@localhost ~]# systemctl enable httpd       //设置开机自启

 显示出来代表成功了

 

httpd常用配置

访问控制法则:

法则功能
Require all granted允许所有主机访问
Require all deny拒绝所有主机访问
Require ip IPADDR授权指定来源地址的主机访问
Require not ip IPADDR拒绝指定来源地址的主机访问
Require host HOSTNAME授权指定来源主机名的主机访问
Require not host HOSTNAME拒绝指定来源主机名的主机访问

注意:httpd-2.4版本默认是拒绝所有主机访问的,所以安装以后必须做显示授权访问

示例:

<Directory /var/www/html/www>
    <RequireAll>
        Require not ip 192.168.1.20
        Require all granted
    </RequireAll>
</Directory>

                 

虚拟主机:
虚拟主机有三类:

  • 相同IP不同端口
  • 不同IP相同端口
  • 相同IP相同端口不同域名
//一个主机跑多个网站需要的配置(相同ip不同端口号)
[root@localhost ~]# ls /usr/local/apache/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@localhost ~]# cd /usr/local/apache/htdocs
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# mkdir test.example.com
[root@localhost htdocs]# ls
index.html  test.example.com
[root@localhost htdocs]# mkdir blog.example.com
[root@localhost htdocs]# ls
blog.example.com  index.html  test.example.com
//配置虚拟主机(如果只用一个网站就不需要配置,但是如果跑多个网站就需要配置)
[root@localhost ~]# cd /usr/local/apache/conf/
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# ls extra/
httpd-autoindex.conf  httpd-info.conf       httpd-mpm.conf                 httpd-userdir.conf
httpd-dav.conf        httpd-languages.conf  httpd-multilang-errordoc.conf  httpd-vhosts.conf
httpd-default.conf    httpd-manual.conf     httpd-ssl.conf                 proxy-html.conf
[root@localhost conf]# cd
[root@localhost ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf   //修改

<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/test.example.com"
    ServerName test.example.com
    ErrorLog "logs/test-host.example.com-error_log"
    CustomLog "logs/test-host.example.com-access_log" common
</VirtualHost>

~                                                                                                
~  
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
#Include conf/extra/httpd-vhosts.conf    //把#删掉,取消注释
 [root@localhost ~]# systemctl restart httpd     //重启


//访问
[root@localhost ~]# cd /usr/local/apache/htdocs
[root@localhost htdocs]# cd test.example.com/
[root@localhost test.example.com]# ls
[root@localhost test.example.com]# echo "test page" > abc.html
[root@localhost test.example.com]# ls
abc.html     //这样用ip访问网页,进去后还要点才能看到,是因为首页网站必须叫index
[root@localhost test.example.com]# mv abc.html index.html    //改一下名字
[root@localhost test.example.com]# ls
index.html   //这样就可以直接访问到
[root@localhost test.example.com]# cd ..
[root@localhost htdocs]# ls
blog.example.com  index.html  test.example.com
[root@localhost htdocs]# cd blog.example.com/
[root@localhost blog.example.com]# ls
[root@localhost blog.example.com]# echo "blog page" > index.html
[root@localhost blog.example.com]# ls
index.html       //这样之后只能看到最先的网站(所以需要以下操作),因为只配置了一个

//操作,继续配置
[root@localhost ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf     //修改配置
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/test.example.com"
    ServerName test.example.com
    ErrorLog "logs/test-host.example.com-error_log"
    CustomLog "logs/test-host.example.com-access_log" common
</VirtualHost>
Listen 81
<VirtualHost *:81>
    DocumentRoot "/usr/local/apache/htdocs/blog.example.com"
    ServerName blog.example.com
    ErrorLog "logs/blog-host.example.com-error_log"
    CustomLog "logs/blog-host.example.com-access_log" common
</VirtualHost>
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# ss -antl
State      Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process     
LISTEN     0          128                  0.0.0.0:111               0.0.0.0:*                   
LISTEN     0          128                  0.0.0.0:22                0.0.0.0:*                   
LISTEN     0          5                  127.0.0.1:631               0.0.0.0:*                   
LISTEN     0          128                     [::]:111                  [::]:*                   
LISTEN     0          128                        *:80                      *:*                   
LISTEN     0          128                        *:81                      *:*                   
LISTEN     0          128                     [::]:22                   [::]:*                   
LISTEN     0          5                      [::1]:631                  [::]:*    
        
//192.168.160.130:81   就可以访问到blog        

//不同ip相同端口
[root@localhost ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf 
<VirtualHost *:192.168.160.130:80>
    DocumentRoot "/usr/local/apache/htdocs/test.example.com"
    ServerName test.example.com
    ErrorLog "logs/test-host.example.com-error_log"
    CustomLog "logs/test-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:192.168.160.131:80>
    DocumentRoot "/usr/local/apache/htdocs/blog.example.com"
    ServerName blog.example.com
    ErrorLog "logs/blog-host.example.com-error_log"
    CustomLog "logs/blog-host.example.com-access_log" common
</VirtualHost>
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:d8:4a:24 brd ff:ff:ff:ff:ff:ff
    inet 192.168.160.130/24 brd 192.168.160.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fed8:4a24/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:6e:03:e4 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 52:54:00:6e:03:e4 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# ip addr add 192.168.160.131/24 dev ens160
[root@localhost ~]# ip a s ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:d8:4a:24 brd ff:ff:ff:ff:ff:ff
    inet 192.168.160.130/24 brd 192.168.160.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 192.168.160.131/24 scope global secondary ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fed8:4a24/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl start httpd


//相同端口相同ip不同域名(平时我们用的)

 [root@localhost ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf 

<VirtualHost *:*:80>
    DocumentRoot "/usr/local/apache/htdocs/test.example.com"
    ServerName test.example.com
    ErrorLog "logs/test-host.example.com-error_log"
    CustomLog "logs/test-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:*:80>
    DocumentRoot "/usr/local/apache/htdocs/blog.example.com"
    ServerName blog.example.com
    ErrorLog "logs/blog-host.example.com-error_log"
    CustomLog "logs/blog-host.example.com-access_log" common
</VirtualHost>

[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl start httpd

 在真机上加

 加一个blog

 

https的配置

//ssl启动模块
[root@localhost ~]# cd /usr/local/apache
[root@localhost apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@localhost apache]# cd conf/
[root@localhost conf]# vim httpd.conf 
#LoadModule ssl_module modules/mod_ssl.so    //搜mod_ssl,将#去掉,取消注释


配置https步骤:

//生成证书
//CA生成一对密钥
[root@localhost conf]# cd /etc/pki
[root@localhost pki]# ls
ca-trust  entitlement  fwupd-metadata  nssdb    product-default  rsyslog  tls
consumer  fwupd        java            product  rpm-gpg          swid
[root@localhost pki]# mkdir CA
[root@localhost pki]# ls
CA        consumer     fwupd           java   product          rpm-gpg  swid
ca-trust  entitlement  fwupd-metadata  nssdb  product-default  rsyslog  tls
[root@localhost pki]# cd CA/
[root@localhost CA]# pwd
/etc/pki/CA
[root@localhost CA]# mkdir private
[root@localhost CA]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus (2 primes)
.............+++++
..........................................+++++
e is 65537 (0x010001)
[root@localhost CA]# ls
private
[root@localhost CA]# ls private/
cakey.pem
//CA生成自签署证书
[root@localhost CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HB
Locality Name (eg, city) [Default City]:WH
Organization Name (eg, company) [Default Company Ltd]:runtime
Organizational Unit Name (eg, section) []:runtime
Common Name (eg, your name or your server's hostname) []:test.example.com
Email Address []:1@2.com
[root@localhost CA]# ls
cacert.pem  private
[root@localhost CA]# mkdir certs newcerts crl
[root@localhost CA]# ls
cacert.pem  certs  crl  newcerts  private
[root@localhost CA]# touch index.txt && echo 01 > serial
[root@localhost CA]# ls
cacert.pem  certs  crl  index.txt  newcerts  private  serial
[root@localhost CA]# cd
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@localhost apache]# cd conf/
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# mkdir ssl
[root@localhost conf]# pwd
/usr/local/apache/conf
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original  ssl
[root@localhost conf]# cd ssl/
//httpd服务器生成密钥
[root@localhost ssl]# (umask 077;openssl genrsa -out httpd.key 2048)
Generating RSA private key, 2048 bit long modulus (2 primes)
................................+++++
............................+++++
e is 65537 (0x010001)
[root@localhost ssl]# ls
httpd.key
//httpd服务器生成证书签署请求
[root@localhost ssl]# openssl req -new -key httpd.key -days 365 -out httpd.csr
Ignoring -days; not generating a certificate
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HB
Locality Name (eg, city) [Default City]:WH
Organization Name (eg, company) [Default Company Ltd]:runtime
Organizational Unit Name (eg, section) []:runtime
Common Name (eg, your name or your server's hostname) []:test.example.com
Email Address []:1@2.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@localhost ssl]# ls
httpd.csr  httpd.key
//CA签署客户端提交上来的证书
[root@localhost ssl]# openssl ca -in httpd.csr -out httpd.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Apr 17 11:47:17 2022 GMT
            Not After : Apr 17 11:47:17 2023 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = HB
            organizationName          = runtime
            organizationalUnitName    = runtime
            commonName                = test.example.com
            emailAddress              = 1@2.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                37:2B:78:43:06:72:5D:5B:DF:95:4D:20:60:B6:6B:94:B7:3E:0F:22
            X509v3 Authority Key Identifier: 
                keyid:0D:1B:E9:6C:35:A7:3E:27:33:D7:89:26:1F:22:FD:6F:E1:05:6F:67

Certificate is to be certified until Apr 17 11:47:17 2023 GMT (365 days)
Sign the certificate? [y/n]:y     //要不要签名


1 out of 1 certificate requests certified, commit? [y/n]y     //要不要提交申请
Write out database with 1 new entries
Data Base Updated
[root@localhost ssl]# ls
httpd.crt  httpd.csr  httpd.key
[root@localhost ssl]# rm -rf httpd.csr
[root@localhost ssl]# ls
httpd.crt  httpd.key
//因为是在一台虚拟机上,所以不用传输给客户端
  • 配置httpd.conf,取消以下内容的注释
    LoadModule ssl_module modules/mod_ssl.so
    Include /etc/httpd24/extra/httpd-vhosts.conf
    Include /etc/httpd24/extra/httpd-ssl.conf
[root@localhost conf]# vim httpd.conf 
[root@localhost conf]# ls extra/
httpd-autoindex.conf  httpd-info.conf       httpd-mpm.conf                 httpd-userdir.conf
httpd-dav.conf        httpd-languages.conf  httpd-multilang-errordoc.conf  httpd-vhosts.conf
httpd-default.conf    httpd-manual.conf     httpd-ssl.conf                 proxy-html.conf
[root@localhost conf]# vim extra/httpd-ssl.conf 

#   General setup for the virtual host
DocumentRoot "/usr/local/apache/htdocs/test.example.com"     //124行
ServerName test.example.com:443       //125行
ServerAdmin you@example.com
ErrorLog "/usr/local/apache/logs/error_log"
TransferLog "/usr/local/apache/logs/access_log"

SSLCertificateFile "/usr/local/apache/conf/ssl/httpd.crt"     //144行
#SSLCertificateFile "/usr/local/apache/conf/server-dsa.crt"
#SSLCertificateFile "/usr/local/apache/conf/server-ecc.crt"

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
#   ECC keys, when in use, can also be configured in parallel
SSLCertificateKeyFile "/usr/local/apache/conf/ssl/httpd.key"      //154行

  • 在httpd-vhosts.conf中配置虚拟主机
  • 在httpd-ssl.conf中配置证书的位置
  • 检查配置文件是否有语法错误
[root@localhost ~]# httpd -t
[Sun Apr 17 20:07:08.970911 2022] [core:error] [pid 111970] (EAI 2)Name or service not known: AH00547: Could not resolve host name *:* -- ignoring!
[Sun Apr 17 20:07:08.971029 2022] [core:error] [pid 111970] (EAI 2)Name or service not known: AH00547: Could not resolve host name *:* -- ignoring!
AH00526: Syntax error on line 92 of /usr/local/apache/conf/extra/httpd-ssl.conf:
SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf 
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so   //删掉#,取消注释
[root@localhost ~]# httpd -t
[Sun Apr 17 20:09:10.856896 2022] [core:error] [pid 112021] (EAI 2)Name or service not known: AH00547: Could not resolve host name *:* -- ignoring!
[Sun Apr 17 20:09:10.856977 2022] [core:error] [pid 112021] (EAI 2)Name or service not known: AH00547: Could not resolve host name *:* -- ignoring!
Syntax OK
  • 启动或重启服务

[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# ss -antl
State      Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process     
LISTEN     0          128                  0.0.0.0:111               0.0.0.0:*                   
LISTEN     0          128                  0.0.0.0:22                0.0.0.0:*                   
LISTEN     0          5                  127.0.0.1:631               0.0.0.0:*                   
LISTEN     0          128                        *:443                     *:*                   
LISTEN     0          128                     [::]:111                  [::]:*                   
LISTEN     0          128                        *:80                      *:*                   
LISTEN     0          128                     [::]:22                   [::]:*                   
LISTEN     0          5                      [::1]:631                  [::]:*      
  • 设置hosts以便用域名访问(仅学习阶段,企业实际工作中无需做此步。

编译安装httpd-2.4 目录前文第二步第三步第四步开始解压 并编辑第五步第六步 编译安装httpd 前文 httpd依赖于apr -1.4+,apr-util-1.4+,【apr-icon】 apr:apache portable runtime 第一步 检查本地仓库是否有没有问题 yum list all 做这样的题目 首先要确保自己本地仓库没有任何问题 还要确保镜像是否挂载 yum groupinstall "... 阅读详情

相关推荐

Apache2.4.57源码安装配置

Apache2.4.57源码安装配置

多学习,多总结 1212

httpd-2.4.57

Apache HTTP Server(简称Apache),是Apache软件基金会的一个开放源代码的网页服务器,可以在大多数电脑操作系统中运行,由于其具有的跨平台性和安全性,被广泛使用,是最流行的Web服务器端软件之一。 升级的第一步是阅读源代码目录中的发布公告(release announcement)和CHANGES文件以寻找可能会对你的站点产生影响的变化。如果主板本号的变化(例如1.3→2.0或2.0→2.2)表明编译时和运行时的配置发生了重大变化,需要手动调整,所有模块也需要升级以兼容新版本的模块API 。 小幅度的版本升级(例如:2.2.55→2.2.57)很容易。make install 的过程不会改写任何已经存在的文档、日志、配置文件。此外,开发者也会尽量兼容上一版本的configure选项、运行时配置、模块API 。大多数情况下,你将能够使用与上一版本完全相同的configure命令行和运行时配置,而你原来的所有模块也将正常工作。 如果你保存了上一次安装后build子目录中的config.nice文件,升级将更加平滑。这个文件精确地保存了所有对目录树进行配置的confi

Centos7上编译安装Httpd2.4

Centos7上编译安装HTTPD2.4在Centos7上使用yum安装httpd是最简便的方式。但是由于Centos7自带的htpd版本固定,有时我们可能需要安装更新版本的httpd,或者需要开启httpd默认未开启的功能模块,此时编译httpd源码的安装方式将是我们必须掌握的技能。

Geoffrey's Blog 3401

Linux:http服务(Apache 2.4.57)源码编译——配置网站 || 入门到入土

我的服务器为centos7系统。

鲍海超 5455

源码编译apache 2.4.5 出现的问题

1、解决依赖关系httpd-2.4.5需要较新版本的apr和apr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。这里选择使用编译源代码的方式进行(1) 编译安装apr# tar xf apr-1.4.6.tar.bz2# cd apr-1.4.6# ./configure --prefix=/usr/local/apr...

weixin_33932129的博客 264

Windows 64位环境下Apache HTTPD 2.4编译安装配置指南

Apache HTTP Server,简称Apache,是互联网上应用最广泛的Web服务器软件之一。最新发布的2.4版本在性能、可伸缩性以及安全性方面做了大量改进,提供了更多新特性和模块,使得它更加稳定和高效。

weixin_42372837的博客 1385

ubuntu1604编译安装apache2httpd-2.4.18)+配置openssl环境

ubuntu1604编译安装apache2httpd-2.4.18)+配置openssl环境 文章目录ubuntu1604编译安装apache2httpd-2.4.18)+配置openssl环境下载安装包执行编译安装脚本修改配置文件运行测试 下载安装http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz http://archive.apa

ronnie88597的博客 731

httpd2.4编译安装配置参数详细说明

一,安装环境描述 VMware workstation 10,CentOS 6.5 64位,强烈建议系统中事先安装开始工具包“Development Tools”,以免在编译安装httpd软件是出现错误(介绍就这么多, Let's go....^_^)二,httpd新性性介绍 1,MPM支持在运行时动态装载(Multipath Process Mo...

weixin_34348805的博客 507

编译安装httpd2.4,配置httpd服务

1.安装apr,apr-utils,pcre-devel和openssl-devel[root@wh1 ~]# tar xf apr-1.5.1.tar.gz[root@wh1 ~]# tar xf apr-util-1.5.3.tar.gz[root@wh1 apr-1.5.1]# cd apr-1.5.1[root@wh1 apr-1.5.1]# ./configure ...

weixin_34362991的博客 222

编译安装最新版本httpd2.4.9的简单配置解析

准备好安装包:apr-1.4.6.tar.bz2,apr-util-1.5.2.tar.bz2httpd-2.4.9.tar.bz2这里我就不介绍了,有兴趣的话可以看看我之前写的Web Server 之一和Web Server 之二有相关介绍;直接配置使用,请看:一、httpd-2.4.9 编译安装。注意:新版本的httpd要依赖于更高版本的apr和apr-util。apr...

weixin_34199335的博客 141

19.httpd(apache)、http协议详解和httpd配置 2.2版本、centos6 上编译安装httpd2.4

1.web服务器程序 2.httpd的特性 ①高度模块化 ②DSO(动态共享对象):支持动态装卸载模块 ③MPM(多进程处理模块):支持多种不同的I/O模型 MPM三种模型详解 prefork:多进程模型,每个进程相应一个请求 一个主进程负责生成n个子进程,每个子进程处理一个用户请求,即使没有用户请求也会预先生成多个空闲进程,随时 等待请求到达。最大不会超过1024个;主进程只负责监听进程,并送给子进程处理 worker:多进程和多线程的混合模式,但是存在keep-alive长连接的时候占用线程资源被浪费

weixin_43812198的博客 460

源码编译安装httpd 2.4,提供系统服务管理脚本并测试——两种方法

源码编译安装httpd 2.4

m0_74747565的博客 737

httpd

httpd的简介 httpdApache超文本传输协议(HTTP)服务器的主程序。被设计为一个独立运行的后台进程,它会建立一个处理请求的子进程或线程的池。 通常,httpd不应该被直接调用,而应该在类Unix系统中由apachectl调用,在Windows中作为服务运行。 httpd的版本 本文主要介绍httpd的两大版本,httpd-2.2httpd-2.4。 CentOS6系列的版本默认...

mylovewxl 467

【超详细】Windows平台安装 apache 2.4

1 先在官网下载apache安装https://www.apachehaus.com/cgi-bin/download.plx#APACHELEVS16 根据需求选择合适的版本: 2 解压,修改apache24/conf/httpd.conf文件 在httpd.conf文件中修改apache 绝对安装路径 保存修改,打开cmd进入bin目录,执行 httpd -t 查看我们刚修改的文件是否合法: 上图表示出错了,在httpd.conf文件中找到ServerName,去掉前面的注释,这里我将域

kite的博客 6291

编译安装Apache的脚本(httpd-2.4.57.tar.gz)

【代码】编译安装Apache的脚本(httpd-2.4.57.tar.gz)

m0_68459671的博客 542

httpd源码安装

httpd源码安装

weixin_72900594的博客 518

安装 Apache 2.4

前提:如果已经存在较老的apache 版本,最好卸载 [root@bogon src]# rpm -qa | grep -i httpd httpd-2.2.15-45.el6.centos.x86_64 httpd-tools-2.2.15-45.el6.centos.x86_64 如果遇到依赖,无法删除, 就不检查依赖,直接删除 使用 --nodeps: rpm -e 包名 --n

happy19870612's blog 751
下一篇: MySQL基础-MySQL安装与配置
是LJ的
博客等级 码龄5年 5粉丝 46原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值