Roshan Book

My Tech Notebook

Configuring Virtual host

When we develop on Zend framework , to check your progress you need to go to http://localhost/phpProj/zend/ , time and again to get to the index page. We can conveniently set up a virtual host on our local machine, so that if we type we could get to the above mentioned link.

Below are the steps to configure virtual host

Before this, visit /etc/apache2 and see the folders residing there.

Notice two specific folder

a) sites-available

b) sites-enabled

Sites-available is a folder which contains configuration file for each site, which you want to enable

sites-enabled mainly contains link to sites-available. link present inside sites-enabled folder

Suppose we make a new zend framework enabled website in /var/www/zend/ , and our objective is to get to its’s public/index.php when we open

Step 1. Create  a new file inside sites-available folder and paste following code :

<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/zend/
<Directory />
Options FollowSymLinks
AllowOverride All
<Directory /var/www/zend/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined

Step 2. Save the file

Step 3. Open the terminal (ctrl+alt+t) and run “sudo a2ensite
Step 4. Open etc/hosts file ( ensure it’s hosts and not host file)

Step 5. Paste

Step 6. Restart apache by running “sudo /etc/init.d/apache2 start

That’s it, when you now open you will get zend welcome page

Notes :

1. In-case you are not able to save site config inside sites-available, try to save the file as root

2. Clear browser chache, if is not giving results


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: