There are a number of different AMP stack bundles available for Windows installation. Installing individual components creates the most customizable and flexible environments. Learn how to download and install the Apache software for Windows in this video by extracting the Apache files to the local hard disk and then running the HTTPD application as a command line application.
- [Narrator] To install Apache MySQL in PHP on Windows, you can choose from a number of different AM Stack bundles, but for the most customizable environment, you might want to install individual components that come directly from the software vendors. I'll start this chapter by showing you how to download and install Apache for Windows. You won't go to the Apache Foundation for this software, instead, I'll use a bundle from the Apache Lounge website at apachelounge.com.
Even though the Apache Foundation manages the HTTP server, it doesn't provide a fully compiled installer for Windows, so instead I recommend this distribution. The steps I'm going to demonstrate work for Windows 7 SP-1 and later. If you're running an older version of Windows, check the instructions on the Apache Lounge website to make sure you're getting the right versions of all of the required software packages. Before you install Apache, you'll need to make sure you have the VC-14 redistributable installed from Microsoft, which is associated with Visual Studio 15.
To find out whether you already have that installed, go to your control panel and select Uninstall a program. Click the name column to put everything in alphabetical order, then scroll down to the Microsoft section, and look for Visual C++ 2015 Redistributable version 14. You only need the version for your particular copy of Windows, I'm working on 64-bit Windows, so I make sure that I have x64 available.
Now, if you don't find that, you can go to Google, and search for it by typing C++ Redistributable 2015, and that should take you to the link, and from here you can download and install the proper software package. Once you've installed that component, you're ready to install Apache. Go to the downloads page, and then choose the version of Apache for your copy of Windows. Either Win64 or Win32. I've already downloaded the .zip file for Win64 to my desktop, and I'll show it right here.
The contents of the .zip file include a readme file, another file that you don't need, and then this directory named Apache24. To extract this, I'm just going to drag it out to my desktop; you could instead right click and select extract all to here. Once the files have been extracted, rename that directory from Apache24 to simply Apache. I'm going to cut the folder to the clipboard, then I'll navigate to my C drive, and paste the directory into place.
So now the path is C:\Apache. Before I start up Apache for the first time, I have to make some configuration changes to match the name of the directory I just created. Under the Apache directory, I'll go to the conf subdirectory, and I'll look for this file named httpd.conf, that file extension might be hidden on Windows by default, but you can open up the properties window by pressing Alt + Enter and see what the file extension is right here.
Open the file extension in a text editor. I'm using TextPad, but you can use any text editor you like. Now, I want to search for all references to Apache 24. There are a number of places in this configuration file that have references to this location. So I'm going to do a search and replace. I'll look for Apache24, and replace it with just Apache. Notice I'm using a forward slash and not a back slash, and that's going to be true throughout the configuration files.
I'll click replace all, and then I'll close this file, and that change is now done. Next, I'm going to search for a value called ServerName. This value is set by default to www.example.com:80, and it's commented out with a hash character. I'll remove the comment character, and then I'm going to change this to the actual DNS name, which is localhost, the reserved name for my own personal computer.
I'll save my changes and exit the file. Now I'm ready to run the server. I'll go to a command prompt. First, I'll navigate to the Apache directory, and then from there to the bin subdirectory. This bin subdirectory contains a number of executables, all with the standard .exe file extension. I'm interested in the one that starts with httpd. That's the server application. To start up the server, I'll simply type httpd.
Notice that the command doesn't finish. That's expected. As long as the command is still running, your server will be alive. You might also see a firewall dialog pop up. If so, accept it to allow communication with the Apache server. Now to test the server, I'll go to a new browser window, and I'll type in localhost, and I should get back the response, "It works!" And that's because of the HTML file that's in the documents folder underneath the Apache directory.
I'll right click and look at the page source, and I'll see that this is a very simple bit of text. An HTML tag, a body, and an h1 tag and the text, "It works!" When running on Apache on Windows, your default web documents directory is named htdocs, and it's under the Apache install directory. So I'll go back to that directory, to htdocs, and here's the index.html file that I just saw in the browser, and I'll open it with TextPad and show that it's exactly the same text.
When you're done with your Apache session, go back to your command prompt and press CTRL + C, and that will interrupt the application and shut it down. Alternatively, you can just close the command window, and then, when you come back to the browser and try to refresh, you should see that the site can't be reached, because the server has been shut down, and is no longer receiving requests. To fire up the server again, go to a new command prompt and start up the httpd application and you'll be ready to work again with the Apache server.
- Installing Apache on Windows
- Working with PHP on Windows and macOS
- Installing MySQL on Windows and macOS
- Adding MySQL bin directory to the PATH
- Starting and stopping Apache on macOS
- Configuring personal site folders
- Installing Apache, PHP, and MySQL on Linux
- Installing and managing WampServer
- Defining WampServer directory aliases
- Installing MAMP on macOS
- Configuring Apache and MySQL server ports on MAMP
- Handling port conflicts on Windows and macOS
- Configuring the Apache web document root