Now: Tutorial for Web and Software Design > PHP > PHP Basic > PHP Content
> PHP 4.3 and Mac OS X [Bookmark it]
PHP 4.3 and Mac OS X

PHP 4.3 and Mac OS X

In addition to configuring PHP to support additional extensions, you also need to tell PHP where to install its files. Apple stores files in a different set of directories than PHP's preferred location. However, you can instruct PHP to override its default settings to conform with Apple's.



To do this, pass in these four settings:

--prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man

Once you set up PHP to install files correctly, add your Web server into the mix. If you don't specifically tell PHP your Web server, PHP builds a generic CGI version. But, if you're running Apache, for instance, PHP can create an Apache module. Apache 1.x support is added by passing in --with-apxs.

--with-apxs

If you're running Apple's bundled Apache, PHP automatically locates your server and properly configures itself accordingly. (This will probably work even if you've reinstalled Apache.)

Other Web servers have different commands. The experimental PHP Apache 2.x filer is built with --apxs2. For others, run the help command, as mentioned earlier. It shows a list of Web server options.

One final configuration note. PHP does not install zlib automatically, and without zlib, MySQL and other programs won't run. So, explicitly add this extension to your configuration line:

--with-zlib

Putting all this together gives us these parameters for a basic Apache and PHP installation:

[benlev:~/php-4.3.0] adam% ./configure --prefix=/usr --sysconfdir=/etc 

 --localstatedir=/var --mandir=/usr/share/man --with-apxs --with-zlib

Hit return and configure will run for a while, printing out a series of scrolling lines, before finally ending with this message:

+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE.  By continuing this installation |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+

|                          *** NOTE ***                              |

|            The default for register_globals is now OFF!            |

|                                                                    |

| If your application relies on register_globals being ON, you       |

| should explicitly set it to on in your php.ini file.               |

| Note that you are strongly encouraged to read                      |

| http://www.php.net/manual/en/security.registerglobals.php          |

| about the implications of having register_globals set to on, and   |

| avoid using it if possible.                                        |

+--------------------------------------------------------------------+

Thank you for using PHP.

As you see, PHP now disables the register_globals configuration directive. This change is effective as of PHP 4.2, but if you're upgrading directly from Apple's installed version (4.0.6), this is the first time the change affects you. In brief, you can no longer access a HTML form variable called "name" as $name. Instead, you need to check the value of $_GET['name'] or $_POST['name']. See the online PHP manual for additional information.

If you don't see this message, PHP had a problem during configuration. Look at the error message and fix what's broken. If you cannot solve the problem by yourself, check the Installation PHP mailing list for help.

Now that the laborious configuration process is complete, compile PHP by running make:

[benlev:~/php-4.3.0] adam% make

This will take a while. Don't be afraid if you see warnings. Warnings are okay; errors are not. There's no fancy announcement when this finishes, so unless you see an obvious error message, everything went OK when the printing stops.

Finally, you want to install PHP. This overwrites any pre-existing copies of PHP on your system. So, if you want to keep them (for testing purposes or nostalgia), now is the time to back them up. If you've chosen to use the directories suggested above, you need administrator privileges to install PHP, so run this command through sudo:

[benlev:~/php-4.3.0] adam% sudo make install

The installer places the Web server module in the correct place, installs the PHP command line version, and also places PEAR onto your system. (A few helper files are also installed.)

If you run Apache and PHP, restart your Web server to use your new copy of PHP:

[benlev:~/php-4.3.0] adam% sudo apachectl graceful

You can verify everything worked OK by viewing a page containing the output from phpinfo(). Check out the version number, build date, and configuration options to make sure.

However, if you're trying out PHP and Apache for the first time, see Kevin Hemenway's article on Apache and PHP to learn how to configure Apache to support PHP.

The command line interface to PHP (aka PHP CLI) lets you execute PHP scripts without the overhead of requesting them using a Web browser. Recently released versions of PHP had unofficial support for the CLI, but it has gone final with 4.3.0. If you want to use PHP for system maintenance tasks or with PHP-GTK, the CLI is for you. (Note: If you've chosen to install PHP as a CGI instead of a Web server module, then you need to explicitly install the CLI using make install-cli. This isn't a problem for people installing PHP as an Apache module, as described earlier in this article.)

Congratulations. You now have a working copy of PHP 4.3 on your Macintosh. Enjoy.


O'Reilly & Associates recently released (November 2002) PHP Cookbook .

  • Beta Sample Chapter 8, Web Basics, is available free online.

  • You can also look at the Full Description of the book.

  • For more information, or to order the book, click here.

Adam Trachtenberg is the manager of technical evangelism for eBay and is the author of two O'Reilly books, "Upgrading to PHP 5" and "PHP Cookbook." In February he will be speaking at Web Services Edge 2005 on "Developing E-Commerce Applications with Web Services" and at the O'Reilly booth at LinuxWorld on "Writing eBay Web Services Applications with PHP 5."


Return to the PHP DevCenter.

Prev  [1] [2] 

[Bookmark][Print] [Close][To Top]
  • Prev Article-PHP:

  • Next Article-PHP:
  • Related Materias
    Managing Sessions and Stat
    Autofilled PHP Forms
    Implementing MVC in PHP: T
    Implementing MVC in PHP: T
    Simplify PHP Development w
    Testing PHP Code with PHPU
    PHP Code Generation with E
    Implementing MVC in PHP: T
    Understanding MVC in PHP
    Important Notice for PHP D
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial