Before you start programming with PHP, you must first acquire, install, and configure the PHP interpreter. PHP is available for a lot of platforms, and works in conjunction with many web-servers. Along with PHP itself and a web-server you also need a web-browser, so you can view the outcome of your work.
The latest version of PHP can be downloaded from www.php.net; after the download is complete, don�t forget to unpack the archive. There are two available downloads: the source code, which you can use to compile PHP, and the binary version of PHP, which means that it�s already compiled. If you�re new in the business, you should go with the binary version, for it will save you from a lot of headaches. If you don�t have already installed a web-server, you should go ahead install one for your operating system (for example Apache on Linux, and IIS or Apache on Windows); a web browser is also required, but this should be the least of your concern, you most probably have it already installed. If you don�t want to run the web-server on your own, you can find a hosting company that will host your web-site. This way, you can skip the installation, start writing scripts. There are a lot of hosting companies that offer free hosting services, just search it on the Internet and you�ll find a lot of offers to choose from.
PHP and your web-server
There are two ways of attaching PHP to your web-server. The first and most common way is with using PHP�s direct module interface – also called SAPI – for the most common web-servers: Apache, Microsoft IIS, Netscape and iPlanet. The second way to use PHP is as a CGI processor, which means that you must set up the server to use the command line executable of PHP, so it can process the PHP file requests on the server. This method mostly applies to the web-servers that PHP doesn�t have a direct module interface for.
PHP has installation instructions for both ways. Before installing, you should always make sure that you are logged into the system as the root user (administrator). If you�re not allowed to access the system�s root account, you should ask your system administrator to install PHP for you.
The first way of installing PHP and the easiest way to get PHP up and running is by using a direct module interface. This will require some configuring in your web-server; for example, Apache requires you to edit its configuration file and add a few new entries. In order to find out exactly what you need to do in order to properly install PHP on Apache, or any other web-server, you should read PHP�s documentation.
The second way of installing PHP is not always recommended by the web-server�s developer. Apache calls this method �suicidal�, because, if not configured properly, could allow a user with not-so-good intentions to access some of the web-server�s files which are not intended to be public. So if you�re a beginner, you should stay away from this method of installing PHP. Even advanced users sometimes fail to cover all the security issues.
After you�ve completed the installation, you should remember to take PHP for a test drive, before you start programming. You wouldn�t want to ask people around why your script isn�t working, when the installation wasn�t performed correctly.