Install Apache Windows

- [Narrator] To install Apache MySQL in PHP on Windows,you can choose from a number of differentAM Stack bundles, but for the most customizableenvironment, you might want to install individualcomponents that come directly from the software vendors.I'll start this chapter by showing you howto 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 Loungewebsite at apachelounge.com.

I suggest you read the official PHP documentation about installing it on Windows systems. Download the latest PHP binaries from the official PHP for Windows download page, choose the thread-safe version that matches your Apache installation's bit-version (x86 for 32-Bit, x64 for 64-Bit). To install Apache Ant on Windows, you just need to download the Ant’s zip file, and Unzip it, and configure the ANTHOME Windows environment variables. Tools Used: JDK 1.7; Apache Ant 1.9.4; Windows 8.1; 1. Make sure JDK is installed, and JAVAHOME is configured as Windows environment variable.

Install Apache Windows

Even though the Apache Foundation manages theHTTP server, it doesn't provide a fully compiledinstaller for Windows, so insteadI recommend this distribution.The steps I'm going to demonstrate work forWindows 7 SP-1 and later.If you're running an older version of Windows,check the instructions on the Apache Lounge websiteto make sure you're getting the right versionsof all of the required software packages.Before you install Apache, you'll need to makesure you have the VC-14 redistributableinstalled from Microsoft, which is associatedwith Visual Studio 15.

To find out whether you already have that installed,go to your control panel and selectUninstall a program.Click the name column to put everything inalphabetical order, then scroll down to theMicrosoft section, and look for Visual C++2015 Redistributable version 14.You only need the version for your particularcopy 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 shouldtake you to the link, and from here you candownload 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 choosethe version of Apache for your copy of Windows.Either Win64 or Win32.I've already downloaded the .zip file forWin64 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 thisdirectory named Apache24.To extract this, I'm just going to drag it outto my desktop; you could instead right clickand 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 changesto match the name of the directory I just created.Under the Apache directory, I'll go to theconf subdirectory, and I'll look for this filenamed httpd.conf, that file extensionmight be hidden on Windows by default,but you can open up the properties windowby pressing Alt + Enter and see whatthe file extension is right here.

Open the file extension in a text editor.I'm using TextPad, but you can use anytext editor you like.Now, I want to search for all references to Apache 24.There are a number of places in this configurationfile 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 throughoutthe 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 actualDNS name, which is localhost, the reserved namefor 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.

Install Apache Windows Php

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 communicationwith 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 backthe response, 'It works!' And that's becauseof the HTML file that's in the documents folderunderneath 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 defaultweb 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.htmlfile that I just saw in the browser,and I'll open it with TextPad and showthat it's exactly the same text.

When you're done with your Apache session,go back to your command prompt and pressCTRL + C, and that will interruptthe application and shut it down.Alternatively, you can just close the command window,and then, when you come back to the browser andtry to refresh, you should see that the sitecan't be reached, because the server has beenshut down, and is no longer receiving requests.To fire up the server again, go to a new command promptand start up the httpd application and you'll beready to work again with the Apache server.

You can install Apache on Windows 10 very easily it is not a Sisyphean task anymore, you don’t need to need to go through multiple documentations to understand how to configure and up it to work with. As we know the Apache HTTP web server is part of Linux and work generally in LAMP (Linux, Apache, MySQL, PHP) environment to support any web application. Thus, on Windows Desktop or server, definitely, you are not looking for solely Apache installation, perhaps whole LAMP stack. Hence, it could be a very tedious job to install each part of LAMP on a system which is primarily not meant for it. Other options that left are XAMPP or WAMPServer, however, they are not meant to work for any production environment and also some times not so much performative. In such situation, WSL (Windows subsystem for Linux) is a boon on Microsoft Windows 10 and Windows 2016 servers.

You can use some Linux server such as Ubuntu 18.04 or Centos 7 on Windows subsystem for Linux to install Apache along with Mysql and PHP to get the same degree of performance as you except on some native Linux server or Desktop.

Moreover, with the announcement of WSL 2 (Windows subsystem Linux second version) in which Microsoft has integrated full-fledged Linux kernel for WSL makes it better than before. Let’s see how to do this…

Install Apache HTTP web server on Windows 10 -WSL

Step 1: Enable WSL on Windows 10 or 2016 server

If you haven’t enabled the WSL yet, then simply search for “Turn Windows feature on or off” in the Windows search box and open it. From where select Windows subsystem for Linux to enable it. For more info on it, see our article: Enable WSL on Windows 10 or server.

Step 2: Download Ubuntu or Centos for WSL

To install Apache on Windows WSL we have to first enable the Windows subsystem for Linux which we already did in the first step of this article. Now, its time to install some Linux distro over it. If you want to use Ubuntu 18.04 then simply open the Microsoft Store and search for Ubuntu. When it appears, install it.

Currently, Centos 7 is not available on Windows store and to install it we have to download it manually. Here you can see how to do that: Centos 7 Linux on Windows Subsystem for Linux.

Step 3: Launch Linux OS on Windows WSL

After installing search and open Ubuntu, it will take some time to get ready. Once it is, a Command terminal window will appear and then move to the next step.

How To Install Apache

Install

Note: The WSL doesn’t support graphical user interface by default, however, it is good to easily access and install Linux apps over it.

Step 4: Install Apache on Windows 10 subsystem for Linux

Now from here, everything is same as installing Apache web server on some Linux operating system. Type the below-given command in Windows 10 WSL command Terminal.

For Ubuntu

For Centos

Step 5: Enable Apache service on Windows

Once the Web server of our based on Apache installed on Windows 10 WSL, its time to enable its services other it won’t work at all. For starting the HTTP Services use below command:

Ubuntu WSL:

Apache Download For Windows 10

Centos WSL:

Step 5: Test Windows Apache web server is running or not

Install Apache Windows 10

The install of Apache HTTP web server on Windows 10 or 2016 servers is finally completed, its time to check whether it is working or not. For that simply open your system’s browser and type http://127.0.0.1:80.

Install Apache Windows 7

In this way, you can install Mysql and PHP + PHPMyAdmin too for testing other Linux web applications on Windows using LAMP stack.