|
|
Later Today: ASP.NET Tutorial 2: Introduction to C#
PHP Tutorial 0: Getting ready for PHP development
by Matt on 2009/10/19 at 4:20 pm
Prerequisites: Windows Vista, Windows 7, or Windows Server 2008 Operating System
This in-depth article contains detailed instructions for setting up your Windows Vista, Windows 7, or Windows Server 2008 computer for full-on, balls-out PHP web development – including installation and configuration of IIS, PHP, MySQL, SQLyog, and NetBeans.
Because of this article’s length, it has been divided into several unique sections, by topic. To get started, click on a section header (ie: “Step 1: Microsoft Web Platform Installer”) to expand it and view it’s contents.
> A Note for Windows XP/Server 2003 Users
If you are using an older copy of Windows, please read this section first.
Visually, IIS6, the version of IIS bundled with older Windows releases (such as Windows XP or Windows Server 2003) bears almost no resemblance to IIS7, which is included exclusively with newer versions of Windows (Windows Vista, Windows 7, or Windows Server 2008). Many features common to PHP under other common PHP server systems (such as Apache) are not compatible with IIS6 (such as URL Rewriting and gzip). Because IIS is a Windows feature, as opposed to an individual piece of software, you are stuck with the version of IIS included in your copy of Windows. For reference, below is a screenshot of each version of IIS:
 IIS6 (Windows XP/Server 2003) |
 IIS7 (Windows Vista/7/Server 2008) |
The issue is this: Any reference to IIS on this site is a reference to IIS7 (the version on Windows Vista, Windows 7, and Windows Server 2008). If you are learning on Windows XP, any IIS examples I give won’t directly apply to your version of IIS (IIS6). It doesn’t mean you won’t be able to follow along, it just means you’ll be on your own for working out how to do things on IIS (and you will also have to work around some reduced functionality). Alternatively, you could always download WAMP or Apache Server and do things the old-fashioned way, but those are not methods I’m going to discuss on this site. It’s too much work and, as far as I’m concerned, Windows XP is ancient history. If ever there was a time to upgrade your OS, it would be now.
> Overview
For folks who just want the cliff’s notes, here’s what we’re going to cover in this tutorial…
- Download Microsoft Web Platform Installer and use it to install the following:
- IIS (installed automatically by WPI, if needed)
- Common Web Server features
- ISAPI Filters
- URL Rewrite module
- PHP Runtime (whatever the latest version is)
- Download, install, and configure MySQL Community Server
- Download, install, and configure SQLyog Community Edition
- Download, install, and configure NetBeans (PHP-only version)
> Step 1: Microsoft Web Platform Installer
Using the Microsoft Web Platform Installer to install and configure IIS and PHP automatically.
IIS (Internet Information Services) is the server software that comes built right into every copy of Windows. Historically, it was really only used for running ASP or ASP.NET web servers not PHP. Sure you could get PHP running on IIS with a little work, but getting it working well was a configuration nightmare. Your only other option would be to download Apache server or WAMP and run an entirely separate server process (Which is a lot less than ideal if you want to run ASP.NET and PHP sites on the same machine which I do constantly). Thankfully, those days are over. That means we can now run PHP, ASP.NET, or regular-old-HTML websites all through the same piece of software. Believe me, it makes things a lot less complicated. Better yet, there’s pretty much no configuration required in order to get the server running. This is all made possible by a cool, free little Microsoft program called Web Platform Installer (or WPI for short).
Downloading Web Platform Installer
WPI automates a lot of the annoying tasks usually associated with setting up a new web server like installing IIS (if needed) or installing and configuring PHP, depending on what options you select.
To get started, visit Microsoft’s Web Platform site at www.microsoft.com/web/ and download the latest version of WPI (which is 2.0 as of this writing).
Configuring Web Platform Installer
When you launch the WPI file (wpilauncher.exe unless you renamed it) you will see three sets of tabs on the left, titled “What’s New?“, “Web Platform“, and “Web Applications“. Everything we need is under the “Web Platform” tab, so click that now. You should then be looking at the following screen:
 Web Platform Installer - Web Platform
Don’t worry if your WPI screen doesn’t have the same features checked as my screenshot. We’re going to set yours up right now.
With the “Web Platform” tab selected, you should see a bunch of category boxes, with a “Web Server” option at the very top. First, click on the “Web Server” box so that you see a green check next to the text. This means you have automatically selected all the basic features in that category… but chances are we’ll want to add a couple more things to that. Find the Customize link underneath the description for “Web Server” and click on it. Now you should see the following screen (again, don’t panic if yours doesn’t look exactly like mine, just follow the instructions below):
 Web Platform Installer - Web Platform (Customize)
This page shows all the individual Web Server features available, lumped together into logical groups. Scroll down the list and make sure that all of the following options are checked (checking any that you need to, if they aren’t already):
- Under the “Application Development” group:
- Under the “Common HTTP Features” group:
- Static Content
- Default Document
- Directory Browsing
- HTTP Errors
- URL Rewrite (IIS7+ only)
When you’re done selecting your Web Platform features, click the Back to Web Platform link in the upper-left.
Now, from Web Platform page, find the “Frameworks and Runtimes” box a little further down and click on the Customize link there. On this screen, the only option you need to check is the one for PHP (whatever the latest version is). As of this writing the page should look similar to this (you can ignore the .NET Framework stuff right now as it’s not necessary for working in PHP):
 Web Platform Installer - Frameworks & Runtimes (Customize)
And that’s it. Simply click the “Install” button in the lower right of the WPI window and the installer will take care of the rest.
> Step 2: Download and Install MySQL
This section details the installation and configuration of a local MySQL database for use in PHP development.
MySQL is the de-facto database standard for PHP. Because, like PHP, MySQL is freely available, platform-independent (as opposed to Microsoft SQL Server, which is Windows-only), and used almost exclusively whenever a PHP application needs a database. Since WPI does not support MySQL at the time of this writing, it is necessary to download and configure it ourselves. Fortunately, this is a fairly straightforward process.
Downloading MySQL Community Server
Someday MySQL may find its way into WPI, but in the mean time we have to install it the old fashioned way. To get started, download the latest non-Beta version of MySQL Community Server from http://dev.mysql.com/downloads/.
Tip: Although the MySQL download link will take you to a login page, there is a “No thanks, just take me to the downloads” option at the bottom so no registration or login is actually required.
Installing MySQL Community Server
When you launch the MySQL installer, be sure to run it with the “Typical” option selected.
 MySQL Installer - Setup Type
When the install completes, you’ll be presented with the “Wizard Completed” window (pictured below). Before you continue, make sure that the option for “Configure the MySQL Server now” is checked (whether you register or not is up to you, but it’s not necessary for this tutorial).
 MySQL Installer - Completed
Configuring MySQL Community Server
After you click “Finish”, you’ll be presented with the MySQL Server Instance Configuration Wizard (yes, that is quite a mouthful). Just click Next and you’ll be presented with two Configuration options Detailed Configuration and Standard Configuration.
 MySQL Instance Configuration Wizard
Select the Standard Configuration option and click Next. On the following screen, ensure both the Install As Windows Service option is selected, then click Next.
 MySQL Instance Configuration Wizard - Install as Windows Service
The next screen is by far the most important. This is where you will set the password for your local “root” account. Leave the first field “Current root password:” blank and enter whatever password you want to use in the “New root password” field, then type your chosen password again in the “Confirm” field (don’t you dare forget the password as you will need this to access your MySQL installation write it down or something if you have to). Unless you are configuring a dedicated web server and you want unrestricted database access from a remote computer, leave “Enable root access from remote machines” unchecked. Click Next.
 MySQL Instance Configuration Wizard - Modify Security Settings
The final screen does not require any configuration. It merely contains a list of tasks that the Configuration Wizard is going to perform. Go ahead and click “Execute“. If all goes well, you should now be starting at the following screen:
 MySQL Instance Configuration Wizard - Finished
Click Finish and that’s it. Congratulations, MySQL is now installed.
> Step 3: Download and Install SQLyog
This section details installation and configuration of SQLyog, a free program used to manage and administer your MySQL databases.
Unfortunately, MySQL does not come with any kind of graphical user interface it’s entirely command line-driven. For beginners, that’s just too much. Many web hosting services use a web-based database management system called PHPMyAdmin which is (not surprisingly) a free, open-source MySQL database administration program written in PHP. I’ve never been a fan of PHPMyAdmin. It’s clunky, ornery (especially when it’s on a shared hosting service), and not nearly productive as proper SQL management software ought to be (I’ve been spoiled by Microsoft SQL Server Management Studio).
Because I like things that work well and because I’m all for anything that makes me more productive as a developer we are going to use a much, much, much cooler program called SQLyog Community Edition.
What makes SQLyog so cool is that, unlike it’s aging competition (PHPMyAdmin), it is a user-friendly, Windows-native program. You can use it with your local MySQL install, or you can use it to connect to a remote database (such as one on a web hosting server) and you’ll never have to look at PHPMyAdmin again. Also, SQLyog installs in a minute and the Community Edition, like everything else I’ve had you download so far, is free.
Download SQLyog Community Edition
To download SQLyog Community Edition, hop on over to its download page at Google Code (http://code.google.com/p/sqlyog/).
There is also an Enterprise version of SQLyog available at www.webyog.com for $79 (which adds code commenting, among other features). If you ever find that you are really serious about PHP/MySQL development, I highly highly recommend you buy the Enterprise version. For now, however, the Community Edition will do everything we want and then some.
Installing SQLyog Community Edition
The SQLyog install is pretty much automatic. Click through the whole thing until you get to the “Completed” screen.
Check the “Run SQLyog” box before clicking Finish.
 SQLyog Community Edition Installer
Configuring SQLyog Community Edition
The only real down side to the Community Edition is the nag screen that appears whenever you open or close the program. For something this unbelievably useful and free, it’s really not a big deal. Just click “Continue” to make it go away.
 SQLyog Nag Screen
The first time you launch SQLyog, you’ll need to tell it how to connect to your MySQL Server instance. To do this, start by clicking the New button in the upper-left of the “Connect to MySQL Host” window (see below). You will be asked for a meaningful name. I called mine “localhost” to remind me that I’m connecting to my own machine.
 SQLyog - Creating a New Connection
SQLyog will fill in a lot of the details for you. The only thing you should have to do at this point is type in your password (the one you created when we installed MySQL, remember?) and click “Connect”.
So long as you dont get an error, and see a window like the one below, youre finished configuring SQLyog!
 SQLyog - Management Screen
> Step 4: Download and Install NetBeans (PHP Edition)
This section covers installing NetBeans, a free IDE for writing and editing PHP.
If youve been following along from the beginning of this tutorial, then by this point your server should be pretty much all set up. There’s only one thing we’re missing an IDE (Integrated Development Environment) for actually writing our PHP.
As far as PHP editors go, you have plenty of options: Dreamweaver, Eclipse… hell, you could even use plain old Windows Notepad. If you have a preference already then by all means use the editor that you’re comfortable with. If you already have one that you love, then you skip this entire step – you’re basically done with this entire tutorial. If not, read on.
While I occasionally use Dreamweaver myself, it is not free software. The good news is that if you don’t already have Dreamweaver (or even if you do, but aren’t happy with Dreamweaver’s coding features) there’s a fantastic PHP IDE that you can use absolutely free… and it actually kicks Dreamweaver’s ass in some very important ways. The biggest advantage that NetBeans has over Dreamweaver is in the code hinting department. While both programs offer some PHP code hints when you press Ctrl+Space on the keyboard, NetBeans goes above and beyond Dreamweaver’s capabilities by actually displaying detailed documentation from the code comments. Even more useful is that NetBeans will examine an entire project and display such comments for any function or class in the project… including ones you wrote yourself.
I’ll post an “Introduction to NetBeans” tutorial in the very near future, but the point I am trying to make is that you can get the perfect PHP editor without having to spend a dime.
Note: You do not need NetBeans in order to follow along with the tutorials on this site – you can use whatever editor or IDE you prefer. I merely want to offer NetBeans as an excellent free alternative to those who want to learn PHP but don’t have money to spend on retail software – or for those who aren’t totally happy with the software they are currently using and want an alternative. Although I use both Dreamweaver and NetBeans, I do tend to use NetBeans more often than Dreamweaver.
Download and Install the Java SE Development Kit
NetBeans is built on Java and requires the Java SE Development Kit (JDK) to be installed before you can install NetBeans. You can find this a little ways down the page here: http://java.sun.com/javase/downloads/.
Tip: Do not download the JDK/NetBeans bundle listed at the top of the Java SE Downloads page. That particular bundle is geared towards Java development, not PHP. Only download the standalone Java SE Development Kit for now (it will be called “JDK 6 Update 16” or something like it). Afterward, we will download the PHP-specific version of NetBeans.
Simply install the Java SE Development Kit with all the default options (no need to change anything) before continuing.
Download and Install NetBeans for PHP
NetBeans can be easily found and downloaded from www.netbeans.org. Be aware, however, that there are several different versions of NetBeans tailored to different programming languages (like Java, Ruby, C/C++, etc). The version you want to download is the PHP-only version.
Installing NetBeans for PHP
The NetBeans install is fairly straightforward – just use all the default options and let it do the rest.
 NetBeans Installer (default options)
Note: If you see the following message when you try to run the installer, then you need to download and install the Java SE Development Kit. Click here for directions.
 NetBeans Installer - JDK Error
When the installer has finished you’ll have the option of registering and providing anonymous usage data… but those are both purely optional. Once you click “Finish”, that’s it… you’re all done!
 NetBeans Installer Completed (optional registration)
 NetBeans Startup Screen
If you followed all four of the above steps then your computer is now ready to be used for full-blown PHP/MySQL development. I’ll be posting overview tutorials for each of specific tools mentioned on this page (IIS, SQLyog, NetBeans) – but don’t wait for me. Go ahead and play around with them. I’ve always found that the best way to learn something is to just do it (even if you don’t exactly know what it is you’re doing).
So don’t wait up. I’m sure you’re smart enough to learn a bit on your own in the mean time
|
|
No Comments