Apache 服务器配置详细教程
发布:smiling 来源: PHP粉丝网 添加日期:2013-11-23 15:03:49 浏览: 评论:0
用户认证的配置
(1)in the httpd.conf:
- accessfilename .htaccess
- .........
- alias /download/ "/var/www/download/"
"/var/www/download" >- options indexes
- allowoverride authconfig
(2) create a password file:
- /usr/local/apache2/bin/htpasswd -c /var/httpuser/passwords bearzhang
(3)onfigure the server to request a password and tell the server which users are allowed access.
- vi /var/www/download/.htaccess:
- authtype basic
- authname "restricted files"
- authuserfile /var/httpuser/passwords
- require user bearzhang
- #require valid-user #all valid user
虚拟主机的配置
(1)基于ip地址的虚拟主机配置 listen 80
- documentroot /www/example1
- servername www.example1.com
- documentroot /www/example2
- servername www.example2.org
(2) 基于ip和多端口的虚拟主机配置
- listen 172.20.30.40:80
- listen 172.20.30.40:8080
- listen 172.20.30.50:80
- listen 172.20.30.50:8080
- documentroot /www/example1-80
- servername www.example1.com
- documentroot /www/example1-8080
- servername www.example1.com
- documentroot /www/example2-80
- servername www.example1.org
- documentroot /www/example2-8080
- servername www.example2.org
(3)单个ip地址的服务器上基于域名的虚拟主机配置:
- # ensure that apache listens on port 80
- listen 80
- # listen for virtual host requests on all ip addresses
- namevirtualhost *:80
- documentroot /www/example1
- servername www.example1.com
- serveralias example1.com. *.example1.com
- # other directives here
- documentroot /www/example2
- servername www.example2.org
- # other directives here
(4)在多个ip地址的服务器上配置基于域名的虚拟主机:
listen 80
- # this is the "main" server running on 172.20.30.40
- servername server.domain.com
- documentroot /www/mainserver
- # this is the other address
- namevirtualhost 172.20.30.50
- documentroot /www/example1
- servername www.example1.com
- # other directives here ...
- documentroot /www/example2
- servername www.example2.org
- # other directives here ...
(5)在不同的端口上运行不同的站点(基于多端口的服务器上配置基于域名的虚拟主机):
- listen 80
- listen 8080
- namevirtualhost 172.20.30.40:80
- namevirtualhost 172.20.30.40:8080
- servername www.example1.com
- documentroot /www/domain-80
- servername www.example1.com
- documentroot /www/domain-8080
- servername www.example2.org
- documentroot /www/otherdomain-80
- servername www.example2.org
- documentroot /www/otherdomain-8080
(6)基于域名和基于ip的混合虚拟主机的配置:
- listen 80
- namevirtualhost 172.20.30.40
- documentroot /www/example1
- servername www.example1.com
- documentroot /www/example2
- servername www.example2.org
- documentroot /www/example3
- servername www.example3.net
Tags: Apache 服务器 配置
相关文章
- ·在apache下限制每个虚拟主机的并发数(2013-11-14)
- ·APACHE禁止图片盗链(2013-11-14)
- ·Apache下的虚拟主机设置(2013-11-14)
- ·Apache中禁止IP段,在httpd.conf中的写法(2013-11-14)
- ·用Apache的rewrite生成伪静态页面(2013-11-14)
- ·HTTP/Apache 错误代码汇总(2013-11-14)
- ·Apache性能优化技巧(2013-11-22)
- ·用Session代替Apache服务器验证(2013-11-22)
- ·Apache中httpd.conf的中文件详解(2013-11-22)
- ·Apache中.Htaccess文件的功能写法(2013-11-22)
- ·如何让apache支持.htaccess并设置404错误页(2013-11-22)
- ·apache 虚拟主机配置[别名配置方法](2013-11-22)
- ·apache 服务器网站不能访问(2013-11-22)
- ·apache教程:.htaccess用法(2013-11-22)
- ·Apache二级域名配置方法(2013-11-22)
- ·apache 封IP基础教程(2013-11-22)