前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 7编译安装Apache 2.4

CentOS 7编译安装Apache 2.4

作者头像
小柒吃地瓜
修改2020-04-21 17:12:15
1.6K0
修改2020-04-21 17:12:15
举报
文章被收录于专栏:梦在深巷梦在深巷

Apache HTTP Server

Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源代码的网页服务器软件,可以在大多数计算机操作系统中运行。由于其跨平台和安全性注 1,被广泛使用,是最流行的Web服务器软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。

编译所需依赖

代码语言:javascript
复制
wget
make
gcc 
gcc-c++ 
pcre 
openssl 
openssl-devel 
zlib 
unzip 
cmake 
ncurses-devel expat-devel
libjpeg libjpeg-devel libpng libpng-del libxml2 libxml2-devel 
curl-devel 
libtool libtool-ltdl libtool-ltdl-devel libevent libevent-devel 
zlib-static 
zlib-devel 
autoconf 
pcre-devel 
gd 
perl 
freetype freetype-devel

yum安装就行,可以选择系统没有的依赖安装;也可以安装全部依赖

apr编译安装过程

代码语言:javascript
复制
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.gz
tar -zxvf apr-1.6.5.tar.gz
cd apr-1.6.5
./configure --prefix=/etc/apr/
make && make install    

如果地址404可以访问:apr目录地址获取最新下载地址

apr-util编译安装过程

代码语言:javascript
复制
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz 
cd apr-util-1.6.1
./configure --prefix=/etc/apr-util --with-apr=/etc/apr
make && make install

如果地址404可以访问:apr目录地址获取最新下载地址

Apache编译安装过程

代码语言:javascript
复制
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.38.tar.gz
tar -axvf httpd-2.4.38.tar.gz 
cd httpd-2.4.38
chmod 777 *

#编译
./configure --prefix=/etc/apache/ \
--sysconfdir=/etc/httpd/ \
--with-include-apr \
--disable-userdir \
--enable-headers \
--with-mpm=worker \
--enable-modules=most \
--enable-so \
--enable-deflate \
--enable-defate=shared \
--enable-expires-shared \
--enable-rewrite=shared \
--enable-static-support \
--with-apr=/etc/apr/ \
--with-apr-util=/etc/apr-util/bin \
--with-ssl \
--with-z 

make && make install

#创建运行Apache的用户
groupadd www
useradd -g www www -s /bin/false 
  • configure正确的信息

*make && make install正确的信息

修改Apache配置文件

  • 配置文件路径/etc/httpd/httpd.conf
代码语言:javascript
复制
vim /etc/httpd/httpd.conf 
#找到156 157行把 daemon修改为www
156 User www
157 Group www
#添加ServerName
ServerName localhost:80

增加Apache环境变量

代码语言:javascript
复制
vim /etc/profile
#在文件的末尾加上
export PATH=$PATH:/etc/apache/bin/
#行下面命令更新环境变量
source /etc/profile

增加Apache自启

代码语言:javascript
复制
cp /etc/apache/bin/apachectl /etc/init.d/httpd
#修改启动脚本
vim /etc/init.d/httpd 

#在#!/bin/bash后添加一下内容
####STA
#chkconfig:345 61 61
#description:Apache httpd
####END

#添加服务
chkconfig --add httpd
chkconfig --level 2345 httpd on

Apache启动方式

  • /etc/init.d/httpd start|stop|restart分别是开启|停止|重启
bin目录下有个ab的nb工具哦!为什么nb就自己摸索吧!!!

版权属于:龙之介大人

本文链接:https://cloud.tencent.com/developer/article/1617653

本站所有原创文章采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 您可以自由的转载和修改,但请务必注明文章来源和作者署名并说明文章非原创且不可用于商业目的。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019 年 01 月,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Apache HTTP Server
  • 编译所需依赖
  • apr编译安装过程
  • apr-util编译安装过程
  • Apache编译安装过程
  • 修改Apache配置文件
  • 增加Apache环境变量
  • 增加Apache自启
  • Apache启动方式
    • bin目录下有个ab的nb工具哦!为什么nb就自己摸索吧!!!
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档