Apach源码安装实验
时间:2019.8.14
实验类型:Apache源码安装实验
实验环境:Redhat7.4
实验准备:Redhat7.4虚拟机、apr-1.6.3 、 apr-util-1.6.1、httpd-2.4.34安装包
1、安装开发工具包
[root@localhost ~]# yum group mark install 'Development Tool'
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Marked install: Development Tool
2、创建apache服务的用户和组
[root@localhost ~]# groupadd -r apache
[root@localhost ~]# useradd -r -M -s /sbin/nologin -g apache apache
3、安装依赖包
[root@localhost ~]# yum -y install openssl-devel prce-devel expat-devel libtool
4、解压安装arp和arp-util包
[root@localhost ~]# tar xf apr-1.6.3.tar.bz2
[root@localhost ~]# tar xf apr-util-1.6.1.tar.bz2
[root@localhost ~]# ls
2.txt apr-1.6.3 apr-util-1.6.1
5、配置并编译安装arp和arp-util包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
apr-1.6.3 apr-1.6.3.tar.bz2 apr-util-1.6.1 debug kernels
[root@localhost src]# cd apr-1.6.3
[root@localhost apr-1.6.3]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //注释或删除此行
[root@localhost apr-1.6.3]# ./configure --prefix=/apr //配置
[root@localhost apr-1.6.3]# make && make install //编译安装
[root@localhost ~]# cd /usr/src/apr-util-1.6.1
[root@localhost apr-util-1.6.1]# configure--prefix=/apr-util -with-apr=/apr
[root@localhost apr-util-1.6.1]# make && make install
6、配置并编译安装httpd
[root@localhost httpd-2.4.34]# cd httpd-2.4.34
[root@localhost httpd-2.4.34]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
7、编译安装过程
[root@localhost httpd-2.4.34]# make && make install
8、安装后配置
[root@localhost ~]# echo 'PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@localhost ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
[root@localhost ~]# sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf
9、启动apache,查看开启端口
[root@localhost ~]# apachectl start
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
10、在网页的首页文件中写入文件,并关闭防火墙,开启httpd服务
[root@localhost htdocs]# echo "Hello WuHan" > index.html
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# apachectl start
httpd (pid 33364) already running