Pragmatism in the real world

Some notes on Zend Server CE for Mac OS X

I’ve installed Zend Server CE on my Mac to see where it’s got to and it’s looking quite usable. The installation puts everything into the usr/local/zend directory which is fairly well laid out so that you can find what you are looking for. There’s also a a nice admin system at http://localhost:10081 which allows you to restart PHP, view phpinfo(), configure extensions and php.ini. There’s also a phpMyAdmin to help administer the bundled MySQL server.

For Mac, this is now one of the better one stop shops for easy PHP & MySQL installation.

Obviously, some things need configuration:

Set up paths

You need access to the command line zendctl.sh and mysql tools:

  • Edit ~/.bash_profile and add:
        PATH=$PATH:/usr/local/zend/bin:/usr/local/zend/mysql/bin 
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib 
    
  • Close Terminal and restart it so that your change takes effect.

Change to port 80

The Apache in Zend Server is configured for 10088 to avoid conflicting with Apple’s Web Sharing I suppose. The choice of using port 80 would have been nice as an installation option though.

To use port 80 is easy enough:

  • Stop Apache: sudo zendctl.sh stop-apache
  • Edit /usr/local/zend/apache2/conf/httpd.conf and replace Listen 10088 with Listen 80
  • Edit /usr/local/zend/apache2/bin/apachectl and change STATUSURL="http://localhost:10088/server-status" to STATUSURL="http://localhost:80/server-status"
  • If you are using vhosts, then edit /usr/local/zend/apaches/conf/httpd.conf and replace all instances 10088 with 80
  • Restart Apache:sudo zendctl.sh start-apache

Installing PHPUnit

Update PEAR first:

    sudo pear channel-update pear.php.net
    sudo pear upgrade-all

Install PHPUnit:

    sudo pear channel-discover pear.phpunit.de
    sudo pear install phpunit/PHPUnit

Installing Xdebug

  • Install Xcode so you have a compiler!
  • Stop Apache: sudo zendctl.sh stop-apache
  • Go to http://localhost:10081/ and pick the Server Setup tab. Turn off the Zend Debugger and Zend Data Cache and restart PHP
  • sudo pecl install xdebug
  • Edit /usr/local/zend/etc/php.ini and add above the [zend] section near the bottom:
    zend_extension="/usr/local/zend/lib/php_extensions/xdebug.so" 
    
    [xdebug] 
    xdebug.remote_enable=1 
    xdebug.remote_host="localhost" 
    xdebug.remote_port=9000 
    xdebug.show_local_vars=On 
    xdebug.var_display_max_data=10000
    xdebug.var_display_max_depth=20
    

    (you should set up your xdebug settings as you require!)

  • Restart Apache:sudo zendctl.sh start-apache
  • The Server Setup->Extensions section of the admin interface should now show xdebug.

All in all, it’s remarkably easy to set up Zend Server using PEAR and PECL is which how it should be.

The only other gotcha I noticed is that my.cnf is in /usr/local/zend/mysql/data whereas I would have thought that /usr/local/zend/etc would have been more logical.

22 thoughts on “Some notes on Zend Server CE for Mac OS X

  1. Thanks.

    I've setup my php, apache and mysql using macports. It works but by the looks of it, this is a much cleaner solution.

  2. Great post, thanks!

    One thing that would be great is to change the htdocs directory to /Users/[username]/Sites to easily backup the users' folder with all projects. But then the admin console does not work any more. I did a workaround with sym-links in the /usr/local/zend/apache/htdocs directory.
    Any clue how to change the htdocs directory (Document Root) and still work with the admin console?
    Maybe also changing the mysql data directory to /Users/[username]/Sites/mysql-data?

    Thomas

  3. Hey,

    I followed your notes, and had some problems upgrading PEAR, and so, installing xdebug. (like some notices and warnings)

    Note that this is a version specific problem.
    Zend Server CE installed v1.8.0 and xdebug needed v1.8.1.

    If anyone has the same problem, here is the solution:

    sudo rm -Rf /usr/local/zend/share/pear/.channels

    sudo pear update-channels

    From: http://www.pear-forum.org/post-5065.html

    By the way, nice post, as always.

  4. I had trouble with OS X's default apache install interfering when I changed the port.
    You'll need to update /private/etc/apache2/httpd.conf to listen on another port.

    I don't know why /usr/sbin/httpd was running but I couldn't get rid of it!

  5. If you have trouble with pecl modules giving:

    mach-o, but wrong architecture in Unknown on line 0

    This is because ZS and it modules are 32bit and the default build is for 64bit arch, correct by manually building the modules using the configure command:

    ./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -g -Os -pipe" CXXFLAGS="-arch i386 -g -Os -pipe" LDFLAGS="-arch i386 -bind_at_load"

  6. Nice post, thanks!

    I had a couple of issues, so just posting in case anyone had similar problems:

    1. The default httpd.conf would sometimes override the zend httpd.conf, so I changed the default conf to listen to 8080.

    2. Problems with installing PEAR, so re-installed in usr/local (see
    http://www.newmediacampaigns.com/page/install-pear-phpunit-xdebug-on-macosx-snow-leopard), and added "/usr/local/PEAR" to the zend server php.ini include_path.

    3. xdebug.so was installed in "/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" by default, so just copied it over to the zend php extension dir "/usr/local/zend/lib/php_extensions/xdebug.so". Then it showed up in Server Setup > Extensions. The above "newmediacampaigns" link also has a link to a pre-compiled xdebug.so, so you can probably install it without the need to compile with xcode.

    cheers

  7. Another issue I found was that the xdebug section had to be earlier in the in ini file instead of the end. Otherwise, it was not recognized by php.

    Here is are my options, note the location right after the opening [php]…
    [PHP]

    [xdebug]
    zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
    xdebug.remote_enable=on
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler=dbgp
    xdebug.show_local_vars=on
    xdebug.var_display_max_data=10000
    xdebug.var_display_max_depth=20

  8. hello,

    i installed ZendStudio 7.2 and ZendServer on MacOS 10.6.5
    PHP Version 5.3.3
    Zend Framework Version 1.10.8

    Server is running an found in ZendStudio, but I always get the message

    http://localhost/ExampleProject/DebugDemo.php
    Page load failed with error: Connection to server could not be established.

    Has anybody an idea what I could try to make it work.

    best regards,
    dennis

  9. So I have installed xdebug, edited my php.ini, disabled optimizer and debugger and restarted zend community server on my mac but I cannot get anything to show up in the phpinfo page in regards to xdebug being installed.

    Any suggestions

  10. Awesome write up. I accidently put the xdebug configuration AFTER the zend configuration and it did not work. Make sure you put it before [zend]

  11. Great instructions thanks.

    However, I found that the install of ZendServer CE php 5.2 on MAC 10.6 was actually a 32bit install. The pear/pecl approach was compiling a 64bit xdebug.so, so was not compatible.
    When attempting to load xdebug.so, I got the error :
    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/xdebug.so' – (null) in Unknown on line 0

    This can be checked with these commands
    $ file -L /usr/local/zend/lib/php_extensions/xdebug.so
    /usr/local/zend/lib/php_extensions/xdebug.so: Mach-O bundle i386
    $ file -L /usr/local/zend/lib/php_extensions/curl.so
    /usr/local/zend/lib/php_extensions/curl.so: Mach-O bundle i386

    Note: both are i386=32bit.

    My solution was :
    1) to install xdebug from source.
    2) run phpize.
    3) Run :
    sudo MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -g -Os -pipe" CXXFLAGS="-arch i386 -g -Os -pipe" LDFLAGS="-arch i386 -bind_at_load" ./configure
    4) sudo make && sudo make install

    Then all seemed ok and works great with NetBeans :) I appreciate Zend as a company but ZendStudio (eclipse) version is just to slow and has annoying features. So glad I moved to NetBeans.

  12. This last note about the 32bit architecture and the cryptic instructions to compile it were awesome. I couldn't figure out for the life of me why Xdebug didn't load in Zend Server. I did all the above Rob Allen instructions exactly right. I even had the PECL installing right and everything went smoothly but I got the red error message in Zend Server Extensions. I just happened to glance at this and see the 32/64 bit thing and sure nuff upon using the file -L command to see the version I had it was 64bit and Xdebug downloads doesn't give you any other options.

    Thanks,

  13. Mae the changes to use Port 80. Launching the Zend Server CE opens "http://localhost:10081/ZendServer/#1308026840667" in my browser, and indicates the following error message:

    "The following error was retrieved from the Web server: Failed to parse response"

    Any clues?

  14. How do I install Zend Server CE and Mac OSX, I am struggling to find the link to download it on my Mac

Comments are closed.