龙之介大人

CentOS 7编译安装Apache 2.4
Apache HTTP ServerApache HTTP Server(简称Apache)是Apache软件基金...
扫描右侧二维码阅读全文
29
2019/01

CentOS 7编译安装Apache 2.4

Apache HTTP Server

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

编译所需依赖

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编译安装过程

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编译安装过程

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编译安装过程

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
vim /etc/httpd/httpd.conf 
#找到156 157行把 daemon修改为www
156 User www
157 Group www
#添加ServerName
ServerName localhost:80

增加Apache环境变量

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

增加Apache自启

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就自己摸索吧!!!

最后修改:2019 年 01 月 29 日 11 : 24 PM

2 条评论

  1. centos

    怎么会一直是这个样子 配置好多遍还是这个样子 这是因为什么造成的

    1. 龙之介大人
      @centos

      是那个步骤编译有问题,有报错信息吗?

发表评论 取消回复