Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
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.
In versions of OS X prior to 10.8, Mountain Lion, Apple had a feature that let you easily create a personal website folder, a subfolder of your home folder named sites, and you could put your own website assets there and address it as its own distinct website. As I showed previously, the user interface for controlling Apache is gone in Mountain Lion, but you can do the same thing in Mountain Lion manually, by just following a few steps in Terminal and in a text editor.
The first step is to create the folder. I'll go to Finder and I'll start in the Desktop folder. Then I'll hold down the Command key and press the up arrow and that takes me to my home folder, and this is where I'll create a new sites folder. I'll right click in the folder and select New Folder and name it Sites, with an uppercase S. You can name this anything you want--it doesn't have to be sites-- but I'm going to show you how to imitate the behavior of previous versions of the operating system.
So the Sites folder has been created, and now we just need to add a little bit of content. I'm going to use TextWrangler to create a very simple HTML file. You can use any text editor that you prefer, such as Dreamweaver or Coda. I'll go to Spotlight and type in TextWrangler and open the application. I'll start by creating a pair of HTML tags, then a pair of body tags, and then within the body, a pair of h1s.
Within the h1 tags, I'll type in "This is my personal website." Then I'll save this file and I'll place it in that new Sites folder. Just as I did before, I'll go to my Home folder, which is named lyndadotcom on my computer. From there, I'll go down to the Sites folder and then I'll name the file index.html. So now I have a simple default web page. The next step is to add a configuration to Apache that tells Apache when the user types in a URL that ends with tilde and then my username, it means to open the files in this folder.
I'll close down TextWrangler and I'll now go to Terminal. In Terminal, I'll switch to the users folder underneath the Apache installation folder. I'll type cd /etcetera/apache2/users/. This users folder will contain one configuration file for each user who has a personal website. If this is a brand-new installation of Mountain Lion and you list out all the files with LS, you should see that there aren't any configuration files there.
If you upgraded Mountain Lion from an older version of OS X, you might see conf files for each user on the computer. Your job is to create a configuration file for your user profile. To do this, we'll use the editor that's included with OS X. It's named pico. Its user interface is a little clunky, but it knows how to create system and hidden files. Start by typing sudo for super-user do, then pico, then your username, and this should match the name of your home folder.
I'll type lyndadotcom. Then follow that with the file extension .conf. You're saying, create this file and open it in the pico editor. When you press Return, you might be prompted for your administrative password. If so, type it in and press Return, and that opens your new file in the editor. Now I'll type in some text. As you will follow along, typing in exactly as I'm doing here. It is case-sensitive. I'll start with the directory tag.
I start with the beginning tag token, a less then character, then the word Directory with an uppercase D. Next is the physical name of your Sites folder. That's the folder you just created. After a double quote, start with /Users, then after another slash the name of your home folder. Again, for me that will be lyndadotcom. Then after another slash, the name of the subfolder you created, and I created a subfolder called Sites, then close the tag.
On the next line, you'll start adding some keywords that tell Apache how this folder should be treated. Start with Options, then Indexes, and then MultiViews. On the next line type in AllowOverride All. It looks like this. On the following line type in Order, with an uppercase O, then in all lowercase allow,deny. That means that when evaluating permissions for this folder, Apache should give precedence to allow commands.
Then on the next line type in, Allow from all, and finally close the directory tag. I'll press Return one more time, and I'll review what I've typed. Make sure that you type this in exactly right. You can always come back and edit it again later by executing that same pico command in Terminal, but it's best if you get it right the first time. Once you have confirmed that you've type everything correctly, press Ctrl+X to exit pico, type in Y for Yes, and then Return to confirm the file name.
When you come back to the command line, type ls and once again list the files and you should see that the configuration file has been created. Now restart Apache. Type in sudo apachectl restart. You won't see any response, but that relaunches the Apache server, and it will read that configuration file and be ready to respond. Let's review all the steps that we followed. We created the Sites folder and we populated it with some content.
In Terminal, we added a configuration file for the current username and then restarted Apache. Now I'll test my personal folder. I'll go to my browser, and I'll type in the URL http://localhost and then the tilde character and my username. And when I press Return, I see my personal webpage is displayed with the content that I typed in. You can follow this process for any user on the computer, creating configuration files that create exactly the same personal website as was created more automatically on older versions of OS X.
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.