PHP TUTORIAL
In this chapter we will learn how to install Apache Server on your local machine. We will then see how to add support for PHP to the server. You will need a local server to test your PHP programme before you deploy them on your final server. You may however skip this chapter if you have a server with PHP support installed either locally or at a server.Installating Apache on Local Machine
We are assuming that you will be installing the Apache server on you local Windows Machine. Go to
http://httpd.apache.org/download.cgi
Download the Microsoft Installer ( .msi ) package. Just double click on the icon to run the installation wizard. Click next until you see the Server Information window. Enter localhost for both the Network Domain and Server Name. This way your machine will act as a server for local files.
Enter any email address for Administrator's email.
This will complete the Apache server installation. To see if you Apache installation was successful open up you browser and type http://localhost in the address bar. You should see a webpage similar to the one below.
You should now check for the document root. The document root is where you must put all your PHP or HTML files so it will be processed by Apache. The document root is dictated by the conficuration file http.conf. The configuration file for Apache is stored in C:\Program Files\Apache Group\Apache2\conf\httpd.conf . It's just a plain text file so you can use Notepad to edit it.
If you want to put all your PHP or HTML files in C:\www just find this line in the httpd.conf :
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
and change it to :
DocumentRoot "C:/www" After making changes to the configuration file you have to restart Apache ( Start > Programs > Apache HTTP Server 2.0.50 > Control Apache Server > Restart ) to see the effect.
Another configuration you may want to change is the directory index. This is the file that Apache will show when you request a directory. As an example if you type http://www.php-mysql-tutorial.com/ without specifying any file the index.php file will be automatically shown.
Suppose you want apache to use index.html, index.php or main.php as the directory index you can modify the DirectoryIndex value like this :
DirectoryIndex index.html index.php main.php
Now whenever you request a directory such as http://localhost/ Apache will try to find the index.html file or if it's not found Apache will use index.php. In case index.php is also not found then main.php will be used.
Installating PHP
In the next chapter we will our first Hello world program.