Laran Evans
I develop software people love to use.
  • Home
  • About
  • Contact
  • Resume
  • Testimonials
Skip to content
  • Entrepreneurship
    • Leadership
    • Project Management
    • Team Development
    • Time Management
  • Puzzles
  • Software Architecture
    • Cloud Computing
  • Software Development
    • Algorithms
    • CSS
    • Java
    • Javascript
    • MySQL
    • PHP
    • Python
    • Ruby and Rails
    • System Administration
« Rails ActionMailer the right way
5 Reasons Your Data is a Mess »

Configuring ZendServer to use Pear on OSX 10.5

By laran | Published: 2009/05/12

I had some issues yesterday trying to use some Pear libraries in a web app.

So, I checked my Pear config:

me:ZendServer laran$ pear config-show
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    
PEAR executables directory     bin_dir          /opt/local/share/pear/bin
PEAR documentation directory   doc_dir          /opt/local/share/pear/PEAR/docs
PHP extension directory        ext_dir          /Applications/ZendServer/lib/php/20060613
PEAR directory                 php_dir          /opt/local/share/pear/PEAR
PEAR Installer cache directory cache_dir        /tmp/pear/cache
PEAR configuration file        cfg_dir          /Applications/ZendServer/share/pear/cfg
directory
PEAR data directory            data_dir         /opt/local/share/pear/PEAR/data
PEAR Installer download        download_dir     /opt/local/share/pear/temp/download
directory
PHP CLI/CGI binary             php_bin          /Applications/ZendServer/bin/php
php.ini location               php_ini          
PEAR Installer temp directory  temp_dir         /opt/local/share/pear/temp
PEAR test directory            test_dir         /opt/local/share/pear/PEAR/tests
PEAR www files directory       www_dir          /Applications/ZendServer/share/pear/htdocs
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            22
Debug Log Level                verbose          1
PEAR password (for             password         
maintainers)
Signature Handling Program     sig_bin          /usr/local/bin/gpg
Signature Key Directory        sig_keydir       /Applications/ZendServer/etc/pearkeys
Signature Key Id               sig_keyid        
Package Signature Type         sig_type         gpg
PEAR username (for             username         
maintainers)
User Configuration File        Filename         /Users/laran/.pearrc
System Configuration File      Filename         /Applications/ZendServer/etc/pear.conf
me:ZendServer laran$

That’s wack. Why are my Pear libraries in /opt/local?

So, I changed those settings so that everything would be in /Applications/ZendServer

me:ZendServer laran$ sudo pear config-set php_dir /Applications/ZendServer/share/pear/PEAR
config-set succeeded
me:ZendServer laran$ sudo pear config-set data_dir /Applications/ZendServer/share/pear/PEAR/data
config-set succeeded
me:ZendServer laran$ sudo pear config-set temp_dir /Applications/ZendServer/share/pear/temp
config-set succeeded
me:ZendServer laran$ sudo pear config-set test_dir /Applications/ZendServer/share/pear/PEAR/tests
config-set succeeded
me:ZendServer laran$ sudo pear config-set bin_dir /Applications/ZendServer/bin
config-set succeeded
me:ZendServer laran$ sudo pear config-set download_dir /Applications/ZendServer/share/pear/temp/download
config-set succeeded

Knowing that the Zend command line php executable is php-cli, not php, I made one last tweak:

me:ZendServer laran$ sudo pear config-set php_bin /Applications/ZendServer/bin/php-cli
dyld: Library not loaded: /usr/local/postgresql-8.2.3/lib/libpq.5.dylib
  Referenced from: /Applications/ZendServer/bin/php
  Reason: image not found
Trace/BPT trap

Doh! Looks like the damage was already done. So, I had to manually modify /Applications/ZendServer/bin/pear to use php-cli. Here’s what it looked like when I was done.

#!/bin/sh

# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
  PHP="$PHP_PEAR_PHP_BIN"
else
  if test "/Applications/ZendServer/bin/php" = '@'php_bin'@'; then
    PHP=php-cli
  else
    PHP="/Applications/ZendServer/bin/php-cli"
  fi
fi

# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
  INCDIR=$PHP_PEAR_INSTALL_DIR
  INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
  if test "/Applications/ZendServer/share/pear/PEAR" = '@'php_dir'@'; then
    INCDIR=`dirname $0`
    INCARG=""
  else
    INCDIR="/Applications/ZendServer/share/pear/PEAR"
    INCARG="-d include_path=/Applications/ZendServer/share/pear/PEAR"
  fi
fi

exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"

The changes in there are on lines 8 and 10, I changed php to php-cli.

Now I can go back to change the Pear php_bin config properly:

me:ZendServer laran$ sudo pear config-set php_bin /Applications/ZendServer/bin/php-cli

Just to be sure, I checked the include_path in /Applications/ZendServer/etc/php.ini. Be sure that /Applications/ZendServer/share/pear/PEAR is on the path.

Restart apache with sudo /Applications/ZendServer/apache2/bin/apachectl restart

Lastly, any modules I’d installed while Pear was still configured to install them to /opt/local have to be re-installed.

And with that, I was ready to rock! Hope this helps.

This entry was posted in PHP and tagged osx, pear, PHP, Tech Tips. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
« Rails ActionMailer the right way
5 Reasons Your Data is a Mess »

2 Comments

  1. Billy
    Posted 2010/03/26 at 7:30 AM | Permalink

    What will be best setup of Zend Server to enable CLI

  2. laran
    Posted 2010/04/03 at 12:04 PM | Permalink

    What operating system are you running? The CLI environment is pretty different depending on the OS and how you have PHP installed etc.

Post a Comment

Click here to cancel reply.

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • About Me

    I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods. Read more »

  • Subscribe

  • Similar Posts
    • Symfony+Pear: Task "generate:project" is not defined.
    • Installing Magento on Dreamhost the easy way
    • Simple Fix for Apache on Snow Leopard
    • How to Upgrade MacPorts Without Deleting Everything
Hello world
  • From Around the Web

    • Chopper Girl @ The 2010 Brass Balls Long Road Party (Uploads from BRASS BALLS BOBBERS)
    • Web App Business Models: User Needs and What People Pay For (Box UK Blog)
    • Blog Writing Tips from the World’s Most Famous Authors (Blogsessive.com)
    • How to get exponential success on your blog (CatsWhoBlog.com)
    • The Four Stages of Growing a Blog (Daily Blog Tips)
    Shared Items
  • Recent Posts

    • 80 pages of Ruby on Rails Performance Optimization Tips
    • Ruby Garbage Collection In-Depth
    • Binary Logic Basics
    • Kuali in Nacubo Magazine
    • Ruby Blocks, Procs, Lambda
  • Older Posts By Month

    Let's Talk

    Ask a question below. You'll be prompted for your name and email after you click the "Ask" button.

Know more. Accomplish more. Succeed.