Centos7学习心得一 基础配置-配置apache
yum安装
比较简单centos7中Apache可以通过yum直接安装,并解决相关依赖
yum install httpd
源码安装
想要了解Apache的安装过程,可以通过源码安装,附所需安装软件
所需软件
httpd
apr
apr-util
PCRE
EXPAT 可以通过yum安装 yum install expat-devel
下载所需软件后拷贝到centos主机 也可以使用wget命令进行下载
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
如果提示没有安装wget yum安装即可
-bash: wget: command not found
yum install wget
tar解压
tar -xvf apr-1.7.0.tar.gz
tar -xvf apr-util-1.6.1.tar.gz
tar -xvf pcre-8.43.tar.gz
tar -xvf httpd-2.4.39.tar.gz
解压后将apr apr-util pcre 拷贝到httpd的srclib下
cp-r apr-1.7.0 httpd-2.4.39/srclib/
cp -r apr-1.7.0 httpd-2.4.39/srclib/
cp -r apr-util-1.6.1 httpd-2.4.39/srclib/
cp -r pcre-8.43 httpd-2.4.39/srclib/
更改文件名,要求文件和名字要一致
mv apr-1.7.0 apr
mv apr-util-1.6.1 apr-util
mv pcre-8.43 pcrebak
apr,apr-util两个在编译安装httpd的同时会自动安装,无需之前安装,但是pcre发现并没有自动安装,需要手动编译一下,cd至pcre目录进行编译安装
编译前需要安装gcc gcc-c++ expat
yum install gcc
yum install expat*
yum list gcc-c++*
装pcre发现make时候报错
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/local/httpsrc/httpd-2.4.39/srclib/pcre-8.43/missing aclocal-1.16 -I m4
/usr/local/httpsrc/httpd-2.4.39/srclib/pcre-8.43/missing: line 81: aclocal-1.16: command not found
WARNING: 'aclocal-1.16' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<https://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<https://www.gnu.org/software/autoconf>
<https://www.gnu.org/software/m4/>
<https://www.perl.org/>
make: *** [aclocal.m4] Error 127
查了一下错误信息,网上有说是解压过程中系统时间戳的问题,没有实践,相关链接
最后发现解压后直接安装就不会出现这个问题。(不知道为什么,可能时间戳刚解完压缩是正常的)
准备工作做好准备源码安装Apache
./configure --prefix=/usr/local/httpd --enable-rewrite --enable-so --with-pcre=/usr/local/httpsrc/httpd-2.4.39/srclib/pcre
make
make install
开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
运行
/usr/local/httpd/bin/apachectl start