Setting up a local development server with WAMP for Windows 10

There are multiple of ways to setup a development server on MS Windows:

Manually installing each application would become very tedious. You could use XAMPP or WAMP which will setup the same server environment without the hassle of doing everything manually. Both softwares are self-installed packages that will install a full AMP (Apache, MySQL and PHP) for you.

I tested both WAMP and XAMPP briefly, and settled on using WAMP as i found XAMPP had too many server applications that i did not need and seems a bit more buggy than WAMP. WAMP also comes with a UI to manage your vhost which can be a time saver (though it is a shame you cannot delete vhost from the UI). 

It would take too long to explain what WAMP and XAMPP is and the pros and cons. So here is a good article you can read up and i do recommend you read it if you are a beginner.

If you have decided to go with WAMP, read on. 

Before we begin, if you haven't installed Notepad++ I recommend you do. It's a really nice free editor. 

Installing WAMP

Download WAMP at https://www.wampserver.com/en/ (Note: the download link will take you to a page to ask you to fill in a form. If you want to skip filling out the form, just click on the link that says, 'you can download it directly'). As of writing this article, the version i downloaded was Wampserver 3.2.0 64 bit x64 (for Windows 10 64bit machine). Choose the installer package which matches your machine and operating system. If you are not sure if your machine is 64bit or 32bit, you check on your PC by going to control panel --> system and security --> system. 

Follow the install steps and choose the following settings:

When installation is completed, you will have a shortcut icon on your desktop WAMP Click this to run WAMP. You know WAMP is running because you will see another icon in your taskbar WAMP

  • Green icon means it is currently running
  • Red icon means it has stop running.

WAMP has two menus for config, settings and tools. Each menu can be accessed either by left-click button or right-click button on the icon in the taskbar.

WAMP - Left-click button menu display
Left-click button menu display

 

WAMP - Right-click button menu display
WAMP - Right-click button menu display

Now that WAMP is running, let see if it is working. Left-click on the WAMP icon and click on 'Localhost'. It should fire up your browser (Chrome which is the default browser we selected during the installation) and present you with this page:

WAMP localhost page

Remember, we have installed 2 database servers (mySQL and MariaDB). They are essentially the same so we only need one. I chose to go with MariaDB so we will disable mySQL. In the next section, we will change some WAMP configuration and settings to optimised our server development. 

WAMP configuration and settings to optimised our server development

I have chosen the following for my development:

  • Apache 2.4
  • MariaDB 10.3.23
  • PHP 7.4.9

Let's first disable both mySQL and Adminer since we wouldn't be using them. 

MySQL uses default port 3306 so before we disable MySQL, let's change the default port to be used by MariaDB. This is will make things easier since majority of cases many web applications tend to leave their DB config settings for port 3306. To change the port, Right-click Wampmanager icon -> Tools -> Invert default DBMS MySQL <-> MariaDB

right-click on WAMP icon in taskbar and select 'WAMP settings'. You will see there is a green check next to 'Allow MySQL'. To check, open your browser and go to http://localhost/

You will see a display text: MariaDB Version: 10.3.23 - Port defined for MariaDB: 3306 - default DBMS - Documentation MariaDB

Now we can disable MySQL. Right-click Wampmanager icon -> Wamp settings --> Allow MySQL (you will noticed a green check displayed next to 'Allow MySQL' to show that it is currently active, if you click on it, it will disable MySQL and no green check will be displayed).

(Optional) Next we want to disable Adminer. Right-click Wampmanager icon -> Wamp settings --> Show Adminer in menu (this doesn't remove Adminer but it remove it from showing up in wamp menu).

Setting up a root password for MariaDB root user

By default WAMP does not have root password. If you visit: http://localhost/phpmyadmin/ to access your phpmyadmin (DB management tool), you simply login with root user and no password is needed. I never liked leaving password empty even for development purposes so let us add a root password. You can achieve this in a few ways. The method i prefer is by using the console. 

On the wamp menu go to MySQL –> MySQL console.

WAMP - mysql console

Hit enter as there is no password. Enter the following commands (one at time):

SET PASSWORD for 'root'@'localhost' = password('root');
SET PASSWORD for 'root'@'127.0.0.1' = password('root');
SET PASSWORD for 'root'@'::1' = password('root');

That’s it, I use 'root' as the password just to simply thing. So root user is:

user: root
password: root

Important: only use 'root' as password if you are sure your local development web sever is only viewable on your own local machine. 

If you want to check the user’s table to see that the info has been updated just enter the additional commands as shown below. This is a good option to check that you have indeed entered the same password for all hosts. You can do this and entering each line:

use mysql
select user, host, password from user;

 

WAMP - change password

Since we added a password, now phpmyadmin will also require a password to login. So we need to add this to phpmyadmin config script. Open the config.inc.php file found in C:\wamp64\apps\phpmyadmin5.0.2\ and look for /* Server: localhost [2] */ (remember, we are using MariaDB. If you are using MySQL, look for /* Server: localhost [1] */) and around line 43. change it to

$cfg['Servers'][$i]['password'] = 'root';

Left-click on wampmanager icon --> Restart all services

Now try logging into phpymyadmin (http://localhost/phpmyadmin/) with both user and password as root.

user: root
password: root

Other methods of creating a root password can be found here: https://www.hsnyc.co/database/how-to-set-the-mysql-root-password-in-localhost-using-wamp/

Altering some server configurations to optimised your local development

WAMP out of the box is ready for running WordPress or Drupal so if you got this far, you should be able to start installing any or most PHP content managed systems.

As a general rule, your local development should match or be as close as possible to your production environment (ie, live server) to minimise any issues during debugging. If your live server has PHP 7.4, then you should not be running PHP 5.6 as default. Sames goes with database server and any server configurations. Always stick with the same versions.    

We alter server configurations on local development to test if you think the server settings are the issue to your site. But to have a more optimised server, I change these settings:

For PHP:

Left-click mampmanager icon -> PHP 7.4.9 --> PHP settings

Update these settings to match:

max_execution_time = 300
max_input_time = 300
max_input_vars = 10000
memory_limit = 2G
post_max_size = 32M

upload_max_filesize = 32M

NOTE: for memory_limit I set it to 2G (select custom and input your own value). This is because i will be running Composer and it requires at least 2 Gb of RAM. If you don't intend to use Composer, then 512M should be sufficient.  

For MariaDB

Left-click mampmanager icon -> MariaDB 10.3.23 --> MariaDB settings

Update these settings to match:

max_allowed_packet = 64M

From Drupal 7.50 and higher, now supports multi-byte UTF-8. If you need this, then follow this guide: https://www.drupal.org/node/2754539 

To add/change the settings for multi-byte UTF-8 (from above link) in wamp:

Left-click mampmanager icon -> MariaDB --> my.ini 

 

How to add vhost

This is quite an important part. What is the purpose of a virtual host (vhost). In basic terms, it allows the user to redirect directories and map them as the main docroot (ie, same as saying webroot) to serve as the domain. This allows many multiple domains on a single server.

In a local development, we have localhost which is by default the main domain on your machine (ie, this is also used as the loopback address on any computers). It would be fine if you ever only going to use and test a single web application, then you could just install it into your main webroot folder (and access it by http://localhost/). But eventually, one is never enough as you might want to setup multiple of the same web application for testing different scenarios. Or that your main site is actually installed into a sub directory on your local development (so you access it by something like http://localhost/my_site) but you want to match it like your production site which is serve from a main domain. We do this by redirecting/mapping any directory to be its own webroot using vhost.

Each time you start a new web project, it is always recommended to create a vhost. It just keeps things clean when you can have your complete installation site in its own directory.

WAMP webroot is /www (full path: C:/wamp64/www), the URL is http://localhost This directory also contains the files for your WAMP startpage. I personally don't like to mix my own development projects in the same directory in case i may accidentally delete some of these files used by WAMP. Luckily we have vhost to work with. So I create another directory to use as a replacement and named this /htdocs. This will now be the directory to contain all our development work.

To create this new /htdocs, navigate to C:/wamp64/ and create a new directory name htdocs This webroot can act as http://localhost2 since we do not have localhost to use.   

Creating a vhost on WAMP is actually quite a simple process 

Left-click on mampmanager icon -> Your VirtualHosts --> VirtualHost management

This will bring up a page at: http://localhost/add_vhost.php 

Let's create our first vhost called localhost2

In the field for 'Name of the Virtual Host No space - No underscore(_) Required', type:

localhost2

In the field for 'Complete absolute path of the VirtualHost folder Examples: C:/wamp/www/projet/ or E:/www/site1/ Required', type:

C:/wamp/htdocs

Click on the 'start creation of the virtualHost' button. Now we must restart DNS for it to take effect.

Right-click on mampmanager icon -> Tools -> Restart DNS

Visit: http://localhost2/

Go to C:/wamp/htdocs and create a simple HTML file and name it index.html You should be able to see this new webpage at http://localhost2/

We will use this as our new webroot where our development website project can reside in. 

You could use this new index.html file as a page to link to many of your projects or reminders and notes. Apart from that, this webroot will mostly be for creating other sub directories which contains an installation of a web application in each sub directory, then use vhost to make these sub directories act as their own webroot (like a single domain) to access. 

As an example, supposing you want to install and run drupal in it's own webroot (like a primary domain). You would first create a sub directory in C:/wamp64/htdocs, such as:

C:/wamp64/htdocs/drupal 

You then copy the full drupal installation into the directory /drupal 

If you ran the installation in subdirectory, you would have to use http://localhost2/drupal/ 

This can present some problems with relative paths when deployed to live site. So we create a vhost to make C:/wamp64/htdocs/drupal run in its own webroot. 

Below image shows an example of how to create vhost for our directory:

create vhost    

Click on the 'start creation of the virtualHost' button. Now we must restart DNS for it to take effect.

Right-click on mampmanager icon -> Tools -> Restart DNS

We can now view the site in a browser by using http://drupal/ 

Deleting a vhost

Sadly, there are no option to delete a vhost. This has to be done manually. Creating a vhost on wamp local development requires 2 files. 

Apache Virtual Hostsc:/wamp64/bin/apache/apache2.4.46/conf/extra/httpd-vhosts.conf

Windows hostsC:/WINDOWS/system32/drivers/etc/hosts

For example, when creating localhost2 we would add to the httpd-vhost.conf file:

<VirtualHost *:80>
	ServerName localhost2
	DocumentRoot "c:/wamp64/htdocs"
	<Directory  "c:/wamp64/htdocs/">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>

 

and in the windows host file:

127.0.0.1	localhost2
::1	localhost2

To delete localhost2, we would simply just remove those lines in both files. 

Now you know which files are used for creating a vhost, you can actually manually add them instead of going through the WAMP vhost management page to do this.

 

Installing PHP extensions (this is optional, you can skip this part if you want)

As I work with Drupal I like to be sure all the requirements are complete. Even though this is optional, it's quite nice to see no warnings in your Drupal status report page. These are PHP APCu Caching and uploadprogress. Unfortunately, they are not included in WAMP so we need to install them manually. 

Installing APCu PHP caching and enabling it

Go to https://pecl.php.net/package/APCu and select the latest version. Click on the DLL link DLL That is the compiled version for Windows operating system. On the next page, select the one for the PHP version you want to install it for. Also, download the 'Thread Safe (TS) x64' if you are using a 64bit machine, otherwise download 'Thread Safe (TS) x86' for 32bit machine. 

This is the version i downloaded: https://windows.php.net/downloads/pecl/releases/apcu/5.1.18/php_apcu-5.1.18-7.4-ts-vc15-x64.zip

Unzip the package and copy php_apcu.dll file to C:\wamp64\bin\php\php7.4.9\ext\

Now we need to add an entry to php.ini file to load the module. Left-click wampmanager icon -> PHP 7.4.9 -> php.ini

Find '; Dynamic Extensions ;' and below the last extension add:

extension=php_apcu.dll

Before it can take effect, we must restart server. Left-click on wampmanager icon -> Restart all services 

Visit http://localhost/?phpinfo=-1 and see if it is enabled. You should see this entry:

WAMP - APCu PHP

 

Installing uploadprogress PHP and enabling it

Go to http://pecl.php.net/package/uploadprogress and select the latest version. Click on the DLL link DLL That is the compiled version for Windows operating system. On the next page, select the one for the PHP version you want to install it for. Also, download the 'Thread Safe (TS) x64' if you are using a 64bit machine, otherwise download 'Thread Safe (TS) x86' for 32bit machine. 

This is the version i downloaded: https://windows.php.net/downloads/pecl/releases/uploadprogress/1.1.3/php_uploadprogress-1.1.3-7.4-ts-vc15-x64.zip

Unzip the package and copy php_uploadprogress.dll file to C:\wamp64\bin\php\php7.4.9\ext\

Now we need to add an entry to php.ini file to load the module. Left-click wampmanager icon -> PHP 7.4.9 -> php.ini

Find '; Dynamic Extensions ;' and below the last extension add:

extension=php_uploadprogress.dll

Before it can take effect, we must restart server. Left-click on wampmanager icon -> Restart all services 

Visit http://localhost/?phpinfo=-1 and see if it is enabled. You should see this entry:

WAMP - uploadprogress

Note: If you want to install both these PHP extensions for other PHP, it is the same procedure but you need to download the correct version for your PHP. For example, if you want to install it for PHP 7.1 as well, then download the PHP extension for PHP 7.1 and go through the same procedure. 

Read the next article if you want to install Composer and Git

 

The content of this field is kept private and will not be shown publicly.
Your email address will be kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.