01源码安装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) 3月 30 11:08:46 CentOS7-4 systemd[1]: Starting firewalld - dynamic firewall daemon... 3月 30 11:08:46 CentOS7-4 systemd[1]: Started firewalld - dynamic firewall daemon. 3月 30 11:08:46 CentOS7-4 firewalld[1228]: WARNING: AllowZoneDrifting is enabled. This is considered ...now. 3月 30 11:09:16 CentOS7-4 systemd[1]: Stopping firewalld - dynamic firewall daemon... 3月 30 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
-
访问