Virtual host not working in zend framework

J.K.A. picture J.K.A. · Jun 29, 2012 · Viewed 7.4k times · Source

Following is my virtual host in /etc/apache2/sites-available:

<VirtualHost *:80>

DocumentRoot "/var/www/roomstays/public"

ServerName roomstays

#This should be omitted in the production environment
SetEnv APPLICATION_ENV development

<Directory "/var/www/roomstays/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

Also it enabled on /etc/apache2/sites-enabled folder

And following is my host file:

127.0.0.1   localhost
127.0.0.1   roomstays

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I configured my site in var/www/roomstays. But when I entered roomstays on it not opening the site and showing this message :

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

What's wrong with virtual host.

Answer

tasmaniski picture tasmaniski · Jun 29, 2012

How to set up virtual host for Zend Project:

Create project(folder) in location /var/www/ named 'roomstays'

Put in file /etc/hosts line:

127.0.0.1 roomstays.test

Create file in /etc/apache2/sites-available/ named "roomstays.conf" and put in it:

<VirtualHost *:80>
    ServerName 127.0.0.1
    ServerAlias roomstays.test
    DocumentRoot /var/www/roomstays/public/
    SetEnv APPLICATION_ENV "development"
    <Directory /var/www/roomstays/public/>
        Options All
        AllowOverride All
        Order Allow,Deny
        Allow From All
    </Directory>
</VirtualHost>

Copy that file 'roomstays.conf' to location /etc/apache2/sites-enabled/

Restart apache, open browser and enter "roomstays.test" and that's work for me.