Linux源码安装httpd

源码安装httpd

一、环境准备
  • 安装环境

    [root@CentOS7-4 ~]# yum -y install gcc gcc-c++ make pcre-devel apr-devel expat-devel libdb-devel cyrus-sasl-devel openldap-devel apr-util-devel
    
  • 检测编译环境

    [root@CentOS7-4 ~]# gcc --version
    gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
    Copyright © 2015 Free Software Foundation, Inc.
    本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
    包括没有适销性和某一专用目的下的适用性担保。
    [root@CentOS7-4 ~]# make --version
    GNU Make 3.82
    Built for x86_64-redhat-linux-gnu
    Copyright (C) 2010  Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
  • 关闭防火墙

    #关闭防火墙
    [root@CentOS7-4 ~]# systemctl stop firewalld
    #查看防火墙状态
    [root@CentOS7-4 ~]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
       Active: inactive (dead)
         Docs: man:firewalld(1)
    
    330 11:08:46 CentOS7-4 systemd[1]: Starting firewalld - dynamic firewall daemon...
    330 11:08:46 CentOS7-4 systemd[1]: Started firewalld - dynamic firewall daemon.
    330 11:08:46 CentOS7-4 firewalld[1228]: WARNING: AllowZoneDrifting is enabled. This is considered ...now.
    330 11:09:16 CentOS7-4 systemd[1]: Stopping firewalld - dynamic firewall daemon...
    330 11:09:16 CentOS7-4 systemd[1]: Stopped firewalld - dynamic firewall daemon.
    Hint: Some lines were ellipsized, use -l to show in full.
    

    在这里插入图片描述

二、上传HTTPD源码包
1.第一种
  • 上传HTTPD软件包

    C:\Users\Administrator>scp D:\httpd-2.4.9.tar.gz root@192.168.88.131:/usr/src/
    root@192.168.88.131's password:
    httpd-2.4.9.tar.gz                              			                100% 6625KB 125.4MB/s   00:00
    

    在这里插入图片描述

  • 查看上传成功

    [root@CentOS7-4 ~]# ls /usr/src/
    debug  httpd-2.4.9.tar.gz  kernels
    
2.第二种上传
  • 利用xshell上传

    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

    [root@CentOS7-4 ~]# ls /usr/src
    debug  httpd-2.4.9.tar.gz  kernels
    
三、开始安装
  • 解压

    #进入目录
    [root@CentOS7-4 ~]# cd /usr/src/
    #解压
    [root@CentOS7-4 src]# tar -zxvf httpd-2.4.9.tar.gz 
    #查看
    [root@CentOS7-4 src]# ls
    debug  httpd-2.4.9  httpd-2.4.9.tar.gz  kernels
    
  • 配置

    [root@CentOS7-4 ~]# cd httpd-2.4.9/
    [root@CentOS7-4 httpd-2.4.9]# ./configure --prefix=/usr/local/apache
    
  • 编译

    [root@CentOS7-4 ~]#make
    
  • 安装

    [root@CentOS7-4 ~]#make install
    
  • 修改配置文件

    [root@CentOS7-4 httpd-2.4.9]# vi /usr/local/apache/conf/httpd.conf
    #set nu --显示行数
    

    在这里插入图片描述

    在这里插入图片描述

  • 光标移到192行,按键盘的i插入模式

    在这里插入图片描述

  • 改好之后,按键盘上的Esc,再按键盘上的Shift+:,输入wq保存并退出,回车

  • 启动服务

    [root@CentOS7-4 httpd-2.4.9]# /usr/local/apache/bin/apachectl start
    
  • 查看端口

    [root@CentOS7-4 httpd-2.4.9]# netstat -anpt
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      942/sshd            
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1099/master         
    tcp        0     36 192.168.88.131:22       192.168.88.1:60293      ESTABLISHED 1193/sshd: root@pts 
    tcp6       0      0 :::80                   :::*                    LISTEN      27157/httpd         
    tcp6       0      0 :::22                   :::*                    LISTEN      942/sshd            
    tcp6       0      0 ::1:25                  :::*                    LISTEN      1099/master    
    
  • 访问

    在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值