第一步:httpd.conf文件的配置
1.1首先打开Apache的安装目录下的CONF文件夹,用记事本打开的conf文件夹里的httpd.conf文件;
1.2查找httpd.conf文件里的#virtual hosts;把#virtual hosts下面一行#Include conf / extra / httpd-vhosts.conf中的注释符号“#”去掉;
就是也。把变成;
1.3保存后,打开Apache的安装目录下的的conf文件夹中的额外的文件夹,用记事本额外的文件夹里面的的httpd-vhosts.conf文件;
第二步:httpd-vhosts.conf文件配置虚拟主机
<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com 即站长邮箱
#虚拟主机网站根目录
DocumentRoot "F:\xxxxxx.xxx.xxx"
#配置这个目录允许呗访问,否则出现Forbidden
<Directory "F:\atouchofyuhui.github.io">
Options Indexes FollowSymLinks #开启目录浏览
AllowOverride None
Require all granted#所有请求允许访问
</Directory>
#servername 就是访问的域名
ServerName site1.io
# ServerAlias www.dummy-host.example.com ServerAlias的作用就是多个域名访问相同的网站
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
第三步:hosts文件
3.配置主机域名(服务器)和地址
管理员身份打开hosts文件,底部添加IP地址,域名 然后保存。
第四步:重启Apache
然后浏览器输入域名或者ip地址就可以访问你的页面了。默认界面是index.html文件。
(也可以在httpd-conf配置文件里修改DirectoryIndex index.html)把默认index.html文件改成别的默认文件