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 , 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
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">
<name> Access Log</name>
<value>/path to apache/Apache2/logs/</value>
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 ;)