Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Installing Apache, MySQL, and PHP with David Gassner describes how to install and configure Apache HTTP server, MySQL database server, and PHP, known as the AMP stack, on a local development computer. Chapters are devoted to multiple installation approaches: installing the components separately on both Windows and Mac (including coverage of Apache and PHP on Mac OS X 10.7 Lion and 10.8 Mountain Lion), installing the pre-packaged Apache and MySQL distributions in WampServer on Windows and MAMP on Mac, and installing the cross-platform XAMPP and Bitnami on both Mac and Windows. Exercise files are included with the course.
This course was updated on 07/06/2012.
Just as with older versions of the Mac operating system, version 10.7, or Lion, includes the Apache HTTP server. It's up to you to activate, or turn it on. I'll go to the Apple menu and choose System Preferences. You can also get here through the Dock. On this screen, go to the Internet & Wireless section and choose Sharing. Mac OS X refers to the Apache HTTP service as Web Sharing. Go to that category, and you'll see that it's turned off by default.
To turn it on, just check the check box; it's that simple. Now to test your Apache server, go to the second link on this screen. It will either show an IP address, as it does here, or your computer name. Click the link. If everything is working correctly you should see the page, "It works!" This is a very simple homepage that's provided with the Apache server. Now it might not work on your system, especially if it's showing the computer name instead of an IP address, but here is the URL that always works.
Go up to the address bar and change either the IP address or the computer name, whichever showed up, to this IP address, 127.0.0.1. Then press Return and now you should definitely see this page. The IP address that starts with 127 is a globally used IP address that refers to the local computer. It's used on Mac, Windows, Linux, and other operating systems. There's a name that goes with it.
Instead of 127.0.0.1, you can instead use localhost and that should work as well. Now let's take a look at where these files are stored on your Mac. Now let's return to the Sharing dialog. Lion has added a couple of useful buttons to this interface. There is a button above called Create Personal Website Folder-- I'll show you that in a moment--and this one Open Computer Website Folder. When you click the button it takes you to your document root folder on your Mac hard disk.
You'll find that it has this file, index.html, and some graphic files that might or might not be showing up on your screen. There's also this folder, postgresql. This is new to Lion. It contains documentation for the PostgreSQL database, and it's not relevant to what we're doing here, so I won't talk about it anymore. I'm going to show you exactly where this folder is located on the disk. I'll make sure that I've deselected all the files and folders in this screen. Then I'll go to the Finder menu and choose View > Show Path Bar.
Down at the bottom of the screen, that will show that this folder is under Library > WebServer > Documents. If you're using the Apache HTTP server, this is where you put your HTML, graphics, PHP files, and other files that you want to be able to browse from the browser. We call it the document root folder. On Mac OS X there is also a concept of a personal document root folder. Each user can have a folder named Sites, with an uppercase S, which is also accessible from a browser.
I'll go back to my Sharing dialog and show you that there's a link here with the original URL and the syntax ampersand and then username. My username is simply lyndadotcom, so this would refer to the Sites folder under my home directory. I'll click the link and you'll see that there's a message saying I don't have permission to access that folder, and here's why. On Lion that folder does not exist by default for new users. I'll go back to Finder and go to the menu and choose Go > Home, and I'll show you that there is no sites folder here.
There is the Desktop, the Documents, and so on, but that folder has not been created yet. So, going back to Sharing, this is where this button comes into play. I'll click Create Personal Website Folder and then Open Personal Website Folder, and I'll see that I have a file called index.html and a folder named images. And looking at the path bar at the bottom, I'll see that I can now do have a Sites folder in my lyndadotcom home folder.
I'll double-click lyndadotcom and show you that that's where the folder has been created. Going back to Sharing, I'll click that link again, and this time I see files that have been created for me. Now just like the computer's own web site, you can either use the URL that's generated here or you can use 127.0.0.1 or you can also use localhost. So if you're able to access both the computer's web site, which is in that Library > WebServer > Documents folder, and your personal web site, which is in the Sites folder, under your home directory, you have Apache completely set up and ready to use.
Find answers to the most frequently asked questions about Installing Apache, MySQL, and PHP.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.