• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Copyright 2005, Sawyer McFarland Media, Inc. This material is supplied to readers of 
Dreamweaver 8: TheMissing Manual 
as a helpful supplement to that book. In addition, those interested in the book can try outthis Tutorial. Buy the book and you can access the last 4 PHP tutorials as well.
PHP Tutorial 1
Getting Started with Dynamic Web Sites
Setting Up Your Computer
To follow this tutorial, you’ll need to have PHP, MySQL and a Web server up and running on yourcomputer. This will be your “testing server,” where you can build and test your database-driven Web pagesThe most common approach is to run Apache (a Web server) along with PHP and MySQL, but it’s alsopossible, if you’re a Windows user, to use Microsoft’s Web server, IIS. Because this can be a complicatedprocedure you’ll find three possible installation scenarios below, ranging from the “Egads, I have troubleinstalling Microsoft Office, and you expect me to install a Web server AND a database server” type of computer user, to the “Back off buddy, I was installing computer systems when you were still in diapers”computer jock.
Scenario 1: When You’ve No Idea Where to Start
The easiest way to install all of the parts of the puzzle is to download an all-in-one solution—a simple clickto go, one stop shop for powerful Web server software. One choice is the XAMPP project from a groupcalled Apache Friends—www.apachefriends.org/en/xampp.html. XAMPP is essentially an Apache Webserver, PHP, MySQL database server, and a bunch of other stuff rolled up into a single package that youcan install on your computer. It’s not a “production” setup—meaning you wouldn’t want to use thissoftware for really hosting a Web site. It isn’t optimized for working with lots of visitors, and it has somepotential security holes that could be exploited if you put XAMPP out in the wild of the Internet.However, for a testing server that completely simulates a real world Web server, XAMPP is the perfectchoice. It lets you create databases, build dynamic Web pages, and view them right on your own computermaking it easier for you to build and test database-driven Web sites. The steps are slightly different forMac and Windows so they’ll be explained separately:
Windows
1.
 
Download the software at:www.apachefriends.org/en/xampp-windows.html#641 
Select the Installer option under the “Basic Package.” At the time of this writing, a direct link toversion 1.5 for Windows was:http://prdownloads.sourceforge.net/xampp/xampp-win32-1.5.0-pl1-installer.exe You may be taken to a page that gives you a bunch of different places to download from. Just clickone of the download buttons. Once downloaded, the installer works like most Windows installers.
2.
 
Double click the .exe file you downloaded.
 
Copyright 2005, Sawyer McFarland Media, Inc. This material is supplied to readers of 
Dreamweaver 8: TheMissing Manual 
as a helpful supplement to that book. In addition, those interested in the book can try outthis Tutorial. Buy the book and you can access the last 4 PHP tutorials as well.
A window opens asking you to select the language you’d like to use.
3.
 
Choose a language from the menu and click the OK button
A Setup Wizard window appears, ready to step you through the set up process.
4.
 
Click the Next button, then click the Install button.
The various files needed are loaded onto your computer.
5.
 
Click the finish button, then when a window appears saying “Install XAMPP servers as service”appears make a selection.
A service starts up ever time you turn on your computer. In other words, do you want the Web serverand database server to startup whenever you turn on your PC? If you plan on doing a lot of development, day-in and day-out, you might want to choose “Yes.” Otherwise you’ll find that you’restarting up the XAMPP control panel (see below) and turning on the servers
every
time you boot up.However, if you won’t be building database sites frequently, or you don’t have a lot of RAM in yourcomputer, you might want to choose “No.” This way you can manually turn on the servers (see “TheXAMPP Control Panel” below) when you need to work on a dynamic site.If you select “Yes” you will be taken through the same question for the Apache Web Server, theMySQL database server and the FileZilla FTP server. It’s best to click “No” for the FileZilla FTPserver. You won’t need it for this tutorial, and since this is just a testing server, you won’t need to havethe ability to FTP to the computer—after all, all your files are already on your computer.
6.
 
Finally, launch a Web browser and type
http://localhost/ 
in the location bar.
You’ll encounter a page that lists a bunch of languages; click the language you prefer and you’ll betaken to a kind of control panel for XAMPP on your computer (see Figure PHP Tutorial 1-1.)
Figure PHP Tutorial 1-1. Once installed, you can view your XAMPP page fromhttp://localhost/xampp/  
Once you’ve installed XAMPP, there will be a shortcut called XAMPP Control Panel on your desktop.Double-click this to control the servers—you can turn the servers off and on, as well as turn them intoservices which launch each time you start up your computer.To uninstall XAMPP, just go to C:\Program Files\ and delete the folder named XAMPP. That’s it!
 
Copyright 2005, Sawyer McFarland Media, Inc. This material is supplied to readers of 
Dreamweaver 8: TheMissing Manual 
as a helpful supplement to that book. In addition, those interested in the book can try outthis Tutorial. Buy the book and you can access the last 4 PHP tutorials as well.
For more information on XAMPP, included detailed installation and setup instructions visitwww.apachefriends.org/en/xampp-windows.html.
Mac
1.
 
Download the software at: www.apachefriends.org/en/xampp-macosx.html#849
Select the first installer option (at the time of this writing it’s listed as XAMPP MacOS X 0.5.)You may be taken to a page that gives you a bunch of different places to download from. Just clickone of the download buttons. Once downloaded you’ll have a “package” file on your computer—inother words a file ending in .pkg, like xampp—macosx-0.5.pkg.
2.
 
Double click the package file.
A window that says “Install XAMPP for MacOS X” appears.
3.
 
Click the Continue button, select your hard drive in the list that appears and click the Continue buttonagain.
Even if you have more than one hard drive attached to your computer, you still have to select the drivethat’s currently running your system—the installer will put all of the XAMPP files into your computersApplications folder.
4.
 
Click the upgrade button and when you’re prompted for you administrator password type it into the password field and click the OK button.
You must have administrative privileges on the computer in order to install XAMPP, or any Webserver or database server.The installer goes through the process of updating your computer, and after a few seconds completesthe installation.
5.
 
Click the Close button.
Although the software is now loaded on your computer, you still have to start it up. Unfortunately, theXAMPP project hasn’t supplied an easy way to do this yet, so you’ll need to open the Terminalprogram and type some UNIX instructions—don’t worry, it sounds way more scary than it is.
6.
 
Open the Terminal program (for example, by double-clicking its icon.)
The program is located in the Utilities folder in your computer’s Applications folder.
7.
 
Type
 sudo su
and hit return. Then, when prompted, type your administrator password.
This gives you “superuser” powers to start software on your computer that everyone can use. (It alsogives you the power to really mess things up, so make sure you type everything listed here verycarefully and then quite Terminal as soon as you’re done.)
8.
 
Type
 /Applications/xampp/xamppfiles/mampp start 
and hit return.
This starts up all the servers you’ve just installed. Next, you’ll turn off the FTP server, since you won’tneed it for this tutorial.
9.
 
Type
 /Applications/xampp/xamppfiles/mampp stopftp
and hit return.
This turns off the FTP server. And finally, you’ll turn on the latest verion of PHP, PHP 5.
10.
 
Type
 /Applications/xampp/xamppfiles/mampp php5
and hit return.
This turns off the FTP server. And finally, you’ll turn on the latest verion of PHP, PHP 5.
11.
 
Launch a Web browser like Safari and type
http://localhost/ 
in the location bar. When the splashscreen appears, click the language you want to use, and you’ll be directed to a page on your newlyinstalled Web server (see Figure PHP Tutorial 1-1.)
To stop the Web Server and MySQL server at any time just follow steps 6 and 7 above, and in the Terminalprogram type
 /Applications/xampp/xamppfiles/mampp stop
and hit return. Unfortunately, at this time,there’s no easy way to automatically start XAMPP whenever you turn on your Mac, so you’ll have to
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...