需要资源:apr、apr-util、pcre
1.配置依赖环境
1) 配置apr依赖
解压: tar -xf apr-1.7.0.tar.gz
进入到目录:cd apr-1.7.0
配置(设置安装在/usr/local/apr):./configure --prefix=./configure --prefix=/usr/local/apr
编译并安装:make && make install
2) 配置apr-util依赖
解压:tar -xf apr-util-1.6.1.tar.gz
进入到目录:cd apr-util-1.6.1/
配置(设置安装在/usr/local/apr-util):./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
编译并安装:make && make install
3) 配置pcre依赖
解压:tar -xf pcre-8.44.tar.bz2
进入到目录: cd pcre-8.44/
配置(设置安装在/usr/local/pcre):./configure --prefix=/usr/local/pcre
编译并安装:make && make install
2.配置安装httpd
解压:tar -xf httpd-2.4.51.tar.gz
进入到目录:cd httpd-2.4.51/
配置:./configure --prefix=/usr/local/http --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
编译并安装:make && make install
3.开启服务
到httpd的conf目录修改httpd.conf文件
进入到conf目录:cd /usr/local/httpd/conf
修改文件:vi httpd.conf
通过搜索ServerName(先Esc,在输入:/ServerName)
打开ServerName这一行注释
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName www.example.com:80
到bin目录开启服务
到bin目录下:cd /usr/local/httpd/bin
开启服务:./apachectl start
查询80端口:netstat -anlp | grep 80
打开浏览器输入虚拟机的IP地址如果页面显示 It works!
代表安装成功
4.异常分析:
由于版本比较新,好像指支持内核为5.,如果内核版本为3.或4.需要更新内核版本
如果虚拟机以前安装过,需要删除后重新安装
在编译安装时(忘记哪一步),有一个依赖要安装,安装提示yum安装即可