Previous Article
Facebook Login with PHP and MySQL: A Secure 2026 Implementation
1 August 2018
WAMP bundles Apache, MySQL and PHP into a single Windows installer, giving you a local server without configuring three separate services. The installation is usually quick — and when it goes wrong, it goes wrong in the same two or three ways every time.
This is the single most common cause of a failed WAMP installation, and the installer's own warning about it is easy to miss.
Apache and PHP on Windows are compiled with Microsoft's C++ compiler and need the matching runtime libraries. Without them the tray icon stays red or orange forever, or you get an error about MSVCR110.dll being missing.
Install all the redistributables before running the WAMP installer — VC++ 2008, 2010, 2012, 2013 and 2015–2022, in both x86 and x64. The WampServer site links a bundled package that installs the lot. Do this first and most installation problems never occur.
C:\wamp64, not Program Files. Paths with spaces and Windows' permission model on Program Files both cause problems. Accept the default..exe — point it at your editor or just accept Notepad. It has no effect on how the server runs.| Colour | Meaning | Usual cause |
|---|---|---|
| Green | Apache and MySQL both running | — |
| Orange | One service running, the other not | Port conflict, or MySQL failed to start |
| Red | Neither running | Missing VC++ runtimes, or port 80 taken |
Once green, open http://localhost/ — you should see the WAMP homepage. phpMyAdmin lives at http://localhost/phpmyadmin.
Apache needs port 80 and something else usually has it. Find out what:
netstat -ano | findstr :80
Take the PID from the last column and look it up in Task Manager's Details tab. The usual culprits:
System, PID 4) — often SQL Server Reporting Services or the Print Spooler's web component.If you cannot free port 80, move Apache instead. Left-click the tray icon → Apache → httpd.conf, and change:
Listen 8080 ServerName localhost:8080
Your site is then at http://localhost:8080/. Restart all services afterwards.
For MySQL failing to start, check C:\wamp64\logs\mysql.log. The common cause is another MySQL already installed as a Windows service holding port 3306 — either stop that service or change WAMP's port in my.ini.
Everything served lives under C:\wamp64\www. Create a folder there:
C:\wamp64\www\myproject\index.php
<?php declare(strict_types=1); echo 'Welcome — PHP ' . PHP_VERSION . ' is running.';
Open http://localhost/myproject/. The URL path always mirrors the folder name under www — if you created myproject, the URL is /myproject/, not anything else.
WAMP also lists every folder in www under "Your Projects" on the localhost homepage, which saves typing.
A genuine advantage of WAMP over some alternatives: left-click the tray icon → PHP → Version, and pick from any installed version. Useful when one client's site needs PHP 7.4 and another needs 8.3. Add more versions from the WampServer add-ons page.
Open phpMyAdmin at http://localhost/phpmyadmin. The default credentials are username root with an empty password.
Run this in the SQL tab:
CREATE DATABASE shop_demo CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; USE shop_demo; CREATE TABLE products ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(150) NOT NULL, price DECIMAL(10,2) NOT NULL, description TEXT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB;
Two things worth doing from the start. Specify utf8mb4 explicitly — older MySQL defaults to latin1, which cannot store emoji or most non-Western scripts, and converting later is tedious. And use DECIMAL for money, never FLOAT, which cannot represent most decimal values exactly.
Keep credentials in one file:
<?php
// config.php
return [
'host' => 'localhost',
'db' => 'shop_demo',
'user' => 'root',
'pass' => '', // WAMP's default — see the security note below
];
<?php
// db.php
declare(strict_types=1);
$config = require __DIR__ . '/config.php';
try {
$pdo = new PDO(
"mysql:host={$config['host']};dbname={$config['db']};charset=utf8mb4",
$config['user'],
$config['pass'],
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false, // use real prepared statements
]
);
} catch (PDOException $e) {
// Log the detail; never print it to the browser in production.
error_log($e->getMessage());
exit('Database connection failed.');
}
Use PDO rather than the mysql_* functions you will find in older tutorials — those were removed in PHP 7 and do not exist any more.
Out of the box WAMP has root with no password and phpMyAdmin open to anyone who can reach it. That is fine on a laptop and dangerous anywhere else.
config.inc.php so phpMyAdmin can still connect.It still works, but there are now better options depending on what you are doing:
| Tool | Strength | Best for |
|---|---|---|
| WAMP | Easy PHP version switching | Classic PHP and WordPress work on Windows |
| XAMPP | Cross-platform, bundles Mercury and FileZilla | Teaching, matching a course |
| Laragon | Automatic virtual hosts, faster, portable | Most modern Windows PHP work |
| Docker | Environment matches production exactly | Teams, anything deployed to Linux |
| WSL2 | Real Linux under Windows | Closest match to a Linux server |
The honest recommendation: if you are learning PHP on Windows, WAMP or Laragon will get you going in ten minutes and that has real value. If you are building something that will deploy to a Linux server, Docker or WSL2 saves you the class of bug where code works locally and fails in production because Windows filesystems are case-insensitive and Linux ones are not.
| Symptom | Fix |
|---|---|
| Icon stays red | Install every VC++ redistributable, then reinstall |
| Icon stays orange | Port 80 or 3306 in use — check with netstat |
| "Forbidden" on localhost | Left-click tray → Put Online, or check Require local in httpd.conf |
| PHP code shows as text | File saved as .html, or Apache started before PHP loaded |
| phpMyAdmin "access denied" | Root password changed but config.inc.php not updated |
| Changes to php.ini ignored | Edit through the tray menu, not the file directly — WAMP keeps several copies |
That last one catches almost everyone. WAMP maintains a separate php.ini per PHP version, and editing the wrong one has no effect. Always go through the tray icon → PHP → php.ini.
Advertisement
Written by
Amit VermaFounder / Senior Software Engineer
Amit leads engineering at Being Idea. With 15+ years building scalable software products across global markets, he drives architecture decisions and engineering culture across every engagement.
More articles by AmitWe ship software that scales. Let's work together.