安裝軟件
yum install httpd 安裝
/etc/init.d/httpd 啟動(dòng)腳本
/etc/httpd/conf/httpd.conf 配置文件
/var/www/html 主頁(yè)目錄
/var/log/httpd/ 日志文件
主配置文件
ServerRoot “/etc/httpd“ :服務(wù)主目錄
PidFile run/httpd.pid :PID文件
Listen 80 :監(jiān)聽端口
Include conf.d/*.conf :擴(kuò)展配置文件
User apache :?jiǎn)?dòng)用戶
Group apache :?jiǎn)?dòng)組
ServerAdmin root@localhost :管理員郵箱
ServerName www.example.com:80 :域名主機(jī)名
DocumentRoot “/var/www/html“ :默認(rèn)主頁(yè)存放目錄
DirectoryIndex index.html index.html.var :索引文件
ErrorLog logs/error_log :錯(cuò)誤日志
CustomLog logs/access_log combined :訪問(wèn)日志
訪問(wèn)控制設(shè)定
作用:對(duì)控制對(duì)特定主頁(yè)的訪問(wèn)瑞你,為相應(yīng)的目錄添加訪問(wèn)控制
分類:客戶機(jī)地址限制酪惭、用戶授權(quán)限制
擴(kuò)展配置文件中:
Options Indexes:文件共享 FollowSymLinks:符號(hào)連接
Order配置:定義控制順序
Order allow,deny:先允許后拒絕,默認(rèn)拒絕
Order deny,allow:先拒絕后允許者甲,默認(rèn)允許
配置方式:
Order allow,deny
Allow from IP地址或者網(wǎng)段
配置訪問(wèn)控制的過(guò)程
創(chuàng)建認(rèn)證用戶的數(shù)據(jù)庫(kù)
-htpasswd -c /etc/httpd/conf/.acluser 用戶名
添加認(rèn)證用戶
-htpasswd /etc/httpd/conf/.acluser 用戶名
添加用戶授權(quán)配置
<Directory "/var/www/html">
....
AuthName "ACL Directory" :自己定義顯示信息
AuthType Basic :認(rèn)證類型
AuthUserFile /etc/httpd/conf/.acluser :賬號(hào)文件
requoire valid-user :有效用戶可登陸
</Directory>
重啟服務(wù)
搭建虛擬主機(jī)
虛擬主機(jī)分類:
基于域名的虛擬主機(jī)
基于IP地址的虛擬主機(jī)
基于端口的虛擬主機(jī)
配置文件:
主dns配置文件格式
options
{
directory "/var/named";
};
zone "simpleware.com" IN
{
type master;
file "simpleware.com.zone";
allow-transfer { 192.168.0.100; }; \\允許誰(shuí)獲得區(qū)域配置文件
};
zone "0.168.192.in-addr.arpa" IN
{
type master;
file "192.168.0.zone";
allow-transfer { 192.168.0.100; };
};
zone "simplexue.com" IN
{
type master;
file "simplexue.com.zone";
allow-transfer { 192.168.0.100; };
};
從dns配置文件格式
options
{
directory "/var/named";
};
zone "simpleware.com" IN
{
type slave;
file "slaves/simpleware.com.zone"; \\區(qū)域文件保存位置
masters { 192.168.0.1; }; \\指定主dns服務(wù)器位置
};
zone "0.168.192.in-addr.arpa" IN
{
type slave;
file "slaves/192.168.0.zone";
masters { 192.168.0.1; };
};
apach配置:
NameVirtualHost 192.168.0.1:80
<VirtualHost 192.168.0.1:80>
DocumentRoot /var/www/html/simpleware
ServerName www.simpleware.com
</VirtualHost>
<VirtualHost 192.168.0.1:80>
DocumentRoot /var/www/html/simplexue
ServerName www.simplexue.com
</VirtualHost>