Getting Started with Zend Server CE
Every once in a while, I get the urge to clean up my development environment, reinstalling everything from the operating system on down just to experience the good vibes that come with a squeaky-clean (and super-snappy) system. However, this isn’t something to be undertaken lightly – it typically takes me an entire weekend to get things set up the way I like them, and I always emerge from the experience bruised and bleary-eyed from squinting at installation documents and configuration variables.
The last weekend was a little different. Having read about the new Zend Server Community Edition, I decided that instead of the usual procedure I follow to reinstall my PHP environment, I’d give the new one-click installer a try and see if it saved me some time. It worked out pretty well, and over the next few pages, I’m going to tell you what I did and guide you through the process of installing and using the application for your own development. And I’ll also show you how simple it is to install and use PHP/MySQL applications under Zend Server CE, with a live demonstration using an off-the-shelf CMS.
Let’s start with the basics – what the heck is Zend Server CE, anyhow?
Zend Server CE, in the words of its official Web site, is a “production-ready, integrated PHP stack for non-critical applications”. If you don’t speak Geek, I’ll translate that for you: it’s a pre-packaged version of Apache and PHP that gets a simple PHP environment up and running with minimal effort on your part. It is currently available for Windows, Linux (RPM and DEB packages) and Macintosh platforms, and (like all good software) it’s provided free of charge.
Here’s a quick list of the key features:
- Single-click installation: Zend Server CE provides an all-in-one installable distribution of PHP, Apache, Zend Framework, and various Zend utilities. An automated installer takes care of installing and configuring these components for your system, without requiring you to download and install packages separately or work your way through three different sets of installation instructions. Needless to say, if you’re in a rush, don’t really want to spend the time creating a custom-fit installation or are looking for an “unattended installation” option suitable for deployment on multiple systems, this single-click installation approach can save you a fair amount of time!
- Integrated administration console: Zend Server CE comes with an integrated administration console for both PHP and Apache services. This console can be accessed via a Web browser, and eliminates the need to futz around with configuration files to alter the server’s behaviour, or to view and change the server’s operational status.
- Bundled development tools: Zend Server CE comes with a bunch of additional development tools, such as the Zend Optimizer+, which speeds up script execution through opcode caching; the Zend Data Cache, a set of functions for speeding up access to data via caching; the Zend Debugger, a full-featured script debugger; the Zend Guard Loader, for running encoded PHP scripts; and the Zend Java Bridge, which makes it possible to use Java applications from within a PHP script. Some of these components are freely available, while others are included in Zend’s commercial products; nevertheless; it’s nice to have them all in one package. And lest you’re worried about performance, you can turn them off individually as well (as you’ll shortly see).
- Free, but certified by Zend: Zend Server CE comes with a certified copy of PHP that includes the latest bug fixes for security and performance. More importantly, it’s free of charge…always a good thing!
Service With A Smile
To get started using Zend Server CE, you’ll need to first make sure that you have everything needed for a successful installation of the product. Basically, so long as you have a relatively-recent Linux distro (for Linux users), or Windows XP and above (for Windows users), you’re good to go. Depending on the kind of performance you’d like to see, you might want to invest in some decent hardware as well, particular on Windows systems.
To download a version for your platform, drop by the Zend Server CE Web site and pick your poison. Once you’ve got it downloaded, installation is pretty simple: unpack the distribution archive and run the included installer. Here’s what it looks like on Linux:
At the end of the process, you should see a series of status messages, as below:
Note this information down, you’ll need it as we go along. In particular, note that the Apache Web server is set to automatically start on port #10088.
Installation on Windows is also quite simple. Start up the installer, and you should see a screen like this:
Work your way through the initial screens and choose a custom installation. You should then have the option of selecting various components, as in the following screenshot:
Notice that, in addition to a complete PHP installation, Zend Server CE includes the Zend Debugger for debugging, and the Zend Optimizer and Zend Data Cache for performance optimization. You should definitely install these components, as they come in handy when developing Web-based applications. Zend Server CE also includes the Zend Framework, which you should install if you expect to be doing any development with this framework.
A number of other add-ons are also available under Windows, including Dojo (don’t install unless your project specifically needs it), MySQL (install if you don’t already have it), phpMyAdmin (install to make MySQL management simpler), and various database drivers (only install the ones you expect to be using).
Once you’ve selected the components, also select the Web server type and port number – Apache 2.2.x on port #80 should do fine for most installations:
Review your installation settings, and confirm them to begin the installation process.
Zend Server CE will begin installing, downloading files as needed to complete the installation.
Once the installation process is complete, the installer’s last task will be to automatically start the Apache Web server, and then launch the Zend Server CE administration console in a new browser window. Under Linux, you’ll have to do this step manually, by accessing the administration URL provided at the end of the installation process.
Since this is the server’s first run, Zend Server CE will first ask you to set a password, which will be needed for all subsequent visits to the administration console. Once you’ve set a password, you’ll be granted access to the main server administration console, which looks something like this:
Spinning A Web
Every aspect of Zend Server CE can be controlled via the integrated administration console shown previously, which is accessible through a Web browser. Let’s quickly review the main sections of this console:
Monitor: This section provides run-time information on the server process. A dashboard provides at-a-glance information on version information, as well as on the status of various Zend components such as the Zend Data Cache and Zend Optimizer. There are also separate pages for viewing PHP information, via the phpinfo() command, and the server’s error and access logs.
Here are some screenshots illustrating what you might see in this section:
Server Setup: The Monitor section provides information on the server’s current state, and is great for when you need a quick visual check that everything’s running smoothly. However, if you need to make changes, you need to instead head over to the Server Setup section, which allows you to modify the server’s configuration. This section allows you to turn the various Zend tools on or off, enable or disable PHP extensions, change PHP configuration, and restart the server to have your PHP configuration changes take effect. All of these changes can be made via the browser-based interface, and every variable comes with an explanatory note, making reconfiguration a far simpler process than it normally is (especially for users new to PHP).
It’s worth pointing out also that Zend Server CE also comes with built-in hooks for debugging PHP scripts using the Zend Studio debugger. Within the Server Setup section, you can allow or deny access to the debugging system for specific clients, using IP address masks.
Here are some screenshots illustrating what you might see in this section:
Administration: The third section, Administration, merely allows you to change the password used to gain access to the administration console.
At this point, Zend Server CE is fully set up. In order to test the installation and verify that your PHP code is being correctly parsed, pop open a text editor and create a simple PHP script containing the following code:
<?php echo strtoupper('Welcome to PHP v' . phpversion()); ?>
Save this script as ‘welcome.php’ in the Web server’s document root directory. If you kept the installation defaults, this directory will be located at ‘C:\Program Files\Zend\Apache2\htdocs’ under Windows, while under Linux it will be located at ‘/usr/local/zend/apache2/htdocs’ (you can also obtain the correct value from the Monitor -> Server Info -> Web Server section of the Zend Server CE administration console). Then, point your browser to ‘http://localhost/welcome.php’ (Windows) or ‘http://localhost:10088/welcome.php’ (Linux), and you should see something like this:
Are we done? Nope, not yet. You see, Zend Server CE is only a means to an end – typically, you’ll install it as a prelude to installing some other PHP/MySQL-based application, such as a weblog application, a shopping cart system or a content management system. Fortunately, this too is pretty painless, and Zend Server CE also comes with some interesting built-in tools to help you monitor the health and performance of your installed applications.
To get started, download Digitalus CMS from its home Web site, and unpack the distribution archive to a directory named ‘digitalus’ under your Web server’s document root:
shell> unzip digitalus_cms_1.5.1_rc1.zip
Next, create the ‘cache’, ‘media’ and ‘trash’ subdirectories under the main installation directory:
shell> mkdir cache shell> mkdir media shell> mkdir trash
Pop open your ‘httpd.conf’ file (you’ll find it in either ‘C:\Program Files\Zend\Apache2\conf\httpd.conf’ on Windows, or ‘/usr/local/zend/apache2/conf/httpd.conf’ on Linux) and allow .htaccess overrides for your Digitalus CMS installation, by adding an entry to the end of the file, as below:
<Directory "/usr/local/zend/apache2/htdocs/digitalus"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
This is necessary for the application’s URL rewriting to work. Once you’re done, restart the Apache Web server, using either the Apache Monitor tray application (Windows) or the ‘zendctl.sh script’ (Linux).
shell> /usr/local/zend/bin/zendctl.sh restart
Fire up your browser and head back to the Zend Server CE administration console. Launch phpMyAdmin by browsing to ‘http://localhost/phpMyAdmin’ (Windows), log in, and create a new MySQL database for the application:
While you’re there, you can also create a MySQL user account, which has limited access only to the above database, for security reasons:
If you don’t have phpMyAdmin, you can also accomplish the above tasks through the MySQL command-line client, as below:
shell> mysql -u root -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 59 Server version: 5.1.28-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> CREATE DATABASE digitalus; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON digitalus.* TO digitalus@localhost IDENTIFIED BY 'g00dcm5'; Query OK, 1 row affected (0.00 sec)
Now, access the Digitalus index page through your browser, and you should be prompted for n administrative account and database information. Provide the necessary information and begin the installation process by hitting Install Now.
Once the installation process is complete, remove the ‘install’ folder, as prompted by the installer, and visit the index page again. You should see the Digitalus CMS, all set up and ready to use!
I, Me, Myself
To access the Digitalus administration module, visit ‘http://localhost/digitalus/admin’, and you should see something like this:
Log in using the credentials you supplied earlier, and you’ll be presented with various administrative options. To quickly see the CMS in action, visit the Pages section, and create a new page:
After defining the basic page parameters, and slotting it into the navigation menu, add some content to it using either the built-in WYSIWYG editor or the bare-bones HTML editor:
Save your page, and head back to the home page. Your newly-added page should show up in the main menu, together with the content you added.
In a similar vein, you can add more pages to the system – Digitalus CMS comes with numerous options to help you control the appearance, content and navigation of pages in the site. There are a lot of features to explore, so take a look at the documentation wiki and play with it a bit to get the hang of it.
As this example demonstrates, Zend Server CE makes it very easy to get a fully-functional PHP environment up in minutes, while simultaneously allowing users the flexibility to reconfigure the default installation to their specific needs. If you’re a system administrator or power users, you might still prefer the “roll your own” approach to building a PHP development environment; however, if you’re a PHP newbie, weekend hobbyist or impatient developer, Zend Server CE might help get you up and running faster than usual. Take a look at it the next time you’re in the mood to “spring clean” your development system…and happy coding!
Copyright Melonfire, 2009. All rights reserved.