Installing Zend Optimizer on a local Windows-based, Apache, server

Note: This guide should work equally well for Zend Optimizer 3.0.1 and above. For a guide on upgrading this 2.6.2 install, see Upgrading to Zend Optimizer 3.0.1 on a local Windows-based, Apache, server.

From Zend's FAQ,

Why use the Zend Optimizer; isn't PHP supposed to be quite fast already?

The standard Zend run-time compiler used by PHP is indeed extremely fast, generating code that is usually 2 to 10 times faster. But an application that uses the Zend Optimizer typically executes another 40% to 100% faster.

So, Zend Optimizer will help decrease the time spent on processing code. If you run the file we created a few steps back, probably called http://localhost/phpinfo.php (which basically runs <?php phpinfo(); ?>), you'll notice a line that says "This program makes use of the Zend Scripting Language Engine: Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies". This is the standard Zend run-time compiler that is mentioned above. Once we download and install the Zend Optimizer, we'll see some additional lines here.

Download Zend Optimizer

The first thing we'll be doing is downloading Zend Optimizer. You can download a copy at http://www.zend.com/products/zend_optimizer/. Based upon the system requirements, we'll be able to install the, at the time of this writing, current version, version 2.6. In order to download this, you will have to create an account.

After creating an account (or logging into your existing one), you'll want to download the Windows x86 version of Zend Optimizer 2.6.2 (or the current version that works with our version of PHP, 4.4.2). It's over 4.5 MB, so you may be in for a wait. Again, I recommend you download this file into the folder you created for these guides. Once the download has finished, open the executable file.

Installing Zend Optimizer

You'll first have to read and agree to the license agreement. After doing so, you'll need to choose an installation directory, which we'll leave as the default (C:\Program Files\Zend\ZendOptimizer-2.6.2). On the next screen, verify that the installer successfully detects the Web server (in our case, Apache 1.3.34).

Next, verify that the folder containing the php.ini file is correct. If you've followed the guide thus far, it's probably in c:\windows\, which is what the installer will probably have. Next, you'll have to choose the "root folder of your Web server", and the default will be something like C:\Program Files\Apache Group\Apache, which is correct. Next, we'll have to choose the "document root folder of your Web server", which is where our Web sites are located. It will choose C:\Program Files\Apache Group\Apache\htdocs, but we'll need to change this to C:\home, since this is where our Web sites are located.

Finally, you'll be asked to verify the installation, and Install. When the installation occurs, it will be making a copy of the php.ini file, and creating a new version with some modifications. In order to do this, it will have to stop and then start Apache, which is absolutely fine.

Once the installation has finished, we can make a quick backup copy of the php.ini file, as well as the file it created (which it would have notified us of). In my case, the backup was called "php.ini.ZendOptimizer-2.6.2_bak".

If we now visit http://localhost/phpinfo.php, we'll notice that the bit on Zend has been increased to something like "This program makes use of the Zend Scripting Language Engine: Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend Extension Manager v1.0.9, Copyright (c) 2003-2006, by Zend Technologies with Zend Optimizer v2.6.2, Copyright (c) 1998-2006, by Zend Technologies".

And, with that, you've successfully installed Zend. While you may not notice a change, especially if you haven't created a lot of PHP files, there is one, one which you would notice once you begin developing larger PHP implementations. In the future, you may want to even uninstall Zend, to see just how pages change.

This in fact brings up a very good point. Now that Zend has created a backup of the pre-Zend php.ini file, you'll want to make a note of any changes you make in the php.ini file. I recommend you keep the pre-Zend php.ini file as it is, but create a copy where you make any modifications you may make to the post-Zend php.ini file.

The modification, in case you wondering, is simply the addition of the below at the very end of the php.ini file.

[Zend]
zend_extension_manager.optimizer_ts="C:\Program Files\Zend\ZendOptimizer-2.6.2\lib\Optimizer-2.6.2"
zend_extension_ts="C:\Program Files\Zend\ZendOptimizer-2.6.2\lib\ZendExtensionManager.dll"

Since you may make additional changes to this file down the line (such as if you look at installing another database solution when I do), it's important to know.

And with that, we've completed this tutorial, as we've successfully installed Zend Optimizer.

View all of the steps to creating a local Web server, for development.