Site Administration Page 5 - Building Apache, MySQL, and PHP on Mac OS X |
The last step is to get PHP set up. Now PHP is decompressed and ready to be configured. The --with-mysql option tells the configure script that we want to use the MySQL libraries that were installed with MySQL instead of the ones that come with PHP. The --with-apxs option does the same thing it does in the mod_dav configuration, tells the configure script that we want PHP compiled as a DSO, and the --with-zlib option tells the configure script where to find the zlib libraries it needs (These are included in Mac OS X). Running the configure script strangely breaks one file in the distribution, main/internal_functions.c. In that file, some of the #include lines are run together into one line, and have the letter "n" separating them. You can edit this file manually to fix this, but I've made a Perl script that will do the trick, if you'd rather use it. Execute the following commands to use my script. % wget http://www.devshed.com/article-images/fix_php.pl % chmod +x fix_php.pl This will get the script and allow you to execute it, and % ./fix_php.pl will run it, fixing the problem. % make % sudo make install These commands will compile, install, and enable the PHP module. You're not done yet, you need to tell Apache to use the PHP module for all files with a .php extension. Edit the Apache configuration file: % sudo pico /etc/httpd/httpd.conf and remove the #s from the lines that look like this: # And for PHP 4.x, use: # #AddType application/x-httpd-php .php #AddType application/x-httpd-php-source .phps so they end up looking like this: # And for PHP 4.x, use: # AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps and restart your Apache server. % sudo apachectl restart Now, to test your PHP setup, you'll need to make a PHP script. Type the following: % pico /Library/WebServer/Documents/phpinfo.php and paste this in: <?php phpinfo(); ?> Save and exit, then open up your web browser and go to http://localhost/phpinfo.php If everything is working correctly, your browser will display a nicely formatted page with info about your PHP installation, and we're done!
blog comments powered by Disqus |
|
|
|
|
|
|
|