配置虚拟主机

时间:2017-01-12 11:07:06

标签: php apache virtualhost

我正在尝试在我的本地主机上创建虚拟主机,我在互联网上关注了tuto。以下是步骤:

1)我在桌面上创建了我的项目(使用laravel 5)

2)我打开文件" httpd-vhosts.conf" (C:\ Program Files(x86)\ EasyPHP-Devserver-16.1 \ eds-binaries \ httpserver \ apache2418x161221110224 \ conf \ httpd-vhosts.conf)取消注释此行:"包括conf / extra / httpd-vhosts。 CONF"

3)我编辑了文件" httpd-vhosts.conf"我添加了以下几行:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\Users\Sony\Desktop\links"
ServerName links.localhost
</VirtualHost>

4)我编辑了文件&#34; hosts&#34; (C:\ WINDOWS \ SYSTEM32 \ DRIVERS \ ETC \主机) 并添加了这一行&#34; 127.0.0.1 links.localhost&#34;

5)然后我重新启动easyphp并在命令行上执行以下命令:ipconfig / flushdns

- &GT;结果: 文件&#34; httpd-vhosts.conf&#34;是空的

此行再次发表评论:&#34;包括conf / extra / httpd-vhosts.conf&#34;

当我尝试访问vhost&#34; http://links.localhost&#34;时,就像我访问本地主机一样

这就是我在#34; httpd.conf&#34;

结束时所拥有的
# VIRTUAL HOSTS
## Virtualhost localweb
<VirtualHost 127.0.0.1>
DocumentRoot "C:/Program Files (x86)/EasyPHP-Devserver-16.1/eds-www"
ServerName 127.0.0.1
<Directory "C:/Program Files (x86)/EasyPHP-Devserver-16.1/eds-www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    Allow from 127.0.0.1
    Deny from all
    Require all granted
</Directory>
</VirtualHost>
#Costumized vhost config file
Include conf/links-vhost.conf

1 个答案:

答案 0 :(得分:0)

首先创建一个文件(比如)命名为links.conf并添加您的虚拟主机

<VirtualHost *:80>
DocumentRoot "C:\Users\Sony\Desktop\links"
ServerName links.localhost
</VirtualHost>

现在在httpd.conf添加结束时Include conf/links.conf