Приглашаем посетить
Черный Саша (cherny-sasha.lit-info.ru)

Chapter 2: Installation

Table of Contents
Previous Next

Chapter 2: Installation

This chapter provides step-by-step instructions for installing and configuring PHP on UNIX-like systems, Windows, and MacOS systems. Additional instructions for installing Apache and MySQL are provided. We also include some suggestions for what to do "in the unlikely event" something goes wrong.

I Already Have PHP

If you already have PHP on your web server, you'll still need to verify that your installation of PHP is configured with all the tools you'll need for this book. Fortunately, there is a built in PHP function, called phpinfo(), to provide status output of virtually everything configurable.

If you have a web server, simply create a text file just like you would an HTML file, but put only one line in it:

    <?php
    phpinfo();
    ?>

You do not need any HTML tags. The phpinfo() function will output everything needed. If your fancy HTML-editor insisted on adding <html> and <body> tags and you can't get rid of them, most browsers will probably cope with it.

Save the file as phpinfo.php and verify that the filename is correct. Notepad tends to add .txt to the end of filenames whether you want it to or not: phpinfo.php.txt will not work. EditPlus from http://www.editplus.com/ is a great alternative to Notepad, but there are dozens of others. Upload phpinfo.php to your web server.

Surf to http://localhost/phpinfo.php and you'll get a long page of all the features installed with PHP.

Sample output of phpinfo() is provided later in this chapter, but there are only a few possible outcomes here:

In case 1, you have PHP, and you can simply read on. In case 2, you either didn't use .php for the file extension, or your web server is not configured with PHP. In case 3, you either uploaded the file to the wrong place, or didn't name it phpinfo.php or didn't surf to the correct URL or similar. Check the URL, the filename, and the upload directory. In case 4, PHP was probably installed, but incorrectly, and the web server is crashing. Read the remainder of this chapter for suggestions on how to track down what is going on.

Once you see the pretty blue and grey boxes, you know you have PHP running, but you need to ensure that the following are somewhere in the text:

You may want to use the browser's Find menu item to search for keywords. If a keyword is truly missing (check your spelling) then it is not installed. You may be able to work around one or two of these features if they are missing or if the version number is a little older than required. However, if your software is way out of date, or is missing multiple features required, you'll need to upgrade.

Also, it may be easier and less time consuming to find an ISP that supports PHP and MySQL than it is to try and build a web server. There are over 2,000 listed in a database for you at http://hosts.php.net/. Some are quite reasonable in cost, and your time and effort are worth a lot.

If you are just a web developer who wants to learn PHP and you don't already run a web server, finding a host that supports PHP and MySQL is probably your smartest option. You may still want to install PHP and MySQL on your desktop or laptop, but you could easily work through the rest of this book first and do that later. It still would be a good idea to skim this chapter so you have a rough idea of how MySQL, Apache, and PHP are installed, and how they interact with each other. Your ISP may not have done things exactly this way, but it will be pretty close.


Table of Contents
Previous Next