August 17th, 2011 Add Your Comments

Zend Server CE is one of the best stacks available for development, and for Mac OSX. These are some simple instructions to get you up and running quickly (and you may learn a few things along the way as well).

Hint: You can copy-paste in terminal so just copy-paste when you can to save yourself time.

Step 1: Download
+ Download Zend Server CE for OSX from http://www.zend.com/en/products/server-ce/downloads. (I recommend the PHP 5.3 version)
+ Follow the prompts and install to the default locations

Step 2: .bash_profile Updates
Let’s edit the bash_profile so you can access the controls from the terminal much easier.

+ Open Terminal
+ Type Open .bash_profile
+ Copy-paste the following

PATH=$PATH:/usr/local/zend/bin:/usr/local/zend/mysql/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib

+ Save file (close)

While were making changes, let’s shortcut Zend Framework too so you can access easily in Terminal to create new projects:

+ Open Terminal
+ alias zf=/usr/local/zend/share/ZendFramework/bin/zf.sh

+ Now restart your computer for the changes to take effect.

Step 3. Welcome Back!… Let’s Change Localhost Port
The Apache in Zend Server is configured for localhost to use port 10088. Let’s make your life easy and change this.

+ Open Terminal
+ sudo zendctl.sh stop
+ sudo vi /usr/local/zend/apache2/conf/httpd.conf
+ Arrow down to line that says Listen 10088 and type the letter i
+ Change to Listen 80
+ Esc, then save/exit by typing :x

+ sudo vi /usr/local/zend/apache2/bin/apachectl
+ Arrow down to line that says STATUSURL=”http://localhost:10088/server-status” and type the letter i
+ Change to STATUSURL=”http://localhost:80/server-status”
+ Esc, then save/exit by typing :x

+ sudo zendctl.sh start

Step 4. Change root passwords for MySQL / phpmyadmin
Do not login to phpmyadmin until you have changed root password!
By default, Zend Server CE doesn’t setup a password for root access to MySQL. Although this is likely a development environment, this is a security issue. Let’s change the root password.
+ Open Terminal
mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD(‘NEW_PASSWORD’) WHERE User=’root';
mysql> flush privileges;
mysql> quit

Step 5. Change Server Root To Sites Folder
Although it’s easy enough to create a shortcut to your htdocs folder, it’s also just as easy to change the root folder. The Sites folder is the standard location used on OSX, and is a convenient place for your projects.
+ Open Terminal
+ sudo vi /usr/local/zend/apache2/conf/httpd.conf
+ Arrow down to the following line and type i to start editing:
change DocumentRoot “/usr/local/zend/apache2/htdocs”
to DocumentRoot “/Users/COMPUTER_ACCOUNT_USERNAME/Sites”
+ Arrow down to the following line to start editing:
change <Directory "/usr/local/zend/apache2/htdocs"></code>
to <Directory "/Users/COMPUTER_ACCOUNT_USERNAME/Sites">
+ Esc, then save/exit by typing :x

Step 6. PEAR and PHPUnit
Let’s upgrade PEAR and install PHPUnit

+ Open Terminal
+ Type the following one line at a time:
sudo pear update-channels
sudo pear upgrade-all
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install phpunit/PHPUnit

Step 7. date.timezone
Don’t forget to date.timezone for PHP. You can do this in the php.ini file, however, Zend Server CE makes this very easy to do from the control panel. Simply launch the control panel, agree to Terms of Use and other basics.
+ Select Server Setup
+ Select Directives
+ Select Date
+ Add America/New_York to input field
+ Save and restart PHP

Reminders:
From Terminal:
Start: sudo zendctl.sh start
Stop: sudo zendctl.sh stop
Restart: sudo zendctl.sh restart
Zend Framework: zf (see list of controls to create projects, files, etc.)
PHPUnit: phpunit

And at any point if you need to uninstall Zend Server CE for some reason, it’s simple to do:
+ Open Terminal
+ sudo /usr/local/zend/bin/uninstall.sh

Alternatives:
And you can always try a nice alternative called MAMP which you can download at http://www.mamp.info/en/downloads/index.html, but remember, it doesn’t have all of the features that are found with Zend Server CE (but everything most people need for LAMP development).

Happy Programming with Zend Server CE
Note: These instructions will work with OSX 10.6 as well.