Apache笔记
Apache 访问控制的配置
为用户访问页面添加账户和密码
在发布网站的目录下创建一个.htaccess文件
写入内容如下:
httpd.conf配置文件中的内容:
需要安装一个httpd-tools的一个工具
yum install httpd-tools
htpasswd -c(新建)/home/user/user_html/.htpasswd tom(用户名) 123(密码)
再次创建就不用-c参数了
测试需要重启服务
Apache 虚拟主机的配置
1, 基于域名的虚拟主机:
Namevirtual 192.168.1.88(地址):80(端口号)
<virtualhost 192.168.1.88:80>
ServerAdmin [email protected](管理员邮箱)
DocumentRoot "/www/docs/host.example.com"(网页存放目录)
ServerName host.example.com(域名)
ErrorLog "logs/host.example.com-error_log"(错误日志)
CustomLog "logs/host.example.com-access_log"(访问日志)common
</virtualhost>
1, 基于端口号的虚拟主机:
1, 基于IP的虚拟主机:
在/etc/hosts文件中更改域名相对应的IP地址
用ifconfig eth0:0 192.168.248.131 来添加IP地址
重启Apache服务