While I was trying to set this up, I came across multiple articles, but none worked correctly for me.
Details of Localserver: Windows 7 64 bit system
WAMP installed to c:\wamp
You need to make two major changes to get a subdomain localhost install of WordPress running correctly. These are changes to your hosts file and the Apache httpd.conf file
Location:
HOSTS FILE:
C:\Windows\System32\drivers\etc
Alternate generic location: %systemroot%\system32\drivers\etc\
Linux: /etc/hosts
HTTPD.CONF FILE:
httpd.conf: C:\wamp\bin\apache\apache2.4.2\conf
On Ubuntu the main Apache configuration file is actually apache2.conf
. Apache2.conf
contains the default configuration for Apache on Ubuntu. Apache2.conf
includeshttpd.conf
for “user configurations”. Here’s the lines from apache2.conf
that includehttpd.conf
:
# Include all the user configurations: Include /etc/apache2/httpd.conf[/code] So usehttpd.conf
to add extra Apache configuration, and modifyapache2.conf
if you need to change the existing Apache configuration.Ubuntu’s Httpd.conf Location
For the versions of Ubuntu we’ve checked so far, you can consistently findhttpd.conf
in the directory/etc/apache2
. I needed to get www.droidzone.in, supernova.droidzone.in working in localhost. So the example will be this. The hosts file needs the following changes:127.0.0.1 www.droidzone.in 127.0.0.1 supernova.droidzone.inNote that http://droidzone.in in real time points to www.droidzone.in by means of an A record. So what applies to www.droidzone.in applies to droidzone.in. The address has to be a.b.c and not just b.c. So adding www before droidzone.in is a must.
So now that the addresses are pointed to localhost represented by 127.0.0.1, we need to setup httpd.conf. Click on th WAMP icon in the tray>Apache>httpd.conf (See figure)
The file opens in Notepad in a window.
Next, at the end of this file, add the following:
<VirtualHost *:80> ServerName www.droidzone.in DocumentRoot "C:\wamp\www" DirectoryIndex index.php index.html index.html index.htm index.shtml </VirtualHost> <VirtualHost *:80> ServerName supernova.droidzone.in DocumentRoot "C:\wamp\www" DirectoryIndex index.php index.html index.html index.htm index.shtml </VirtualHost>Note that C:\wamp\www is the directory where I have put my WordPress installation. That is, the directories wp-admin and wp-content, along with the file wp-config.php are contained within this directory.
Once these files have been modified, you should restart Apache.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.