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

Now look for the Win32 Binary without crypto (no mod_ssl) (MSI Installer). under "Apache HTTP Server 2.0.64 is also available". Click on the link httpd-2.0.64-win32-x86-no_ssl.msi which will download the Microsoft Installer ( .msi ) package. Just double click on the icon to run the installation wizard.

Here is the youtube, if you are stuck up somewhere.



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.

Please note that you may get updated and newer version at the time pass by, but this should give you an idea. If you are sruck , here is the tutorial in youtube ( We hope your internet has enough bandwidth to handle youtube).

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.



For now your Windows 7 system is setup to act as an Apache server and will serve all the html pages. It basically serves any page that is in the directory C:/Program Files/Apache Group/Apache2/htdocs. We suggest that you browse to the directory C:/Program Files/Apache Group/Apache2/htdocs and delete all the files ( index.html.ca , index.html.es etc) and create a new index.html file - that says "It works" ( Of course in HTML ). If you are successful, you should see something like this
At this point we would like to point out that you may be able to create a symbolic link so that your files in another directory is also served. But we will come to that later on. For now we want to get something quick. And we have not yet included support to server php file. You can only serve .html files.

Installing PHP Server


You now need to add support for PHP in Apache. We are going to do it for your Windows machine. Go to http://windows.php.net/download/ and download and install the PHP 5.2(5.2.17) VC6 x86 - Thread Safe Installer.

See this youtube if this is not clear.

A note on localhost



We will be writing php code and save them in the directory C:\wwww\ - and check the program by browsing to the http://localhost/. For example if we write and save a program like tutorial1.php in C:\www as C:\www\tutorial1.php, we can test see it in action using http://localhost/tutorial1.php. In real life, you will have a domain name and a server. We will cover this topic sometimes later chapters.

Summing it up



We have basically set up the environmengt for learning PHP. You are now ready to learn PHP and you will be writing your first PHP code - A simple "Hello World Program" We will do it in the next page.