Simple WAMP Server

This guide will walk through installing Apache 2.4, PHP 7.4, and MySQL 8 onto a regular Windows workstation WITHOUT using any installers, with cURL and MySQLi enabled for PHP.

ASSUMPTIONS

This guide assumes you are on a 64-bit version of Windows. Folder names do not really matter as long as you are consistent with them, but for the purposes of the guide, we’ll put all of our components (PHP, Apache, etc) into a folder called C:\WAMP.

PHP

  1. First, create the C:\WAMP folder for all your WAMP stack components.

  2. Next, create C:\WAMP\DocumentRoot, which will be the folder containing all your content.

  3. Next, download the latest 64-bit Windows build of PHP. Go to:

    https://windows.php.net/download

    You are looking for the latest build that is both “Thread Safe” and “x64” (for 64-bit). Within that section, click on the Zip link to start the download. And while you’re waiting, you might have noticed that even though you selected the x64 option, the filename contains the phrase “Win32” – don’t worry about that.

  4. Unzip the file into a subfolder in your WAMP stack folder. I personally like to name my folders using the PHP major and minor versions. At the time of writing this guide, the PHP version was 7.4.3, so I unzipped everything into C:\WAMP\php74 (so my php.exe file was C:\WAMP\php74\php.exe).
  5. Inside C:\WAMP\php74, copy the php.ini-development to php.ini.

  6. Edit php.ini with your favorite text editor and make the following changes:

    • Search for extension_dir = and you’ll find two versions of that line, both are commented out. Just add a new line in that general area:

      extension_dir = "/WAMP/php74/ext"
    • Search for extension=mysqli and remove the semicolon ; at the beginning.

    • A few lines up from there is extension=curl – uncomment that one, too.

      NOTE: You can optionally enable other modules in here, but just be warned that some of them require extra setup steps in order to work properly. The cURL extension does have an extra step, which we’ll do momentarily, but you’ll be able to check the Apache error log later on to see if there were any problems loading a particular extension.

      Don’t enable extensions that you don’t actually need or are not sure if you need. If it turns out you need something later on, just come back into this file, enable the extension, save, and restart Apache.
    • Save the file and close.
  7. For the cURL extension to work, we’ll need to add our PHP folder to the system path. This lets PHP find some of the files that cURL needs when it starts up. To do this:
    • Run the following command to open up the System Properties:
      sysdm.cpl SystemProperties
    • Go to the Advanced tab.
    • Click on Environment Variables…
    • In the popup window, you’ll see two lists, one for the current user and one for the system. We want to change the system’s path, so in the bottom list, find the “Path” entry and double-click on it.
    • In the next pop-up, double-click on an empty line at the bottom and type in:
      C:\WAMP\php74
    • Click on OK to close the popup, and then OK on the Environment Variables popup, too.
    • Click on OK on the System Properties popup to close it out.

APACHE

Next, we’ll install the Apache web server. Now, while you CAN get a Windows build straight from Apache, PHP (and me, too) recommends using the Apache builds provided by the people over at the Apache Lounge. Those builds are tested and come with some pretty commonly-used modules, which saves you a ton of time (unless you like compiling things from scratch):
https://apachelounge.com/download/

You are looking for the latest Win64 zip file, which is usually the first big download link on the page. At the time of this guide, that was “Apache 2.4.41 Win64”. So download that zip file and open it. Inside should be an “Apache24” subfolder, so extract that subfolder into your C:\WAMP (or whatever you called it) folder.

  1. Open up C:\WAMP\Apache24\httpd.conf with Notepad or your favorite text editor.
    • Change ServerRoot to “/WAMP/Apache24” (include the quote marks). In some recent builds of Apache, the config defines this path in a constant called SRVROOT (defaults to “c:/Apache24”), so just change it there.
    • Search for DocumentRoot, and you should see two lines next to each other:
      DocumentRoot "${SRVROOT}/htdocs"
      <Directory "${SRVROOT}/htdocs">

    • Change “${SRVROOT}/htdocs” to “/WAMP/DocumentRoot” on both lines.
    • There is a bunch of “LoadModule” lines in the config file near the top. Find that section, then add these lines below that section (make sure there are no trailing slashes in the PHPIniDir value):
      LoadModule php7_module "/WAMP/php74/php7apache2_4.dll"
      AddType application/x-httpd-php .php
      PHPIniDir "/WAMP/php74"
      LoadFile "/WAMP/php74/libssh2.dll"

    • Save the httpd.conf file.
  1. In the Windows 10 search bar, type in “cmd” and you should see “Command Prompt” pop up. Right-click on it and choose “Run as administrator” and accept the permissions/security prompt.

  2. Next, we’ll run a test of the configuration to make sure all the above changes work okay. So in the command prompt, type this and hit Enter:
    C:\WAMP\Apache24\bin\httpd.exe -t 

    If it comes back with “Syntax OK”, then go to the next step. Otherwise, try to fix whatever errors it tells you about. If you’ve followed the guide to the letter so far, then chances are it’s just a typo in one of the configuration changes from step 6.

  3. Once you get a “Syntax OK” result, we’ll install Apache as a Windows Service so it runs when the computer starts up. So hit the up arrow key, which should show you the same command again. However, this time remove the “-t” at the end and replace it with “-k install”:

    C:\WAMP\Apache24\bin\httpd.exe -k install

  4. You should see about 4 lines show up. The second line should tell you that “The ‘Apache2.4’ service is successfully installed.”

  5. Once you see that, we just need to manually start the service for the first time, which is the same command except “-k start” at the end:

    C:\WAMP\Apache24\bin\httpd.exe -k start

    There should not be any output. It should just take a second and then return you to the command prompt if successful.

  6. Now to test out the integration, open up your favorite text editor and create a new file C:\WAMP\DocumentRoot\phpinfo.php, with nothing but the following line:

    <?php phpinfo();

  7. Open up your favorite web browser and go to http://localhost

  8. You should see a mostly-blank page listing the contents of your DocumentRoot folder, with your new phpinfo.php file. Go ahead and click on that link, which should take you to http://localhost/phpinfo.php, which should show you a diagnostic page for PHP, indicating that PHP is correctly installed and talking to Apache.

MySQL

  1. First we’re going to download the MySQL Community Server. Go to https://dev.mysql.com/downloads/mysql/
    …but DO NOT download the recommended installer.
  2. Instead, there’s a smaller “Other Downloads” section with two ZIP archives – a regular one and one with Debug Binaries – you want the regular one (it should be around 190 MB – 200 MB). Click on the Download button to the right of that, and on the next screen, you can skip the sign-up and just click the “No thanks, take me to the downloads” link.
  3. Once the ZIP finishes downloading, unzip the contents into your C:\WAMP folder, which should result in a folder like C:\WAMP\mysql-8.0.23-winx64. We’ll refer to this as our “base folder”.
  4. Go into that base folder and you should see a bunch of subfolders like bin and include and stuff. Create a new subfolder here called data.
  5. In that same base folder, use a text editor to create a new file called my.ini with the following contents:
    [client]
    port = 3306
    socket = "/WAMP/mysql-8.0.23-winx64/mysql.sock"
    [mysqld]
    port = 3306
    basedir = "/WAMP/mysql-8.0.23-winx64/"
    datadir = "/WAMP/mysql-8.0.23-winx64/data/"
    socket = "/WAMP/mysql-8.0.23-winx64/mysql.sock"
    log_error = "/WAMP/mysql-8.0.23-winx64/data/mysql_error.log"
  6. Next, open up a command prompt as an administrator and run these commands:
    • cd c:\WAMP\mysql-8.0.23-winx64
    • bin\mysqld --initialize-insecure --console

      This will take about 30 seconds or so, and will initialize your data directory and set up root without a password (which we will remedy as our first step).
    • bin\mysqld --install

      This will install MySQL as a Windows service so it starts up when Windows starts.
    • net start mysql

      This will start the MySQL service for the first time. You may get a popup from your firewall (e.g. Windows Defender) to ask you about allowing the software to run, so check the boxes (or whatever steps are appropriate for your firewall) and allow that access.
    • bin\mysql -uroot

      This will start up the MySQL client shell, so you’re now connected to the database and can issue queries. The only critical thing we need to do here is set the root password. So at the mysql> prompt, run this query (and the exit command):
      • ALTER USER 'root'@'localhost' IDENTIFIED BY 'your-root-password-here';

        OPTIONAL: If you want, you can take this opportunity to add more user accounts, create specific databases for your application, etc… or you can do it later on if you want. The free MySQL client program HeidiSQL has a great management tool for doing all of that.
      • exit
    • exit

And you’re done! You should now have a very basic WAMP stack installed. It does not have any ties into the Windows system except for the services entries that will start up Apache and MySQL when Windows boots up.

From here, you can write PHP scripts, put them into C:\WAMP\DocumentRoot, and access them from your browser!

Leave a Reply

Your email address will not be published. Required fields are marked *