Saturday, February 14, 2009

Getting started with PHP- PART 1

Before you can start coding and running PHP you must have Apache HTTP Server running on your local machine. You can use XAMPP from Apache Friends.

There are four operating systems supported by XAMPP: Linux, Mac OS X, Solaris, and Windows. The package can downloaded from the Apache Friends Web site and it installs quite handily.

Installing XAMPP for Windows Client

1. Create a folder to catch the archive file:

MD C:\downloads\XAMPP

Feel free to put this on E or F or your favorite client drive as long as it has a few hundred meg of extra space available.

2. Start the download process at the following link:

http://www.apachefriends.org/en/XAMPP-windows.html

3. Scroll down to "Download" and click on the XAMPP link.

4. You will see some information about various ways to install. Three different downloads are available:

Windows Installer--This uses the typical Windows installation approach. Its advantage is that it is familiar and safe for anybody who has ever installed a package to Windows that updates the registry.

ZIP archive--This is a normal ZIP archive that can be unzipped by PKZIP or WINZIP.

Self-extracting 7-ZIP archive--This is a special high compression ration version that requires you to load a special unzipper. This method is very economical in size but it does require an additional product to unzip.

5. Because I was not interested in downloading another archive product and because I just got my new high-speed cable connection, I selected the standard ZIP archive with no Windows installer required.

Scroll down to "XAMPP Windows 1.6.3a" (basic package) and click on "ZIP" (80 MB Zip Archive).

6. Choose "Save to Disk."

7. Select "x:\downloads\XAMPP" (X = drive letter) and click "Save" to save the "xampp-win32-1.6.3a.zip" file.

8. Go to the "x:\downloads\xampp" folder and click on the archive to run the extraction.

9. Select the option to extract to a first level directory named "x:\xampp" in which "x" is the drive letter where you want the package installed. In my case, I picked c:\XAMPP.

10. Click to go inside the c:\xampp folder to see the file structure:

11. Create a folder within htdocs called "MYPHP" for your stuff.

MD c:\XAMPP\htdocs\MYPHP

This is the htdocs for PHP and Apache and MySQL.

12. By extracting XAMPP in a top level folder like c:\xampp or d:\xampp as you will, you can start XAMPP directly. That means you do not need to execute the "setup_xampp.bat" at all. Apache, MySQL, and Mercury Mail server will start up correctly! The FileZilla FTP server will not start because it requires absolute paths. Please note: Do not use a double-XAMPP-folder like c:\xampp\xampp! You need a single- XAMPP folder like d:\xampp(\apache and so on). Otherwise you must run the "setup- XAMPP.bat" to set up the path configurations. Do not run the setup-xampp.bat procedure.

13. Click to open the c:\xampp folder.

14. Click on xampp_start.exe and it should all start.

15. Check the DOS box that appears. It looks like this:

16. Do not end the DOS box unless you intend to shut down XAMPP. While you're at it, take a little German lesson and you get an idea of where the roots of XAMPP originate.

17. To see if your installation has worked, type the following in the URL of a browser from your client workstation:

http://localhost

18. Check to make sure you see a panel such as the following:

19. Click on "English" or your preferred language to continue.

20. Check to make sure you see this panel:

Once you are in, check for status, security, documentation, etc., by clicking the menu items on the left frame. All of these functions are written in PHP scripts.

Here are some more server scripts, you might find useful:

  • Apache & MySQL start: .\xampp\xampp_start.exe
  • Apache & MySQL stop: .\xampp\xampp_stop.exe
  • Apache start: .\xampp\apache_start.bat
  • Apache stop: .\xampp\apache_stop.bat
  • MySQL start: .\xampp\MySQL_start.bat
  • MySQL stop: .\xampp\MySQL_stop.bat
  • Mercury Mailserver start: .\xampp\mercury_start.bat
  • FileZilla Server setup: .\xampp\filezilla_setup.bat
  • FileZilla Server start: .\xampp\filezilla_start.bat
  • FileZilla Server stop: .\xampp\filezilla_stop.bat

In addition to the Apache and MySQL start script (xampp_start.exe) that we have already used, there are a number of other scripts available in the list above. The script that may be of most use to you is the universal control center script that is called "call .C:\XAMPP\XAMPP-control.exe." As a point of note, the control center is not included in the lite version. Before you start the control center, right click on it and copy the icon to the desktop so that you can start and stop at will.

When you click on this or type it into the Windows command prompt, you get a GUI to help control the server operations.

Notice all of the servers monitored by this control center are running. You need just Apache and MySQL to handle simple scripts.

You now have the developer's dream machine for PHP.

Cheers :).

4 comments:

Anonymous said...

How about SQL connection for database connection.

-Darkshadow

napster creator said...

Database connection will be done via PHP coding and that will be in the next article. :)

Anonymous said...

i just downloaded the scourge save a lot of file extract for 100% from what you have blog.

Anonymous said...

I just installed xampp apache friends from the http://sourceforge.net/project/downloading.php?groupname=xampp&filename=xampp-win32-1.7.0-installer.exe&use_mirror=jaist
it almost took me 4-5 mins to download the file whats the rush.