It is easier to develop your PHP scripts locally on your own computer and then upload your files once everything is tested. Saving, uploading and testing to a remote server is an arduous task. To develop your PHP files locally you will need to download and install Apache Web Server, and PHP on you Windows Operating System.
Installing, configuring and testing Apache
After downloading Apache, install the server on your computer. After the installation find and load the file “C:\Program Files\Apache Group\Apache\Conf\httpd.conf” into a text editor.
In httpd.conf search for #LoadModule. There should be a list of modules that can be loaded. Leave those alone, but directly under them, add these lines:
LoadModule php4_module c:/php/sapi/php4apache.dll
AddType application/x-httpd-php .php
Now find the line:
DocumentRoot “C:/Program Files/Apache Group/Apache/htdocs”
This is the directory out of which you will serve your PHP documents. By default, all requests are taken from this directory, but you can change the directory, for example to:
Now let’s test our server. Create a file test.html:
<TITLE>Apache server test</TITLE>
Apache server test.
Place the file to the directory that you set above. Now start your Apache server:
Start -> Program Files -> Apache -> Management -> Start Apache.
Now start your browser, and type in:
If you get:
Apache server test.
Congratulations! Your server is up and running, and we are ready to install and test PHP.
Installing and testing PHP
If you already downloaded PHP, unzip the file to C:\php.
Stop Apache. At c:\php find and copy php4ts.dll to the Windows\System directory. That’s it.
Now, create a file called test.php:
print “PHP test.”;
Place it into the directory you set as the document root, start up your Apache server, and type this into the location bar of your browser:
You should get:
Congratulations! Now you are ready to run your PHP scripts on your computer and then upload your PHP files online. But first you should learn PHP.
What’s more, you can even install MySQL database on your own computer and develop PHP scripts with MySQL queries. Visit our MySQL tutorial and find out more about databases.
Well, let’s go to the next tutorial PHP document structure.