How to setup Apache, PHP and MySQL on Windows 10

In this tutorial, you will learn about how you can setup Apache, PHP and MySQL server on Windows 10.

If you are planning to install Apache, MySQL and PHP on Windows 10, you have two options:

  1. you can download and install a free web development environment (WampServer, XAMPP)
  2. you can create your own environment by installing Apache, PHP and MySQL manually

For beginners I recommend the first option. For the second option you have to decide as to which version of each application will be installed. In this tutorial I am going to setup

  • Apache 2.4.46
  • PHP 7.4 (7.4.13RC1)
  • MySQL 5.7.31

Download the installation packages:

Apache: https://www.apachelounge.com/download/
PHP (download the Thread Safe version): https://windows.php.net/qa/
MySQL: https://downloads.mysql.com/archives/installer/

Apache 2.4 setup on Windows 10

  • Unzip the downloaded files to the C:\Apache24 directory if possible (this is the default ServerRoot directory in the Apache configuration file)
  • You can unzip to another location, but remember the path, you will have to change the SRVROOT variable in the http.conf file later
  • Install the Visual C++ Redistributable for Visual Studio 2015-2019 x64
  • After unzipping and installing the Visual C++ Redistributable package go to the C:\Apache24\conf directory and open httpd.conf in any text editor
  • If you unzipped the files to other location as C:\Apache24, change the path to your location in the line below:
Define SRVROOT "c:/Apache24"
  • Add a line right after #ServerName www.example.com:80 like this:
#ServerName www.example.com:80
ServerName localhost
  • You are ready to go. I recommend to change the following lines too:
  • Change AllowOverride None to AllowOverride All to enable .htaccess files in your projects:
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords: 
# AllowOverride FileInfo AuthConfig Limit 
# 
AllowOverride None
  • Check if you the mod_rewrite module is enabled. Find the line
#LoadModule rewrite_module modules/mod_rewrite.so

and remove the # from the beginning to enable the module:

LoadModule rewrite_module modules/mod_rewrite.so
  • To serve index.php file automatically if a directory is requested append index.php to the DirectoryIndex variable
<IfModule dir_module> 
DirectoryIndex index.html index.php 
</IfModule>

To test the installation, open up the command prompt, go to C:\Apache24\bin and run Apache by typing httpd.exe:

run apache from command prompt

If there is no error, open up a browser of your choice and go to http://localhost where you will see this page:

apache it works

To run Apache automatically on startup, register it as a service. Open the Command Prompt as administrator (right click -> Run as administrator) and type in these lines:

register apache as a service

Check Apache service in Services and click Start the service:

apache running

PHP 7.4 installation on Windows 10

  • Unzip the downloaded package to C:\php74
  • Go to the C:\php74 directory
  • Rename php.ini-development to php.ini
  • Add PHP 7.4 to system environment variable in Command Prompt:
C:>setx path "%PATH%, C:\php74" /M
  • Open the C:\Apache24\conf\httpd.conf apache configuration file again and add these lines to the end of the file:
PHPIniDir "C:/PHP74" 
AddHandler application/x-httpd-php .php 
LoadModule php7_module "C:/PHP74/php7apache2_4.dll"
  • Restart Apache 2.4 service in Services, or open the Command prompt and type
C:\>httpd -k restart
  • To test the installation, create a file named phpinfo.php in C:\Apache24\htdocs directory and copy these lines to the file:
<?php 
phpinfo();
  • Open a browser of your choice and open http://localhost/phpinfo.php
phpinfo

MySQL 5.7 installation on Windows 10

  • Download the installer
  • Run the installer
  • In the first step pick server-only and hit Next
mysql installation server only
  • Download and install Microsoft Visual C++ 2013 Redistributable Package if you don’t have it already
  • After installing Microsoft Visual C++ 2013 Redistributable Package click Next again
  • If you downloaded the smaller package, click Execute in the third step and wait while the download ends
  • Click Next, the next step is Product Configuration
  • In the Product Configuration window click Next and pick the Standalone MySQL Server option in the first step
  • Click Next
  • In the Type and Networking step you can leave everything as it is (Config Type: Development Computer, Port: 3306), click Next again
  • Set your MySQL Root Password and go to the next step
  • Leave everything as it is in the next two steps (Next, then execute)
  • The installation is done, click Finish
  • Open Services and verify that the service named MySQL57 is running
mysql service running
  • If you are not comfortable with the command line, you can download and install MySQL Workbench, or install phpmyAdmin to manage your databases through a graphical user interface

Do you have a project for us?

Contact us

Our Services

WEB DESIGN AND DEVELOPMENT

From raw idea to a scalable product
Each website we develop is truly unique, tailor-made for your brand, product or company.

Learn more »

WORDPRESS & WOOCOMMERCE

Custom online-store, theme and plugin development
GoWild Digital leverages the flexibility of the WordPress platform to develop websites that can be easily maintained and upgraded.

Learn more »

TECHNICAL SEO AUDIT

A health check of your website
Our Technical SEO audit identifies technical errors with your website that can be hindering your performance and visibility.

Order now »

WORDPRESS SPEED OPTIMIZATION

Enhance your site’s user experience and rankings
Website speed optimization service that can help your website load at top speeds and generate more conversions.

Order now »

AD-HOC SUPPORT AND MAINTENANCE

For a fixed price
Purchase a block of support minutes to complete any tasks needed. Minutes purchased never expire.

Order now »

WEBSITE MIGRATION

We can help you to migrate your website to your new web hosting
Let us take on the heavy lifting of your next website migration to reduce your stress and to migrate your site efficiently and effectively

Order now »

Update Gone Wrong

An update broke your WordPress site?
Let us help you! Our service provides you with the fix of one error to get your WordPress website back up and running.

Order now »

Repair Hacked Website

Site hacked?
We’ll restore your website fast to help limit the downside. If it gets reinfected in the next 30 days, we fix it for FREE again.

Order now »

Quick Website Repair

Broken WordPress or PHP based website?
Our service provides you with the fix of one error to get your website back up and running.

Order now »

Our Work

Green Guide Budapest

Green Guide Budapest

greenguide.hu
Web design: Mimma Nosek (Behance)
UI/UX mentor: Júlia Tóth (Behance, Dribble)

Trilla

Trilla

trillafesztival.hu

Web design: Anuri Design Studio (Website)

Barber Bay

Barber Bay

barberbay.hu

Web design: Endre Gömöri (LinkedIn)

MOST

MOST

mostmusic.eu

Web design: Anuri Design Studio (Website)

Hungarian World Music Guide

Hungarian World Music Guide

hungarianworldmusicguide.com

Web design: Anuri Design Studio (Website)

Have a question?