Configuring vhosts and fixing zf.exe tool with initial setup of Zend Server CE and Zend Framework 1.9.1 on Windows.

I’ve just spent a few hours wading through what should otherwise be simple.

First of all, download Zend Server CE you can get it here:

http://www.zend.com/en/products/server-ce/downloads

I chose the PHP 5.3 version.

Start the install, and choose custom install if you want to also install MySQL Server and PhpMyAdmin.

Once the install is complete, you would think that you would be ready to go…Should be simple…Zend Framework on running Zend Server. Not so!

First of all, at the time of this writing, Zend Framework 1.9.0 and 1.9.1 have a bug which makes it impossible to use the command line tool to do anything other than create a project on a windows system. If you are installing on Windows, you will need to manually add a few lines to the

Zend/Tool/Project/Provider/Abstract.php

file. This is a pain, but I’m sure it will be fixed soon.

You can get all the details the fix for it here:

http://zendframework.com/issues/browse/ZF-7465

I used the second fix, and it works fine. If you don’t patch this, you will get an error when you try to create a module after you’ve created your project, and you will probably tear your hair out finding the problems.

Next, once you patch, and create a project, you would think that it would be easy to create a virtual host for your new project. After unsuccessfully trying many different snippets of advice, I finally came across this, buried in the “best practices” part of the installation guide here:

http://files.zend.com/help/Zend-Server-Community-Edition/configuring_zend_framework.htm

First, assuming that you created your project in the web root of your new installation, and your project is called “yourprojectname” you would cut and paste the following text directly into the very bottom of your

C:\Program Files\Zend\Apache2\conf\http.conf

file. I’m not sure why this is considered a best practice (as opposed to using /extra/httpd-vhost.conf file), but it works.

  1. Listen 84
  2.  
  3. <VirtualHost *:84>
  4.  
  5.     DocumentRoot "C:\Program Files\Zend\Apache2\htdocs\yourprojectname\public"
  6.  
  7.     <Directory "C:\Program Files\Zend\Apache2\htdocs\yourprojectname\public">
  8.  
  9.         Order allow,deny
  10.  
  11.         Allow from all
  12.  
  13.     AllowOverride all
  14.  
  15. </Directory>
  16.  
  17. </VirtualHost>

Now your new project will be served on http://localhost:84/

Next, you need to have an .htaccess file in the \public directory of the new project you just created. So if the module you created was “mynewmodule”, you would create a file called .htaccess in

C:\Program Files\Zend\Apache2\htdocs\mynewproject\public

If there is already contents in that file, you should comment out existing code first, then past this below:

# public/.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ – [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

Whew! That’s it!

Remember to restart your apache server, you should now see your zend framework homepage at http://localhost:84/

You should be able to get started coding now!

Trackbacks & Pingbacks 1

  1. From Problems with include_path in VirtualHost and resolving directories... - Zend Framework Forum on 14 Aug 2009 at 10:37 am

    [...] I ran into getting started, one of them was setting up the vhost when using zend server ce. GoodLux Media – Configuring vhosts and fixing zf.exe tool with initial setup of Zend Server CE and Z… Hope this [...]