---------------------------------------------
配置文件  RPM 包安装
Apache  /etc/httpd/conf/httpd.conf

--------------------------------------------

apache 配置文件

--------------------------------

serverRoot "/etc/httpd"

ServerRoot用于指定apache服务器的配置
文件及日志文件存放的根目录,默认为目录

“/etc/httpd”

pidFile /var/run/httpd.id
 
  PidFile 用于指定记录httpd进程号(pid)的文件
位置,默认值为“/var/run/httpd.pid”

MaxKeepAilveRequests 100

每次连接可提出请求的数量,设置为0为不限,默认为100

KeepAileTimeout 15

连接两个请求之间的时间如果超过15秒还未到达,则视为连接
中断

DocumentRoot "/var/www/html"

指定apache服务器存放网页的文档根目录

##################################

UserDir

UserDir public_html

UserDir 用于设定用户个人主页存放的目录,默认为

“public_html”目录,即用/home/anyuser/public_html

为每个用户配置跟人主页

例如:为用户user1建立个人主页

cd /home/user1
mkdir public_html

chown user1.user1 public_html

cd ..
 
 chmod 711 user1

在/home/user1/public_html中建立index.html

使用浏览器http://localhost/~user1/

虚拟用户

############################################

Alias  用于设置路径别名

Alias /doc/ /usr/share/doc/

给 "/usr/share/doc" 设置路径别名为“/doc/”

************************************************
容器

<Directory / >     设置“/”根目录的访问权限

options

AllowOverride

Order

Allow

Deny

</ Directory>

五个属性

options 属性

options FollowSymLinks Indexes MultiViews

Options 可以组合设置下列选项

ALL:用户可以在此目录中做任何事情。

ExecCGI:允许在此目录中实行CGI程序

FollowSymLinks: 服务器可使用符号链接指向的文件或目录。

Indexes:服务器可生成此目录的文件列表。

None:不允许访问此目录。

AllowOverride None

AllowOverride 会根据设定的值决定是否读取目录中的
.htaccess文件,来改变运来所设置的权限。

All:读取.htaccess文件的内容,修改原来的访问权限

None:不读取.htaccess文件

为避免用户自行建立.htaccess文件修改访问权限,http.conf
文件中默认设置每个目录为:AllowOverride None.

AccessFileName filename

AccessFileName 指令用于指定保护目录设定文件的
文件名称,默认为“.htaccess”

AccessFileName .acl

-----------------------------------

APACHE虚拟目录

虚拟目录的优点:

便于访问

便于移动站点目录

加大磁盘空间

安全性好

Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

*******************************
首先在/etc/httpd/conf/httpd.conf
添加  Include vhost/vhost.conf

然后在 /etc/httpd/下创建 mkdir vhost

cd  vhost

vi vhost.conf 添加如下内容

Alias /test1 "/root/web/test1/"

<Directory "/root/web/test1">
    Options Indexes MultiViews
     AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Alias /test2 "/root/web/test2/"

<Directory "/root/web/test2">
    Options Indexes MultiViews
     AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

然后改变 chmod 755 -R /root/web/test1
         chmod 755 -R /root/web/test2

http://localhost/test1

http://localhost/test2

可以增加权限的设置。。。

apache 虚拟目录

deny 和allow 访问列表的几种形式

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

认证和授权

认证类型

basic(常用)  digest(再要认证)不常用

建立认证与授权的步骤

建立用户库
   配置服务器的保护域
   什么用户具有访问权限

认证指令

Authname           受保护领域名称
    Authtype            认证方式
    Authuserfile        认证口令文件
    Authgroupfile       认证组文件

Require use         授权指定用户
    Require group       授权指定组
    Require valid-user  授权给认证口令文件用户

建立用户库基本认证

htpasswd -c authfile username

口令文件格式
     
       username:password
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

用户认证:

例如:给添加认证

Alias /test2 "/root/web/test2/"

<Directory "/root/web/test2">
    Options Indexes MultiViews
    authtype basic
    authname "welcome test"
    authuserfile /etc/httpd/httppwd
    require Valid-user = user test
        
</Directory>

cd /etc/httpd 下实行  建立用户名和密码
      
               文件名 用户名
   htpasswd -c httppwd test

如果要添加多个用户那么只要第一使用过-c;以后都不用

htpasswd httppwd aaa
 
并在添加  Alias /test2 "/root/web/test2/"

require Valid-user = user test aaa

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
用户组授权
Alias /test2 "/root/web/test2/"

<Directory "/root/web/test2">
    Options Indexes MultiViews
    allowOverride None
    authtype basic
    authname "welcome admin"
    authuserfile /etc/httpd/httppwd
    authgroupfile /etc/httpd/httpgrp
    require group admin
   
        
</Directory>
 
vi httpgrp  添加 如下内容:
   admin:test aaa

必须在/etc/httpd/httppwd 和/etc/httpd/httpgrp 都存在相同的用户

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

用.htaccess 文件授权

Alias /test2 "/root/web/test2/"

<Directory "/root/web/test2">
    Options Indexes MultiViews
    
    AllowOverride all  
</Directory>

vi /var/www/test2/.htaccess
     authtype basic
    authname "welcome test"
    authuserfile /etc/httpd/httppwd
    require Valid-user

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

建立虚拟web站点

基于IP地址的虚拟主机;基于域名的虚拟主机(同IP,不同端口)

基于IP的虚拟主机的配置

<VirtualHost 169.254.1.234:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /root/web/test1/
</VirtualHost>

<VirtualHost 169.254.1.233:80>
   ServerAdmin webmaster@dummy-host.example.com
   DocumentRoot /root/web/test3/
</VirtualHost>

基于端口的虚拟主机配置

Listen 81
  Listen 82

<VirtualHost 169.254.1.234:81>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /root/web/test1/
    ServerName 169.254.1.234:81
</VirtualHost>

<VirtualHost 169.254.1.234:82>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /root/web/test3/
    ServerName 169.254.1.234:82
</VirtualHost>

-------------------------------------

转载于:https://blog.51cto.com/litclive/546435

apache服务器详细配置相关推荐

  1. Apache服务器全局配置之服务器标识配置篇

    Apache服务器全局配置之服务器标识配置篇   本文摘录自Apache2.2手册   服务器标识相关指令: ServerName ServerAdmin ServerSignature Server ...

  2. linux下apache服务器的配置和管理(启动、重启、中断服务)

    2019独角兽企业重金招聘Python工程师标准>>> linux下apache服务器的配置和管理 一.两个重要目录: Apache有两个重要的目录: 1.配置目录/etc/http ...

  3. SQLServer连接服务器维护,SQLServer远程连接服务器详细配置(sp_addlinkedserver)

    远程链接服务器详细配置 --建立连接服务器 EXEC sp_addlinkedserver '远程服务器IP','SQL Server' --标注存储 EXEC sp_addlinkedserver ...

  4. 怎么看服务器的内部性能参数,怎么看服务器详细配置参数

    怎么看服务器详细配置参数 内容精选 换一换 代码迁移工具进行代码迁移时,需要调用Linux下的rpm.deb等命令才能完成扫描和迁移相关任务,这些命令和逻辑必须在后端Linux运行.IDE插件只支持以 ...

  5. sp_addlinkedserver oracle,SQL Server 远程连接服务器详细配置(sp_addlinkedserver)

    远程链接服务器详细配置 --建立连接服务器 EXEC sp_addlinkedserver '远程服务器IP','SQL Server' --标注存储 EXEC sp_addlinkedserver ...

  6. Apache的详细配置

    http 协议名 apache 软件名 nginx httpd (http daemon;http服务) web 服务器 survey.netcraft.net --此网站会有每月份的世界上网站使用的 ...

  7. Apache服务器+tomcat配置

    2019独角兽企业重金招聘Python工程师标准>>> 1.安装Apache服务器 1.1 Windows下安装Apache 打开Apache Server的官网,可以看到上面只提供 ...

  8. apache服务器的配置

    1. apache的配置 1.1 安装apache2服务 yum install httpd -y 1.2 关闭防火墙 编辑sellinux配置文件:vim /etc/selinux/config 将 ...

  9. php如何配置apache服务器,Apache服务器如何配置PHP

    软件使用版本: Apache:httpd-2.2.21-win32-x86-no_ssl.msi 安装版 PHP: php-5.3.10-Win32-VC9-x86.zip 解压版(安装版的php中缺 ...

最新文章

  1. great sentences for university sentences
  2. 下载量过百万的吴恩达机器学习和深度学习笔记更新了!(附PDF下载)
  3. yii mysql语法_yii2 + mysql 常用增删改查操作语法以及事务
  4. 关于 SAP Spartacus UI 框架选型问题
  5. matlab 替换指定的元素
  6. 【计算机网络】TCP三次握手
  7. 优秀博客 --敏感词汇过滤
  8. mysql安装开始报错_MYSQL安装报错 -- 出现Failed to find valid data directory.
  9. HCIE Security 二层攻击防范 备考笔记(幕布)
  10. 拓端tecdat|python爬虫进行Web抓取LDA主题语义数据分析报告
  11. 开启打印服务Print Spooler
  12. Codevs 2800 送外卖(状压DP)
  13. 机器学习之决策树、随机森林
  14. UE4 3DUI Widget半透明渲染模糊和重影问题
  15. jQuery自动补全邮箱后缀列表插件
  16. 知识图谱学习(二):电商知识图谱
  17. linux的sssd服务,系统安全服务守护进程SSSD
  18. 转:用调制解调器打电话收传真-ModemFax
  19. Android Studio 开发(二)问题
  20. opencv中 equalizeHist()均衡化直方图

热门文章

  1. 故障闪烁过渡网页幻灯片特效源码
  2. Spring Cloud微服务之业务物理删除(十)
  3. DotFuscator使用步骤
  4. Linux: terminal 终端生存指南
  5. Mysql: LBS实现查找附近的人 (两经纬度之间的距离)
  6. 一分钟解决“仅限中国大陆地区播放”
  7. 一些上流的CSS3图片样式
  8. ubuntu 添加 qq
  9. ffmpeg——vs集成ffmpeg相关开发
  10. linux chcon命令详解