centos 7 源码包安装apache2

centos 7 源码包安装apache2

主配置文件httpd.conf说明

准备工作:卸载htttpd及相关依赖包

Rpm  -e   httpd  --nodeps

解压缩软件包并进入源代码目录:tar  zxf  httpd-*  -C  /usr/src

Cd /usr/src/httpd*  (*代表键盘上的tab键)

2)配置:检测系统是否满足安装要求

./configure --prefix=/usr/local/httpd --enable-so  --enable-rewrite

选项:--prefix=/安装目录     指定软件安装目录的路径

--enable-so           动态加载模块

--enable-rewrite       支持网页地址重写

3)编译:将源代码转换为二进制文件     Make

4) 安装:将二进制文件复制到系统中   Make  install

5) 启动http服务

/usr/local/httpd/bin/apachectl  restart

3、 httpd主要目录和文件

1)服务器根目录:/usr/local/httpd   由—prefix指定

2)配置文件目录:conf

主配置文件名为:httpd.conf

3)网页目录:htdocs

4)执行程序目录:bin

启动命令:apachectl

5)日志目录:logs

有两个日志文件:访问日志:access_log

错误日志:error_log

语法检查命令:/usr/local/httpd/bin/apachectl  -t

/usr/local/httpd/bin/httpd   -t

4、 主配置文件httpd.conf的配置项

1)ServerRoot:服务器的根目录   默认为安装的路径

2)ServerAdmin:管理员的邮箱

3)ServerName:服务器域名

4)User和Group:运行服务的用户和组  默认为:daemon

5)DocumentRoot:网页文档的根目录  默认为:htdocs

6)Listen:监听的ip地址、端口号   默认监听端口

7)PidFile:指定PID号的文件       默认为:httpd.pid

8)DirectoryIndex:默认主页         默认主页名称为:index.html

9) Include:需要包含的其他配置文件

5、Awstats 日志分析系统

Awstats是使用pert语言开发的一款开源日志分析系统,可分析Apache、Samba、Vsftp、IIS等服务的日志信息,可同时分析多个服务的日志,结合crond等计划任务,可定期分析日志信息,可使用自动跳转的网页简化访问路径。

在控制台显示PATH环境变量的值:echo  SPATH

优化:In  -s  /usr/local/httpd/bin/*    /usr/local/bin/

实验要求:

1、 WEB服务器:

使用源码包apache实现。安装完成后,并优化执行路径。
启动服务后,客户端通过http://IP能访问默认的网站。
2、 DNS服务器:

安装DNS所需的软件包
创建一个正向区域(benet.com),并将www.benet.com解析为WEB服务器的IP地址。
启动服务后,客户端通过http://www.benet.com能访问默认的网站。
3、 Awstats日志监控服务器

配置awstats,并实现能监控到web服务器上的默认网站的访问日志
客户端访问awstats的网站,并查看和统计到默认网站的访问日志情况。
apache 官方安装文档
http://httpd.apache.org/docs/2.4/en/install.html
北京外国语大学开源软件镜像站
https://mirrors.bfsu.edu.cn/

下载相关软件 
yum -y install wget

wget -c https://mirrors.bfsu.edu.cn/apache//apr/apr-1.7.0.tar.gz

wget -c https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

wget -c https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz

wget -c https://www.openssl.org/source/openssl-1.1.1i.tar.gz

wget -c https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.gz

安装 apache 相关依赖库
yum -y install  gcc  gcc-c++ libtool libtool-ltdl libtool-ltdl-devel expat-devel

解压和安装

1.安装 apr 

************************************************************
tar -zxvf apr-1.7.0.tar.gz

cd apr-1.7.0
vim configure   
将 RM='$RM'  改成 RM='$RM -f'
./configure  --prefix=/usr/apr  #指定安装的位置 
make && make install 


************************************************************

2.安装 apr-util  
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/apr
make && make install 

************************************************************
3.安装pcre 
tar -zxvf pcre-8.44.tar.gz
cd  pcre-8.44
./configure --prefix=/usr/local/pcre
make && make install 

************************************************************
4.安装openssl  
tar -zxvf openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./config 
make && make install 

************************************************************
5.httpd 


tar -zxvf httpd-2.4.46.tar.gz

cp -rf /root/yoyo/apr-1.7.0   /root/yoyo/httpd-2.4.46/srclib/apr

cp -rf /root/yoyo/apr-util-1.6.1  /root/yoyo/httpd-2.4.46/srclib/apr-util

cd /root/yoyo/httpd-2.4.46/   

./configure --prefix=/usr/local/httpd  --with-included-apr --sysconfdir=/etc/httpd/ --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr/local/pcre --with-apr=/usr/apr --with-apr-util=/usr/local/apr-util

make && make install 

************************************************************

启动服务

启动http服务:/usr/local/httpd/bin/apachectl  restart
语法检查命令:/usr/local/httpd/bin/apachectl  -t



cd /usr/local/httpd/bin 

[root@localhost bin]# ./apachectl start 
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

cd /etc/httpd/
 cp httpd.conf httpd.conf.bak
vim httpd.conf

底部命令模式  :set nu  
:199  
ServerName 127.0.0.1:80  


cd /usr/local/httpd/bin/
[root@localhost bin]# ./apachectl restart 
systemctl stop firewalld.service #关闭防火墙  


 cd /var/www/html/
vim index.html  改成你想要的内容 

在浏览器 输入该服务器的ip地址


参考链接
https://blog.csdn.net/weixin_46021446/article/details/112786697#comments_14670017

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值