源码安装httpd服务

编译安装httpd

编译安装apache需要三个源码包
下载   apr apr-util httpd

[root@xz ~]# yum groups mark install "Development Tools"  //安装开发工具包
[root@xz ~]# useradd -r -M -s /sbin/nologin apache
[root@xz ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
[root@xz ~]# yum -y install openssl-devel pcre-devel expat-devel libtool    
[root@xz ~]# yum - y install make  

下载源码包并解压

[root@xz ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz
[root@xz ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
[root@xz ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@xz ~]# tar -xf apr-1.7.0.tar.gz  
[root@xz ~]# tar -xf apr-util-1.6.1.tar.gz 
[root@xz~]# tar -xf httpd-2.4.53.tar.gz 
//安装apr
[root@xz ~]# cd apr-1.7.0/
[root@xz apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@xz apr-1.7.0]# make
[root@xz apr-1.7.0]# make install 
//安装apr-util
[root@xz ~]# cd apr-util-1.6.1/ 
[root@xz apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr   //apr-util是apr的子包 所以需要指定指定主包的位置
[root@xz apr-1.7.0]# make
[root@xz apr-1.7.0]# make install 
//安装httpd
[root@xz ~]# cd httpd-2.4.53/
[root@xz 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@xz apr-1.7.0]# make
[root@xz apr-1.7.0]# make install  

 设置环境变量

[root@xz ~]# ls /usr/local/   
apache  apr-util  etc    include  lib64    sbin   src
apr     bin       games  lib      libexec  share
[root@xz ~]# cd /usr/local/apache/
[root@xz apache]# ls   //环境变量的目录
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@xz ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@xz ~]# source /etc/profile.d/apache.sh
[root@xz ~]# which httpd
/usr/local/apache/bin/httpd
[root@xz ~]# which apachectl
/usr/local/apache/bin/apachectl

配置映射关系

[root@xz ~]# ls /usr/local/apache/   //有头文件include所以需要做链接
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@xz ~]# ln -s /usr/local/apache/include /usr/include/apache

配置man文档

[root@xz ~]# 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@xz ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

查看防火墙状态

[root@xz ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor pre>
   Active: inactive (dead)
     Docs: man:firewalld(1)

Apr 17 10:41:43 xz systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 17 10:41:45 xz systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 17 10:41:46 xz firewalld[1065]: WARNING: AllowZoneDrifting is enabled. This is>
Apr 17 13:05:21 xz systemd[1]: Stopping firewalld - dynamic firewall daemon...
Apr 17 13:05:21 xz systemd[1]: firewalld.service: Succeeded.
Apr 17 13:05:21 xz systemd[1]: Stopped firewalld - dynamic firewall daemon.
lines 1-11/11 (END)
[root@xz ~]# setenforce 0
[root@xz ~]# getenforce
Permissive
[root@xz ~]# vim /etc/selinux/config 
SELINUX=disabled    //让它永久生效
[root@xz ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
LISTEN   0        128                 [::]:22                [::]:*                
[root@xz ~]# which apachectl
/usr/local/apache/bin/apachectl
[root@xz ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe09:8f36%ens160. Set the 'ServerName' directive globally to suppress this message

[root@xz ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
LISTEN   0        128                 [::]:22                [::]:*                
LISTEN   0        128                    *:80                   *:*     

部署成功

[root@xz ~]# apachectl stop   //停用
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe09:8f36%ens160. Set the 'ServerName' directive globally to suppress this message
[root@xz ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
LISTEN   0        128                 [::]:22                [::]:*  
//取消警告提醒
[root@xz conf]# vim httpd.conf 

ServerName www.example.com:80//取消这个注释
[root@xz conf]# apachectl start
[root@xz conf]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128   
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值