apache手册:http://httpd.apache.org/docs/current/install.html
在安装apache之前,需要先安装APR、APR-util、PCRE,另外Ubuntu需要安装libexpat1-dev,CentOS和RHEL需要安装expat-devel
获取安装包
apr / apr-util:http://mirrors.hust.edu.cn/apache/apr/ 或 http://mirror.bit.edu.cn/apache/apr/
pcre:https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
apache:http://mirrors.hust.edu.cn/apache/httpd/
依赖包安装
1)安装编译器gcc、gcc-c++
yum install -y gcc gcc-c++
2)安装依赖包expat-devel、zlib-devel、openssl-devel
yum install -y expat-devel zlib-devel openssl-devel
3) 安装依赖包apr
tar zxvf apr-1.6.2.tar.gz
cd apr-1.6.2
./configure --prefix=/usr/local/apr
make && make install
3) 安装依赖包apr-util
tar zxvf apr-util-1.6.0.tar.gz
cd apr-util-1.6.0
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
4) 安装依赖包pcre
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure --prefix=/usr/local/pcre
make && make install
Apache安装
1)解压
2)将apr、apr-util安装包拷贝到Apach
[root@centos7 opt]# cp -r apr-1.7.0 httpd-2.4.41/srclib/apr
[root@centos7 opt]# cp -r apr-util-1.6.1 httpd-2.4.41/srclib/apr-util
3)编译、安装
cd httpd-2.4.41
./configure --prefix=/usr/local/server/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-mysql=shared,mysqlnd --enable-so --enable-ssl --enable-deflate --enable-rewrite --enable-headers --enable-expires --disable-cgid--disable-cgi
make
make install
4)修改配置文件httpd.conf
编辑 /usr/local/server/apache/conf/httpd.conf
配置文件
去掉ServerName前面的 #,并将ServerName后面的网址改为localhost:80
5)将httpd加入系统服务并设置开机自启
将httpd加入系统服务:
cp /usr/local/server/apache/bin/apachectl /etc/init.d/httpd
## 修改/etc/init.d/httpd,在第3行加入以下内容(注意: 代码中的 # 不可以去掉):
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
设置系统服务开机自启:systemctl enable httpd
https://blog.csdn.net/weixin_42075590/article/details/80741211