tirsdag 3. mai 2011

Setting up Zend Server CE in Ubuntu 11.04

Who is this guide for

Installing and configuring a lamp-stack (Linux, Apache, MySQL and php) can be a somewhat daunting task if done manually. There are many files to configure, and making sure everything works correctly together can take some work and experience. For those with little or no experience in setting up such a stack, especially when it comes to the Linux environment, there are alternatives. For use in development environments you've got software that pretty much sets up a LAMP-stack for you, such as LAMPP (Linux, Apache, MySQL, php, Pearl) and Zend Server (CE).

This guide intends to show you how to set up the latter, and is as much a guide for you, the reader, as it is a note for me, the author, who has the keen ability to forget about these kinds of things. I also wanted to make this guide because the installation manual provided by Zend is not updated for Ubuntu 11.04, let alone 10.10, and because it is not that beginner friendly. I've borrowed most of the steps in this guide from other guides, and citations are provided where such is the case. So let's start.

Installing Zend Server CE

If you clicked the nice little URL pointing to the Zend Server CE-page, you might have noticed that the download page offers you a DEB/RPM installer script. This script however, is made to work with aptitude (I suspect) which is the standard package handler for the deb-variant of Linux, and won't work with Ubuntu 11.04 as this version of Ubuntu use APT. We'll avoid the installer script, and instead install the application manually.

One important thing to note is that Ubuntu 11.04 (and other versions of Ubuntu) comes with both Apache, php and MySQL. In addition to these pre-existing pieces of software, Zend Server CE will install the lighttpd web server and it's own php version. You might wonder why you would need two webservers, both apache and lighttpd. The reason is quite simply that Zend wanted to run the admin panel for Zend Server on it's own server, so that the configurations needed for the admin panel would not interfere with the configurations wanted by the users, (Source: Jess Portnoy).

The first thing we need to do is add the Zend Server CE-repository to the sources list.
Open the terminal and enter the following line:
sudo nano /etc/apt/sources.list

This should open the sources.list file in the terminal text editor nano and look something like this:

Some guides tell you to use the gedit text editor via the command "sudo gedit /etc/apt....". However, this will produce errors because graphical (gnome) applications should be accessed with gnomesu via the terminal. For our purposes, nano should do the trick, so I will stick to that editor. (Source: opensuseforums).

Scroll down to the bottom of the document and insert the following line:
deb http://repos.zend.com/zend-server/deb server non-free
What this line does, is to tell APT (the package manager in Ubuntu) where Zend Server can be found. To save the change to the source.list file, press ctrl + O (the character, not the number). This keyboard shortcut promts nano to start the process of writing the data out to the file. To complete the save, press the return/enter key. If nano successfully wrote the file, you can exit the editor by pressing ctrl + x.

The next thing to do is to add the public key for the Zend Server repository to the package manager. Enter the following line into the terminal, and provide the root password as necessary:
wget http://repos.zend.com/zend.key -O- |sudo apt-key add -

If everything went ok, the terminal should display an "OK" line at the end of the text output. It should look something like this:

At this point the repository location (URI) of Zend Server CE should be added to the sources.list file of the APT package manager. APT should also have the public key to the repository. The last thing we have to do before we can start the installation process is to tell APT to update it's list of available repositories. Write the following line into the terminal and execute:

sudo apt-get update

If you've done everything right thus far, APT should be able to read the sources.list file without problems, and output something like this to the terminal:

Now that APT has updates it's repositories list, we can let APT handle the process of installing Zend Server CE. For someone like me, who barely grasps the fairly intricate architecture (if you will) of the Linux file system, having APT putting everything where it belongs is great stuff. To install Zend Server CE, simply write the following line into the terminal and enter root password as needed:

sudo apt-get install zend-server-ce-php-5.3

During installation, the terminal will prompt you for a yes/no-answer:

Just enter a big Y and press the return/enter-key. APT will then start downloading the necessary packages from the repositories, and do the installation. If the installation succeeded your terminal should look something like this:

As you might have noticed, Apache2 will give the following output error:

apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

To fix this problem, we'll have to add the "ServerName" property into the httpd.conf file, which tells Apache2 what name the server goes by. Open the text document with nano (like we did with the sources.list file):
sudo nano /etc/apache2/httpd.conf
and enter the following line and save (ctrl + O, enter/return and then ctrl + x):
ServerName localhost

If you restart the Apache2 server, the error message should be history. You should restart Zend Server as well and check it's status, to make sure everything is ok. Before that can be done, you should know that Apache requires a text-based browser to display it's status in the terminal, (Source: Serverfault). As it seems Ubuntu 11.04 does not provide such a browser, you'll have to install one. There are several text-based browser available, but lynx is probably as good as anything else for our use. Install lynx by writing the following line in the terminal (enter Y + enter/return key on prompt the same way as before:

sudo apt-get install lynx

To restart the server, enter the following lines into the terminal:

sudo /etc/init.d/apache2 restart
sudo /usr/local/zend/bin/zendctl.sh restart

This should yield the two respective results:

To check Zend Server CE's status, write the following line into the terminal:

/usr/local/zend/bin/zendctl.sh status

This should display the status of the Apache2 and lighttpd server.

When you've come this far, Zend Server has installed it's components. That is, lighttpd (webserver), configured the Apache2-webserver and the MySQL-server that comes prepackaged (so to speak) with Ubuntu. To make sure the webserver is working, open localhost in your browser of choice by typing in the following URI:


If it worked it should display the following text:
It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

If you are positively sure that you are not going to use Perl, pecl (PHP extensions community library), Zend Framework or any other such tools, you may skip the next step in this guide. Though, it would probably not hurt to do it, especially if you change your mind later on. Now, before you can lean back and relax, there are some final post-installation steps to be done. The first thing we need to do is to add the Zend Server CE binary folder to the $PATH environment variable for all users on your Linux-machine. When the binary folder is added to the $PATH environment variable, it tells the OS to look for executable files in the Zend binary folder. To do this open the profile file in the etc-folder with nano like so:

sudo nano /etc/profile

Add the following two lines to the end of the file and save the file in the usual manner (ctrl + O, enter/return-key and ctrl +x):


It should look like this:

As this guide is not going to use the terminal to execute any of the binaries in the Zend application folder, the following step is not necessary. But if you want to start using the binaries, it is required. To make the shell (terminal) reload the configuration file, the easiest solution is to just close and reopen the terminal. You could also use the following line:

source /etc/profile

The last thing to do now, is go to the following link:


This will take you to the registration and set-up process for the Zend Server. Just follow the simple instructions, and you're done!

In a later blog post, I will go trough the process of installing phpMyAdmin, a web-based mySQL-client that let's you manage your mySQL-database. In addition the post will handle the process of setting up a virtual host, and how to install Zend Server components. I hope this little tutorial has been helpful for those that wanted to set up Zend Server. I realize that most of these steps can be found on the Internet. But none of the guides I've stumbled upon (or rather searched for in a brave effort on Google) have been adapted for the newest versions of Ubuntu (10.10 and 11.04), and that warranted a new tutorial. I've also taken care to not assume to much knowledge on the part of the user, because there might be people who are completely new to Linux and Ubuntu. Things like using the right package manager, avoiding cryptic errors when using GUI-enabled applications without proper security privileges, and so on, can be quite confounding for a new or inexperienced user, such as myself. Feel free to point out any errors in this post. I'm not an expert Linux-user, and as a result I am prone to making errors.

So long, and happy computing.

7 kommentarer:

  1. Thanks, saved my life. I have things to do and I need to be productive, not stumble around trying to set up Zend Server!

    Great article ^_^

  2. You are very welcome. It warms my hearth to see such thanks posted. I did spend a fair amount of time on this tutorial, so to see it appriciated is nice. :)

  3. Hi, will it be a problem if I already have Apache installed and configured before install Zend? Thanks.

  4. I can't say for certain as I don't actually know. It should not, in my mind, pose any problems. But the people over at the Zend community fora should know better than me. :)

  5. Hi I got the following error when access address localhost:10081

    Zend Server Exception Caught:
    Permission denied '/usr/local/zend/gui/application/data/zend-server.ini'
    #0 /usr/local/zend/gui/application/CE/models/Plugins/Initializer/CE.php(128): Common_ApplicationModel::loadConfiguration()
    #1 /usr/local/zend/gui/application/CE/models/Plugins/Initializer/CE.php(38): Plugins_Initializer_CE->initApplication()
    #2 /usr/local/zend/gui/application/Initializer.php(34): Plugins_Initializer_CE->__construct()
    #3 /usr/local/zend/gui/html/index.php(24): Initializer::getInitializer('CE')
    #4 {main}

    But I think I have read permission for that file. Any idea? Thanks in advance.

  6. I have never happened upon this problem myself, but some googling revealed that it could be a problem with your port settings. You should check out this troubleshoot snippet from Zend:


    If it is neither a permission error or port listening problem then I do not know what could be wrong. You could try chatting up the folks over at the Zend Community Forum. :)

  7. Great tutorial. I have done this pieces manually but today I did a clean install of of Ubuntu 11.10 and found your steps and it worked great. All smooth. Good stuff.

    Keep it FREE!