Linux安装Apache

  1. 下载apache
wget https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.gz --no-check-certificate
  1. 下载依赖
wget https://dlcdn.apache.org//apr/apr-1.7.0.tar.gz --no-check-certificate
wget https://dlcdn.apache.org//apr/apr-util-1.6.1.tar.gz --no-check-certificate
  1. 安装依赖
tar -zxvf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/usr/local/apr
make && make install
yum install expat-devel
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install 
  1. 安装apache
tar -zxvf httpd-2.4.51.tar.gz
cd httpd-2.4.51
##./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

##./configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=prefork --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
./configure --prefix=/usr/local/apache --enable-mods-shared=most --enable-headers --enable-mime-magic --enable-proxy --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-deflate --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --enable-remoteip
make && make install

编译说明:
  –prefix 指明程序安装目录 --enable-so 表示启用模块的动态装卸载功能
  --enable-ssl 表示启用ssl功能,此项可能需要先安装openssl-devel包
  --enable-cgi 表示启用支持cgi机制的功能 --enable-rewrite 表示支持url重写功能
  --enable-modules=most 表示启用的http模块有哪些,most表示启动大多数
  --enable-mpms-shared=all 表示以共享方式启用哪些MPM模块(prefork、worker、event), all表示所有的,此项为httpd2.4独有的选项,因为只有2.4才支持MPM的动态装卸载,2.2的MPM为静态的,只有编译进去,才能使用
  --with-mpm=prefork 表示默认启动的MPM是哪种
  --with-zlib 表示依赖zlib,用于支持压缩功能 没用=等号指明zlib的路径,则系统会自动到被依赖的文件的默认的路径去寻找, 如果被依赖的文件不是rpm安装,或不放在默认路径下,则需要手动利用=等号指明路径
  --with-pcre 表示依赖的pcre,用于支持url重写时支持正则表达式 --with-apr 依赖的apr
  --with-apr-util 依赖的apr-util

#复制服务
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
#配置支持chkconfig
vi /etc/init.d/httpd
#在!/bin/sh后面添加如下代码
#chkconfig:345 85 15
#
#description:Start and stop the Apache HTTP Server

#添加服务启动项
chkconfig --add httpd
#自启
chkconfig httpd on
#检查
chkconfig --list httpd
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

httpd           0:关    1:关    2:开    3:开    4:开    5:开    6:关
  1. 修改apache监听端口为88(避免和nginx商品冲突)
vi /usr/local/apache/conf/httpd.conf
 #开放88端口
 firewall-cmd --zone=public --add-port=88/tcp --permanent
 firewall-cmd --reload
 firewall-cmd --query-port=88/tcp

在这里插入图片描述

  1. 启动apache
 service httpd start

在这里插入图片描述
备注:如果service httpd start报如下错
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using ::1. Set the ‘ServerName’ directive globally to suppress this message
打开vi /usr/local/apache/conf/httpd.conf
修改#ServerName www.example.com:80为ServerName localhost:88
重启httpd即可

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大叔是90后大叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值