Tuesday 28 May 2013

How to get started with PHP

PHP does not come pre-installed on Windows systems. To work with PHP on Windows, PHP will need to be manually downloaded and installed. instead of downloading separate PHP we will download XAMPP, it is a free and open source cross-platform web server solution stack package. ( its a bundle which contains all the required libraries to run a PHP program) 
XAMPP's name is an acronym for

  • X- (to be read as "cross", meaning cross-platform)
  • A- Apache HTTP Server
  • M- MySQL
  • P- PHP
  • P- Perl
How to Install XAMPP ?

  1. Select the Installer option under the Basic Package. You may be taken to a page that presents you with a bunch of different download locations. Just click one of the download buttons, and then save the file to your desktop. Once downloaded, the installer works like most Windows installers.
    In Internet Explorer, you may get a warning about downloading the file. Click the yellow information bar that appears above the Web page in IE, and choose Download File…

  2. Double-click the .exe file you downloaded.

    A window opens, asking you to select the language you’d like to use.
    If a warning dialog appears click the "Allow" option to install XAMPP.

  3. Choose a language from the menu, and then click OK.

    A Setup Wizard window appears, ready to step you through the setup process.
    In Vista you may see a message warning you that XAMPP may not work when installed in the C:\Program Files directory. The default installation is in C:\XAMPP so you don’t have to worry about this problem.

  4. Click the Next button.

    The installer suggests putting the application on your main drive at C:\XAMPP. You can pretty much install it anywhere, but with the Vista operating system you may encounter problems if you install it in C:\Program Files.

  5. Click the Next button once again.

    The XAMPP Options window appears (see below). In most cases, it’s fine to leave all the window’s checkboxes just as you see; see the note below for details.
    If you plan on doing a lot of development, day in and day out, you might want to turn on the “Install Apache as service” and “Install MySQL as service” checkboxes. A service starts up every time you turn on your computer, so Apache, PHP, and MySQL are always running. However, if you won’t be building database sites frequently, or you don’t have a lot of RAM in your computer, don’t turn on these boxes (you’ll just have to manually start the servers when you wish to build dynamic pages, using the XAMPP control panel described on the next page).

  6. Click Install.

    The installer places all the files onto your system. This process takes a while, since a lot of programs and files are being installed.

  7. Finally, click the Finish button.

    A window appears “congratulating” you (way to double-click the installer program!), and asking whether you wish to start the XAMPP Control panel.

  8. Click Yes, to open the XAMPP Control Panel (see screenshot below).

    The XAMPP Control Panel lets you start and stop the Apache Web server and MySQL database server.
    In this figure, both Apache and MySQL are currently NOT running, as indicated by the word Start to the right of their names. Click the Start buttons to turn the servers on. You can open the Control Panel by clicking the XAMPP Control Panel shortcut on your desktop.

  9. If the buttons to the right of Apache and MySQL say Start, click them to start the Web server and the MySQL database server.

    You probably get a Windows security alert about both MySQL and Apache: Click the Unblock button in both cases. This action allows the two servers to run, and tells the Windows firewall protection service that everything is OK.If Apache and MySQL are already running, these buttons say Stop. (Clicking them turns off the Web server and MySQL.) Whenever you start Apache, PHP automatically starts as well. At this point, you should have a complete testing server running on your machine. You just need to make sure it’s working.

  10. To do so, launch a Web browser, and, in the Location bar, type http://localhost/.

    You encounter a page that lists a bunch of languages; click the language you prefer, and you’re taken to a kind of Web-based control panel for XAMPP (see screenshot below).
    Once installed, you can view your XAMPP home page from http://localhost/xampp/. From the left-hand list of links, you can access helpful programs and information, such as phpMyAdmin (for working with the MySQL database) and phpinfo() for finding out more about the server setup.
Once you’ve installed XAMPP, you’ll see a shortcut called XAMPP Control Panel on your desktop. Double-click this icon to control the servers you’ve just installed—you can turn the servers off and on, as well as turn them into services (which launch each time you start up your computer).
The next lesson is about how to Write and Run PHP programs 

1 comment: