默认的初始站点配置
安装后,有一个默认站点,其配置都在的主配置文件(httpd.conf)中,主要包括如下几项 。
1、站点域名:
## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.##ServerName www.example.com:80 -》 默认配置就是 127.0.0.1# 现在我们需要自定义一个 ServerNameServerName 127.0.0.1
2、站点位置(文件夹位置) :
## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.## /Library/WebServer/Documents -》 默认根目录# /Users/dengzemiao/Sites -》 自定义根目录DocumentRoot "/Users/dengzemiao/Sites"
3、站点文件夹的访问权限设置: …
设置访问形式如下:
// 三项为固定写法 前面 key 后面 配置参数
4、站点默认显示的网页(首页) :
# DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#
我们可以理解为:
: 是对外看的,也就是域名给别人用的 。
: 其实指向的就是路径,相当于=。
:能管理这个路径的访问权限,
:设置这个路径默认要展示文件 。
1、在的主配置文件(httpd.conf) ,引入多站点的配置文件(虚拟主机配置文件),在 httpd.conf 搜索 “httpd-.conf”,打开注释:
# Virtual hostsInclude /private/etc/apache2/extra/httpd-vhosts.conf
httpd.conf 中还有一个文件 “.so” ,这个文件专门解决多次或者重复配置的站点,也就是可以写一个站点模板,里面都是自适应填充站点内容找到对应文件,这个可以单独去了解一下,这里我就不打开了,但是推荐使用这个 。
文章插图
【PHP Apache - 多站点虚拟主机配置】
#LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
2、在虚拟主机配置文件 (httpd-.conf)中,再挨个网站进行配置(每个网站一段配置),我们找到 httpd-.conf 文件打开,我们把里面的所有东西都注释掉,自己来配置 。
# Virtual Hosts## Required modules: mod_log_config# If you want to maintain multiple domains/hostnames on your# machine you can setup VirtualHost containers for them. Most configurations# use only name-based virtual hosts so the server doesn't need to worry about# IP addresses. This is indicated by the asterisks in the directives below.## Please see the documentation at # # for further details before you try to setup virtual hosts.## You may use the command line option '-S' to verify your virtual host# configuration.## VirtualHost example:# Almost any Apache directive may go into a VirtualHost container.# The first VirtualHost section is used for all requests that do not# match a ServerName or ServerAlias in any block.## #ServerAdmin webmaster@dummy-host.example.com#DocumentRoot "/usr/docs/dummy-host.example.com"#ServerName dummy-host.example.com#ServerAlias www.dummy-host.example.com#ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"#CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common# # #ServerAdmin webmaster@dummy-host2.example.com#DocumentRoot "/usr/docs/dummy-host2.example.com"#ServerName dummy-host2.example.com#ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"#CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common#
# 默认都是 80 端口,如果你的端口不是可以进行修改# 站点1:(第一个站点,被称为默认站点)# 域名ServerName localhost# 域名根目录DocumentRoot "/Users/dengzemiao/Sites"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php
# Virtual Hosts## Required modules: mod_log_config# If you want to maintain multiple domains/hostnames on your# machine you can setup VirtualHost containers for them. Most configurations# use only name-based virtual hosts so the server doesn't need to worry about# IP addresses. This is indicated by the asterisks in the directives below.## Please see the documentation at # # for further details before you try to setup virtual hosts.## You may use the command line option '-S' to verify your virtual host# configuration.## VirtualHost example:# Almost any Apache directive may go into a VirtualHost container.# The first VirtualHost section is used for all requests that do not# match a ServerName or ServerAlias in any block.## #ServerAdmin webmaster@dummy-host.example.com#DocumentRoot "/usr/docs/dummy-host.example.com"#ServerName dummy-host.example.com#ServerAlias www.dummy-host.example.com#ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"#CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common# # #ServerAdmin webmaster@dummy-host2.example.com#DocumentRoot "/usr/docs/dummy-host2.example.com"#ServerName dummy-host2.example.com#ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"#CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common# # 自定义多个站点配置# 默认都是 80 端口,如果你的端口不是可以进行修改# 站点1:(第一个站点,被称为默认站点)(一般都会配置一个 localhost 方便访问主目录)# 域名ServerName localhost# 域名根目录DocumentRoot "/Users/dengzemiao/Sites"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php # 站点2:# 域名ServerName www.dzm.com# 错误日志ErrorLog "/Users/dengzemiao/Sites/dzm/error.log"# 成功日志CustomLog "/Users/dengzemiao/Sites/dzm/access.log" combined# 域名根目录DocumentRoot "/Users/dengzemiao/Sites/dzm"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php # 站点3:# 域名ServerName www.xyq.com# 错误日志ErrorLog "/Users/dengzemiao/Sites/xyq/error.log"# 成功日志CustomLog "/Users/dengzemiao/Sites/xyq/access.log" combined# 域名根目录DocumentRoot "/Users/dengzemiao/Sites/xyq"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php
/private/etc
# 自定义多个站点配置# 默认都是 80 端口,如果你的端口不是可以进行修改# 站点1:(第一个站点,被称为默认站点)(一般都会配置一个 localhost 方便访问主目录)# 域名ServerName localhost# 域名根目录DocumentRoot "/Users/dengzemiao/Desktop/Project/php/Sites"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php # 站点2:# 域名ServerName www.dzm.com# 域名根目录DocumentRoot "/Users/dengzemiao/Sites/dzm"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php # 站点3:# 域名ServerName www.xyq.com# 域名根目录DocumentRoot "/Users/dengzemiao/Sites/xyq"# 域名根目录权限# 运行列出目录(正式服务器需要去掉 Indexes)Options Indexes FollowSymLinks# 运行权限覆盖AllowOverride All# 运行所有人访问Require all granted # 域名根目录默认显示文件DirectoryIndex index.html index.php
- 服务器发送了一个意外的数据包 received 3_肝不好的人,要多喝1水
- 冲施肥含钾最高多少
- 计算机图形学实验三 《交互式绘制多边形》
- 全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏
- 1块3毛5用计算机怎么打出,用了这么多年计算器
- 操作系统之经典同步问题(司机售票员、文件打印、多个生产者消费者、放水果吃水果、读
- 鳜鱼一般在多深
- 河南多地发布暴雪红色预警 郑州安阳新乡等地今天停课
- 扶桑花扦插繁殖方法
- 传奇架设一条龙正确安装热血传奇客户端图文教程