How to Install WordPress Locally using XAMPP
Few days back one of my friend asked me How to Install WordPress Locally using XAMPP. He was trying to setup a local website to try out some design and content before its pushed to production environment of third party hosting service. Though I guided him, I realized that I don’t have any active article running on my site that is too obvious, so I decided to put in all the information together in an article and publish it. Here we will see all the steps from downloading XAMPP to publishing our first post on brand new local website.
Step 1: Download XAMPP from the official site
First of all we will download XAMPP from the official site. We will choose the “Installer” format/option suggested and most preferred.
The download size is aroud 102MB so need to be patient till it completes. Once download is complete you will have an exe “xampp-win32-1.8.2-2-VC9-installer.exe” [Name may vary as per version you are downloading]. We need to execute it to start our installation of XAMPP.
Step 2: Installing XAMPP
Installation is super easy. You just need to locate the downloaded exe file and run it. Simply follow the easy instructions during installations like choosing language, directory etc. Below image will show you what options I have chosen for installation.
Installation may take 10-15 minutes depending up on hardware environment. Once its complete you will be asked to start the control panel. This panel will have listing of services running on your machine and you can choose what to start, PID, Ports etc. After installation is complete my control panel is like this
I have only Apache and MySQL servers running as I need only this as of now. You can test if XAMPP is running properly by visiting local url.
Step 3: Setting up MySQL for WordPress
Every WordPress site needs a MySQL database to run. We will setup one database and a user first using the PHPMYADMIN panel provided by XAMPP. To access this you just need to type in url http://localhost/phpmyadmin in your browser.
Once you are on this page click on “Databases” link, it will open you interface to create database. Here we will create a database named
“wp_local“. Refer below given screen for same
Once you click create, a database will be created and it will be listed in the database list. Next we will create a user for this database. For that you need to click on the database from left side database list. After that click on the “Privileges” tab. This page has a link to create user, click it. You will be presented with the interface as shown in below
Make sure you grant all the Global Privileges from this page as ours will be admin user to we would need all the rights we can get. Now we are all set from database side.
Step 4: Setting up Virtual Hosts in XAMPP
Before we go to WordPress installation we would like to decide on domain name on which we will be doing our WP installation. I am sure you dont want to do it on some default localhost url. We will setup a local domain name which will be either .com or .dev as we are doing this for development purpose. Its up to you what to choose. [You can even choose any random characters :)]
So for our illustration purpose we will take domain name that’s easy to type in “wplocal.com“. XAMPP provides us with a file “httpd-vhosts.conf” under installation directory “C:\xampp\apache\conf\extra” [this is installation path on my local environment, it may vary on what path you chosen while doing installation]. We need add v-host entry to this file. Virtual host entry is nothing but way of telling apache that from where you want to operate your site, what domain name etc. Now I have chosen a directory on my C: drive “C:\wplocal.com” to act as a document root for my website. Let me show you what code you need to add to conf file.
First of all stop the apache server from XAMPP control panel. Open above httpd-vhosts.conf file in any text editor of your choice. remove # from NameVirtualHost *:80 in the file. It should look like
1 |
NameVirtualHost *:80 |
Then, add following lines in the end of the file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<VirtualHost *:80> ServerAdmin webmaster@wplocal.com DocumentRoot "C:/wplocal.com" ServerName wplocal.com ServerAlias www.wplocal.com ErrorLog "logs/wplocal.com-error.log" CustomLog "logs/wplocal.com-access.log" common <Directory "C:/wplocal.com"> Options All AllowOverride All Order Allow,Deny Allow from all Require all granted </Directory> </VirtualHost> |
Now once its done, close the file and start apache server. Go to your machines “System32\drivers\etc” and open hosts file in text editor. Add following line to end of the file
1 |
127.0.0.1 wplocal.com www.wplocal.com |
You are done, go and try to access the site in your browser. You will be greeted with welcome page if you added one in the document root directory.
Step 5: Install WordPress Locally using XAMPP
So far we have completed the basic website setup. Now we need to go and grab a our WordPress installation copy and install it in our newly setup domain name. Always use official WordPress site to download the copy, you can download one form here. At the time of this article we have version 3.6.1 available so we will get it.
Copy “wordpress-3.6.1.zip” to “wplocal.com” directory and unzip it in the root directory itself. The structure will look like below
Once you extracted all the files to root directory, go to the browser and type in your domain url. WordPress setup will detect that there is no configuration done earlier and it will prompt you to do one. Click on this create configuration button, in next couple of screens, it will ask you details about our database, which we have already setup using PHPMYADMIN. Give in the database name, pwd etc
Submit the form after entering correct details about user and password. Next step will confirm the database details and will ask you to start installation. Once you passsed the database test, you will need to provide your website title, admin user password for wordpress control panel.
Go on and click on “Install WordPress” button. It will take couple of minutes for installation to complete. Once it is you will be presented with login screen to your wp-admin. Login using the user/password we set in above steps and you are ready to post your first article and share it with the world.
and here is your actual website
That’s it you have your website installed locally where you can try out any design, plugins etc. and once satisfied you can push those to your live/production environment. Hope this article will be useful to those who seek information.
Related Links:
Please let me know your feedback on how you find this article.
Hey Pavan,
I get this error “Please check if the file is opened in another program” while editing hosts file on “system31/drivers/etc”.
Please help me in solving this.
Thanks in advance 🙂
Hi Ankit
I hope you have sufficient privileges to edit the system files. Please check check and update files using admin account.
thanks
Hi Thank you very much for that post
but i have find one problem when i try to create wplocal.com
where i type wplocal.com on browser in shows index of then show wordpress folder and then i click on wordpress folder its run
please give me a solution for this
Hi Gourav
You must have installed your wordpress package in the wordpress directory. If you want to change only url here is great resource
http://codex.wordpress.org/Changing_The_Site_URL
hi these process of code is beneficial…
Thank you so much for this article. I never knew anything about virtual hosts on xampp before now.
Can you please add an article on migrating the website from the local server to a live server (web host)
Thank you once again
whoah this weblog is magnificent i love reading your posts. Keep up the good work! You realize, a lot of people are searching around for this info, you can aid them greatly.