Setting up WAMP for Zend Framework Projects

A ZF project would not run out of the box on a fresh installation of WAMP. The purpose of this guide is to act as a checklist for the experienced, and a step by step guide for the more inexperienced. Before we start, this article is written based on WampServer 2.0i with Zend Framework 1.10. If you are using earlier versions, the steps should work, but you might want to consider upgrading to the newest.

  1. Make sure Wamp is running ok
  2. Enable virtual hosts, mod_rewrite, and override in ‘httpd.conf’
  3. Set up virtual host in ‘httpd-vhosts.conf’
  4. Check include paths for  the Zend library
  5. Add Custom URLs in host file

1. Make sure Wamp is running ok

Navigate to http://localhost on your favorite browser, you should see the WampServer welcome screen with headings “Server Configuration”, “Tools”, “Your projects” etc. If not, check your Wamp installation before proceeding further.

2. Enable virtual hosts, mod_rewrite, and override in ‘httpd.conf’

For a default 2.0i installation, the apache configuration file can be found at ‘C:wampbinapacheApache2.2.11conf’. After making a backup, open it in notepad and search for “vhosts”. Make sure the line

# Include conf/extra/httpd-vhosts.conf

is uncommented by removing the “#” in front.

Next, look for the line

# LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it too.

Lastly, look for

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    # Deny from all
</Directory>

and make sure AllowOverride is set to All instead of none. This prompts Apache to apply rules found in the .htaccess files in sub directories. Save and close.

3. Set up virtual host in ‘httpd-vhosts.conf’

Look for the file in ‘C:wampbinapacheApache2.2.11confextra’. Make a copy for backup and open it in notepad. The file should already have 2 dummy <VirtualHost> entries which you can safely remove. Now we will add the default virtual host and your own custom host:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "c:wampwww"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "C:wamplogsapache_error.log"
    CustomLog "C:wamplogsaccess.log" common
</VirtualHost>

Note: replace the parameters below with your own project paths.

<VirtualHost 127.0.0.1:80>
    ServerAdmin admin@customurl.localhost
    DocumentRoot "C:MyProjectPathpublic"
    ServerName customurl.localhost
    ServerAlias customurl.localhost
    ErrorLog "C:MyProjectPathlogsapache_error.log"
    CustomLog "C:MyProjectPathlogsaccess.log" common
</VirtualHost>

Update: if you get a “You don’t have permission to access” error when accessing the page, include the following directive right before the </VirtualHost> tag:

<directory "C:MyProjectPathpublic">
allow from all
</directory>

4. Check include paths for  the Zend library

Your app probably runs alright now. If you are getting the file not found error when including the Zend library, make sure you have copied the Zend library into your /library folder and your index.php actually combines it with the PHP include path:

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path()
)));

Edit: As Fernando pointed out, take note to use slashes “” instead of back slashes “/” on windows. Also, include your custom urls in your host file if they are not a subdomain of localhost:

5. Add Custom URLs in host file

Your host file is located at ‘C:WindowsSystem32driversetc’. Its a file without extension, but you can open it with notepad just the same. Add the following line to the end:

127.0.0.1 [Custom URL here]

That’s it. If you are unsure of the steps or meet any other problems feel free to email me. Tested using WampServer 2.0i with Zend Framework 1.10.

16 thoughts on “Setting up WAMP for Zend Framework Projects

  1. Pingback: Zend Framework News » Blog Archive » WAMP einrichten für das Zend Framework

  2. Fernando

    Hi Ryan, good tutorial. I have two comments to do.

    1- If you are under windows, you have to put the paths with this “/” bar.

    For example, in this lines:

    DocumentRoot “c:wampwww”
    ErrorLog “C:wamplogsapache_error.log”
    CustomLog “C:wamplogsaccess.log” common

    change it like this:

    DocumentRoot “c:/wamp/www”
    ErrorLog “C:/wamp/logs/apache_error.log”
    CustomLog “C:/wamp/logs/access.log” common

    Otherwise, the apache server won’t start.

    2- For virtualhosts, apart of changing “httpd-vhosts.conf”, you have to set the hosts file of the OS.

    Path -> C:WindowsSystem32driversetchosts

    something like this:

    127.0.0.1 customurl # customurl ZF project

    See you,
    Fernando.

    Reply
  3. Frédérique

    Hi there,

    I wanted to install ioncube to locally test some softwares and since what I was doing did not work, I thought that maybe it was something to do with Zend not being activated in Wamp. I followed your instructions, step by step, but I have a question about the last step. You mention to change the info for our own stuff, and here I am at lost (I am a real beginer trying to make things work for me).

    Can you please give me an actual example of what I should change the line below for?

    ServerAdmin admin@customurl.localhost
    DocumentRoot “C:MyProjectPathpublic”
    ServerName customurl.localhost
    ServerAlias customurl.localhost
    ErrorLog “C:MyProjectPathlogsapache_error.log”
    CustomLog “C:MyProjectPathlogsaccess.log” common

    Should the “my” be replaced by “wamp” and then the name of the particular website I want have Zend activated for? What should “customurl” replaced for? The actual website name ? the folder’s name on wamp?

    Other question: if I have more than one website that I want to test, do I have to create a virtual host for each?

    I hope my questions will not bore you. I must say that I am navigating in a field that I really don’t master.

    Thanks

    Reply
  4. ryan

    Frédérique, the document root should be the absolute path to the folder containing your website’s public files. e.g. is your index.php residing at “C:MyProjectPathpublic” ?

    Reply
  5. Pranav

    Hi,
    I am new to using Zend framework with WAMP. However before starting I had one doubt.
    After installing zend framework with wamp, will I be able to use wamp without the framework for projects which do not require it?
    Or is it that every new project will have to be used with Zend framework only after installation?

    Reply
  6. Pranav

    Hi again,
    I have another doubt same as Frédérique’s.
    My project is in the folder www/wamp/project, so should I use this path to enable zend framework for the “project”. Also what if I have more then one site to run with zend, should I create custom paths for all?
    And what url should I use in the browser to access “project” to start using the framework.
    And what url should I use when I wish to use wamp normally for projects without using the zend framework.

    Do excuse my questions, if they seem silly. I am new to zend framework. I want to use it, but without disturbing my other projects which are already running under wamp, without the zend framework.
    My email id is pranav6487@gmail.com, you can mail me the reply too

    Reply
  7. ryan

    Hi Pranav, the zend framework can reside in a specific site directory without affecting other sites. The steps I mentioned in the post actually general steps applying to any site you want to set up locally and only step 4 is relevant to zf.

    So in answer to your question: yes you should use www/wamp/project, and yes you need custom paths for each site you want to set up. Hope it clears your doubts. In any case, the steps are totally reversible so don’t be afriad to go ahead and try it out =)

    Reply
  8. Andrew

    Really found this useful. I am experimenting with WAMP and Zend and found ZendServer. Want to try both need to see how they compare. Need a tutorial on using Zend and WAMP.

    Reply
  9. Pratik

    I m trying to edit the host file under the driver in system 32.But when I make the edit it is not allowing me to save the file inside the etc folder.IT is saying contact the administrator .pls help

    Reply
    1. ryan

      you’ll need the proper permissions in order to edit this file. If you believe you do, try using a proper editor to save the file other than notepad (for something quick try wordpad), also try to uncheck the ‘read-only’ check box in the file properties dialog.

      Reply
  10. Pingback: set up zendframework on windows « Website Design & Development Documentation

  11. thickglass

    Hello ryan thanks for the tutorial. Setup for the virtual host was quite successful but now I am only able to access the zend project and doesn’t allow me to access any other projects how can i solve that

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *