Monday, March 23, 2009

Zend Server tips and tricks

Zend Server is a “ready to use” development solution for PHP and Zend Framework developers. It includes Apache + PHP + Zend Optimizer + Zend Debug with Zend Studio debugging integration + Zend Framework pre-installed + some additional staff. Distribution is available for Windows (XP, Vista, 2003, 2008 Servers), Linux (Tarball, RPM, DEB) and Mac OS X.



In August 2008 I've joined the project with code name “Zenith” via Yahoo! group http://tech.groups.yahoo.com/group/zenith_beta/ , downloaded the latest available BETA version and was impressed how easy it can be to install Apache + FastCGI + PHP + lot of extensions on my Ubuntu and Windows XP machines with only couple of clicks (key pressings :) . If you ask me to tell something about Zend Server with only three words, I will say: “it just works!”
I wasn’t able to post this article until Zend Server is publically announced. Right now after it is turned into Zend Server public Beta program I can freely share my ideas after working for about 6+ month with Zend Server.
So lets use some tips and tricks to force Zend Server work even better.

Initial configuration

After Server is successfully installed you can enter the WEB-interface
image
From "Monitor" tab you can monitor Apache and PHP info, track server logs. "Server Setup" tab will help you to enable/disable extensions, edit "php.ini" file, configure Zend Debugger. Detailed instructions on how to use these cool features you can found in Zend Server users manual.
The most important post installation operation for me is to switch document root to my workspace. We need to open and edit "..Apache2/conf/httpd.conf " and:
1. Change the document root directive:
DocumentRoot "/my full workspace path/localhtdocs"
2. Set the document root directory settings, so find the following line and change the document root path:
# This should be changed to whatever you set DocumentRoot to.
#
<DIRECTORY /my full workspace path/localhtdocs>
Also set the appropriate directive in this <Directory /> block:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride FileInfo
You need to restart Apache server in order to apply changes.
NOTE: You can find the "Restart Server" button in WEB interface, - but it doesn't restarts server actually. It restarts only PHP FastCGI processes, so only changes in "php.ini" will be applied. To apply changes from "httpd.conf " you need to restart Apache server according to your operation system (restart Apache2.2-Zend service on Windows or httpd daemon on Linux).

FastCGI optimization

NOTE: FastCGI optimization applicable for Windows users only at this time, as for ZendServer on Linux PHP is shipped as "mod_php".
The first optimization point will be to decrease the number of PHP FastCGI processes. As I'm running development machine it is enough for me to have only one FastCGI process at once.
As Zend Server store its configuration in XML file:
INSTALLATION PATH: /ZendServer/etc/ZendEnablerConf.xml
Try to edit the following values:
<processcount extra="1" start="1" />
<timeouts requesttimeout="120" connectiontimeout="60" />
NOTE: You can find "php.ini" file here and edit it for your needs but anyway remember that you can use WEB interface to edit these directives.

Track Zend Server virtual hosts logs via WEB interface

As Zend Server is based on Apache server, you can easily add virtual hosts for your needs.
It’s also good to have virtual hosts custom logs, available via WEB interface. There is no such feature to add custom logs via WEB interface but after discovering some sources I've found how it can be easily added.
Just edit the following XML file "ZendServer/GUI/application/data/logfiles.xml", and add your own log files. For example:
<logfile id="10">
<directive></directive>
<name>my.virtual.host.com Access Log</name>
<value>/path to apache/Apache2/logs/my.virtual.host.error.log</value>
</logfile>
NOTE: Don't forget to add unique ID for every log file.
That’s all. Hope this article will help others to hack Zend Server in their own way ;)

7 comments:

  1. Hello,

    Thanks for you review of ZendServer.
    You've mentioned FastCGI, I assume you meant the Windows setup as in the Linux and MAC ones PHP is shipped as a PHP Apache2 module only.
    We are currently considering adding FCGI support in addition so I would be very interested in hearing your take on that.
    Please see:
    http://forums.zend.com/viewtopic.php?f=8&t=614

    I'd appreciate your reply to this post, you can also mail me at jess zend com.

    Thanks in advance,

    Jess Portnoy

    ReplyDelete
  2. All described tricks available for Windows users. Linux users can use some of these tips prudently.

    Thanks for your note, I'll add minor update to this article.

    ReplyDelete
  3. You got me headed in the right direction, my problem was a bit different.

    I wanted to extend the connection timeout for fast-cgi but I could not find a place to modify it in the Zend Server configuration.

    I ended up editing the ZendEnablerConf.xml file to extend the requesttimeout, and then going into windows services and restarting the Apache2.2-Zend service

    Now I know that some will say that 2 minutes should be plenty of time and that a user will not want to wait for more than 2 minutes anyway, but we do not serve webpages to the public the browser is merely the GUI for our engineering application and yes, in complex applications, we can chew on data for more than a couple of minutes.

    If I could have one wish come true, it would be that the web server development community would realize that browsers are a GUI and not just for watching YouTube.

    So thank you very much Joss

    ReplyDelete
  4. This is the nice piece of information because I am also a Zend Framework Developer and I am working in a software company. I like your article and bookmarking for new information on it.
    ASP.NET Development Company

    ReplyDelete
  5. Such a nice blog, you really provide me some great information. i am going to bookmark this blog, share with my friends and will definitely visit here again. Thanks for your article.
    Jimmy Wilson-Drive Jacket Steady Clothing

    ReplyDelete