PHP 4.3 and Mac OS X
Pages: 1, 2
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.
-
Problem getting php to recognize curl
2006-04-11 01:07:20 billc108 [View]
-
Great resource!
2005-10-30 08:36:43 Working_in_PJ [View]
-
PHP 4.3.10 on OS X 10.2.8
2005-02-01 11:59:50 rmwiseman [View]
-
PHP 4.3.10 on OS X 10.2.8
2005-02-03 11:59:07 rmwiseman [View]
-
missing commands in terminal
2004-12-21 10:02:10 jamiekravitz [View]
-
missing commands in terminal
2005-01-17 18:00:30 nika_berlin [View]
-
Compile Errors
2004-02-29 05:08:12 samsprograms [View]
-
"./configure --with" does not seems to work
2004-02-12 01:15:12 jeanloui [View]
-
some advances
2004-02-12 05:50:31 jeanloui [View]
-
some advances
2004-04-07 22:14:33 Adam Trachtenberg |
[View]
-
upgrading to 4.3.6
2004-05-07 05:10:59 jeanloui [View]
-
error logs
2004-02-12 02:37:10 jeanloui [View]
-
error logs
2004-04-07 22:10:03 Adam Trachtenberg |
[View]
-
adding directives in the future
2004-01-27 07:40:42 nicki [View]
-
adding directives in the future
2004-01-29 18:04:06 Adam Trachtenberg |
[View]
-
MySQL import and/or compiling problems
2003-12-16 11:30:49 dmcole [View]
-
Solution to FreeType2 not found!
2004-01-16 19:23:38 anonymous2 [View]
-
Solution to FreeType2 not found!
2004-01-29 18:59:07 Adam Trachtenberg |
[View]
-
Are these instructions compatible with OS X 10.3 Panther?
2003-11-02 10:05:17 anonymous2 [View]
-
Are these instructions compatible with OS X 10.3 Panther?
2003-11-27 15:46:46 anonymous2 [View]
-
Are these instructions compatible with OS X 10.3 Panther?
2003-12-02 21:30:54 Adam Trachtenberg |
[View]
-
Succesfull install.
2003-09-08 11:18:13 anonymous2 [View]
-
Zend Optimizer installed
2003-08-24 13:43:02 anonymous2 [View]
-
error during make
2003-07-02 15:18:59 anonymous2 [View]
-
Error during make
2003-06-24 15:08:40 anonymous2 [View]
-
Files with php3 extensions will not execute.
2003-06-10 08:29:09 anonymous2 [View]
-
Files with php3 extensions will not execute.
2003-06-10 09:17:13 Adam Trachtenberg |
[View]
-
error: no acceptable cc found in $PATH
2003-05-28 15:43:02 anonymous2 [View]
-
error: no acceptable cc found in $PATH
2003-05-29 20:23:52 Adam Trachtenberg |
[View]
-
error: no acceptable cc found in $PATH
2005-04-27 21:35:18 nickos [View]
-
Error During 'sudo make install'
2003-05-23 19:54:49 anonymous2 [View]
-
Error During 'sudo make install'
2003-05-29 20:30:27 Adam Trachtenberg |
[View]
-
Great article...but my old build is still serving pages
2003-05-20 05:16:20 anonymous2 [View]
-
Update--still the same after reboot
2003-05-20 05:30:28 anonymous2 [View]
-
Sigh. Never mind
2003-05-20 08:12:04 anonymous2 [View]
-
Sigh. Never mind
2003-05-20 11:38:18 Adam Trachtenberg |
[View]
-
Sigh. Never mind
2003-05-29 20:32:23 Adam Trachtenberg |
[View]
-
PDFlib, pdflib.upr
2003-05-30 10:37:59 anonymous2 [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2003-05-07 10:44:46 anonymous2 [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2004-04-07 18:04:14 jamfan [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2004-04-08 02:04:34 jamfan [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2004-03-03 16:39:58 daveola [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2003-10-08 19:14:50 anonymous2 [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2004-02-27 05:04:16 tristanr [View]
-
Problems compiling Php4.3.1 with java on Mac OsX
2003-05-12 22:17:11 Adam Trachtenberg |
[View]
-
Zend Optimizer
2003-04-22 16:40:39 anonymous2 [View]
-
Zend Optimizer
2003-04-22 18:07:22 Adam Trachtenberg |
[View]
-
Instalation
2003-03-14 06:18:35 anonymous2 [View]
-
Instalation
2003-04-22 17:49:18 Adam Trachtenberg |
[View]
-
These instructions don't seem to work
2003-02-16 23:28:52 anonymous2 [View]
-
These instructions don't - But I got it
2003-03-25 12:18:45 anonymous2 [View]
-
These instructions don't seem to work
2003-02-28 21:06:42 tychay [View]
-
Features List ?
2003-02-11 17:23:40 anonymous2 [View]
-
Features List ?
2003-02-28 20:07:59 tychay [View]
-
error on installation
2003-02-09 15:05:22 anonymous2 [View]
-
Developer Tools
2003-02-09 19:20:01 ayakotan [View]
-
Cannot update to 4.3 --please help!
2003-02-08 21:00:40 anonymous2 [View]
-
Cannot update to 4.3 --please help!
2003-02-09 19:18:47 ayakotan [View]
-
Having problems with LDAP
2003-02-04 08:22:35 qperkins [View]
-
Having problems with LDAP
2003-02-24 14:58:35 qperkins [View]
-
Having problems with LDAP
2003-02-28 20:37:42 tychay [View]
-
mysql
2003-01-29 20:09:39 anonymous2 [View]
-
mysql
2003-02-28 19:42:53 tychay [View]
-
macosx precompiled binaries
2003-01-28 20:54:34 anonymous2 [View]
-
--with-zlib fails to find libz, any corrected instructions known?
2003-01-28 18:50:06 anonymous2 [View]
-
--with-zlib fails to find libz, any corrected instructions known?
2003-02-28 19:43:17 tychay [View]
-
php set-up problem
2003-01-24 07:21:57 anonymous2 [View]
-
php set-up problem
2003-01-24 14:54:08 Adam Trachtenberg |
[View]
-
CURL version stops installl
2003-01-23 09:19:31 anonymous2 [View]
-
CURL version stops installl
2003-01-24 14:45:49 Adam Trachtenberg |
[View]
-
Installation ?
2003-01-22 19:22:21 anonymous2 [View]
-
Installation ?
2003-02-28 19:12:19 tychay [View]
-
Installation ?
2003-01-23 08:04:20 Adam Trachtenberg |
[View]
-
Location of fink packages
2003-01-21 12:55:35 anonymous2 [View]
-
Location of fink packages
2003-01-21 13:56:11 Adam Trachtenberg |
[View]
-
Location of fink packages
2003-02-28 19:04:15 tychay [View]
-
mcrypt
2003-01-21 08:48:03 anonymous2 [View]
-
mcrypt
2003-01-21 16:16:54 Adam Trachtenberg |
[View]
-
mcrypt
2003-02-28 18:55:56 tychay [View]
-
ldap library...
2003-01-19 16:13:40 anonymous2 [View]
-
compile problems
2003-01-19 02:50:10 anonymous2 [View]
-
compile problems
2003-01-19 11:56:08 maarky [View]
-
What version??
2003-01-17 13:33:40 anonymous2 [View]
-
What version??
2003-01-17 21:44:52 Adam Trachtenberg |
[View]
-
Configuring with PHP 4.3's bundled libgd
2003-01-17 02:46:25 maarky [View]
-
Configuring with PHP 4.3's bundled libgd
2003-01-17 08:24:44 Adam Trachtenberg |
[View]
-
Configuring with PHP 4.3's bundled libgd
2003-01-18 04:33:45 pierre_ [View]
-
Configuring with PHP 4.3's bundled libgd
2003-01-20 13:33:37 Adam Trachtenberg |
[View]
-
Configuring with PHP 4.3's bundled libgd
2003-02-28 18:45:24 tychay [View]
-
where is php.ini
2003-01-17 00:45:01 anonymous2 [View]
-
where is php.ini
2003-02-28 18:40:14 tychay [View]
-
where is php.ini
2005-06-10 07:46:19 zicco [View]
-
where is php.ini
2003-01-17 02:27:18 maarky [View]
-
where is php.ini
2003-09-26 11:36:44 anonymous2 [View]
-
GD with GIF? Ming?
2003-01-16 22:26:46 dogzilla [View]
-
GD with GIF? Ming?
2003-02-28 21:30:27 tychay [View]
-
GD with GIF? Ming?
2003-01-17 08:19:19 Adam Trachtenberg |
[View]
-
include_path
2003-01-16 19:43:26 Steve Mallett |
[View]
-
include_path
2003-01-17 02:15:55 maarky [View]