PHP on Apache: The Definitive Installation Guide Page 5
Download the authoritative guide: Data Center Guide: Optimizing Your Data Center Strategy
Download the authoritative guide: Cloud Computing: Using the Cloud for Competitive Advantage
% cat <<EOP > script-test.php3 > #!/usr/local/bin/php -q > <? echo "PHP script interpreter is OK!\n"; ?> > EOP % chmod 755 script-test.php3 % ./script-test.php3 PHP script interpreter is OK! %
-q' switch tells the interpreter to suppress the '
Content-type: text/html' line it ordinarily prints by default (because it assumes it's being run as a CGI script).
If PHP was built as an Apache module, the simplest way to test it is to create a file in the
DocumentRootthat contains this single line:<? phpinfo(); ?>
and then fetch it in a browser. It should display a long and detailed Web page describing the PHP module, the extensions that were included when it was built, and the Apache environment as well.
With PHP installed and working, what do you do then? Well, that's really up to you--but for a couple of examples of what's possible, check out the PHP site itself and the ApacheCon 2000 site. The PHP site is totally driven by the software; as you browse through the online documentation, you can see that not only is it 'live,' meaning that you can comment on it or make suggestions for improvements, but you can also see what other people have suggested. The ApacheCon 2000 site uses PHP to display the very latest information on sessions, speakers, sponsors, and other aspects of the conference, building each page when it's requested from the data, stored in a MySQL database.
The documentation link at the PHP site is invaluable. While it doesn't give a lot of guidance on how to accomplish things, it's very complete when it comes to descriptions of the PHP functions. For more, check USENET or the PHP mailing lists.
One final trick, which is illustrated at the PHP site, is to add the 'show me the source' feature to your server. Add a line like this to your
AddType application/x-httpd-php3-source .phps
and then soft-link
.php3files to the same name with a
.phpsextension, as with% ln -s some-php-file.php3 some-php-file.phps
.phpsfile in a Web browser will display the source of a PHP (or PHP-enabled HTML) file, nicely color-coded.
If running the Apache Web server and wanting to make your Web pages more interactive, responsive, personalised or otherwise to "spice them up," PHP is an easy and excellent way to do it. The software is under constant intense scrutiny by dozens of developers, so problems are fixed quite quickly.
Got a Topic You Want Covered?
If you have a particular Apache-related topic that you'd like covered in a future article in this column, please let me know at <coar@Apache.Org>. I do read and answer my email, usually within a few hours (although a few days may pass if I'm travelling or my mail volume is way up). If I don't respond within what seems to be a reasonable amount of time, ping me again!
Appendix A: Building Apache at Lightspeed
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...