简体   繁体   中英

vhost config for Zend Framework 2 in Xampp (windows)

I have installed zend framework 2 in xamp (Windows) & its accessible when i call http://localhost/zf2-tutorial/public/ . I am trying to set virtual host using the below config using httpd-vhosts.conf

<VirtualHost *:80>
     ServerName zf2-tutorial.localhost
     DocumentRoot "D:/xampp/htdocs/zf2-tutorial/public"
     SetEnv APPLICATION_ENV "development"
     <Directory D:/xampp/htdocs/zf2-tutorial/public>
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
 </VirtualHost>

and have configured 127.0.0.1 zf2-tutorial.localhost in host file. but when i call zf2-tutorial.localhost in browser, all i get is http://zf2-tutorial.localhost/xampp/ . I also tried adding this in httpd.conf , still the result is same. Please Help ?

如果您在文件httpd-vhost.com配置虚拟主机,请确保在httpd.conf文件中未注释虚拟主机包含文件,即从Include conf/extra/httpd-vhosts.conf行的开头删除#。

I personally dont like the xammp software and rather set up my own apache but there shouldn't be to many differences in setting up a project. I also like having alias's for my project's rather then accessing them trough "localhost" or a "ip". My config usually looks something like this:

<VirtualHost *:80>
    ServerName tutorial.local
    ServerAlias tutorial.local
    DocumentRoot c:/Apache24/htdocs/tutorial/public/
    SetEnv APPLICATION_ENV "development"

    <Directory c:/Apache24/htdocs/tutorial/public/>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

After setting up the Virtual Host with the aliases you'll have to open your hosts file within FILESYSTEM:\\windows\\System32\\drivers\\etc\\ and add a host.

localhost or IP  tutorial.local

keep in mind that you'll have to open this file as a administrator and may disable your Antivirus/Spyblocker.

I finally found what was wrong, i never added vhost for local host. Once, i configured the localhost in httpd-vhost.cong like this, it worked perfectly. Thanks for all your help

<VirtualHost *:80>
  DocumentRoot "D:\xampp\htdocs"
  ServerName localhost
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM