2021-11-14 15:52:46 +08:00

66 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Httpd 笔记"
date: 2019-10-30T11:28:36+08:00
lastmod: 2019-10-30T11:28:36+08:00
tags: ["httpd"]
categories: ["web"]
---
## CentOS7 安装
```bash
yum install httpd
```
## 支持 SVN
- 安装 svn 模块
```bash
yum install mod_dav_svn subversion
```
- 建立 svn 库 test_prj
```bash
mkdir -p /mnt/vdb1/svn_repos/test_prj
svnadmin create /mnt/vdb1/svn_repos/test_prj
```
- 编辑 test_prj 下 conf 目录中的 authz 和 passwd 文件,配置权限
- 启动 svn
```bash
svnserve -d -r /mnt/vdb1/svn_repos/
#客户端测试
svn checkout svn://{ip}/test_prj
```
- 编辑 /etc/httpd/conf.modules.d/10-subversion.conf追加如下
```xml
<Location /test_prj/>
DAV svn
SVNListParentPath off
SVNPath /mnt/vdb1/svn_repos/test_prj/
#Satisfy Any
AuthzSVNAccessFile /mnt/vdb1/svn_repos/test_prj/conf/authz
Require valid-user
</Location>
```
- 增加 apache 用户读写 test_prj 目录的权限
```bash
usermod -a -G root apache
chmod -R g+w /mnt/vdb1/svn_repos/
```
- 重启 httpd 服务
```bash
systemctl restart httpd
```
## Basic HTTP 认证
- 生成密码文件(用户名是admin密码是123456)
```bash
htpasswd -c -m /etc/httpd/httpd.auth admin # 按提示输入密码
```
- 在 Location 中配置如下
```xml
<Location />
AuthType Basic
AuthName "提示信息"
AuthUserFile /etc/httpd/httpd.auth
</Location>
```