Thursday, 24 September 2015

Installing Wordpress on a Local Server(local machine) and Database on a Remote Server or Hosting Server

I am new to Wordpress so any suggestions or corrects in the post are welcome.

Now one would think why would you ever want that kind of setup for a Wordpress site. But believe me it reduces a lot of effort. In a minute you'll realize what I am talking about.

I prefer customizing the look and feel plus a little here and there of Wordpress sites locally before deploying them on the server. Of course it is possible to edit the code once the site is deployed from the wp-admin panel but then I find it quite inconvenient especially when the bandwidth is low(slow net speed). So I prefer doing it locally using other editors available like Notepad++.

So that means you edit and fill in all the initial stuff you got locally and then perform the following steps:

  • Export the local database
  • Import the database into the Hosting Server
  • Using any client FTP (for eg. Filezilla )transfer your locally developed website to the Hosting Server
  • Then make changes in the database so now the website refers to the actual domain instead of the localhost.

This database thing is a nightmare especially for those who are not from the programming background. Sometimes due to encoding issues it becomes a headache even for those with experience.

A better way (actually a less painful way) is to have the Wordpress Database of your website on your Hosting Server right from the start of your installation. This way you won't have to go through the pain of migrating the database from your local machine to the Hosting Server.

  • Simply create a database on your Hosting Server.
  • Now if using WAMP extract the Wordpress Installation in the C:\wamp\www\ directory and rename the wordpress to your site name(or anything you want)
  • Open a browser and type localhost\your_wordpress_folder_name\
  • A page will open which will ask you to select the language of your choice. After selecting that you will be asked for your credentials.

Fill in all the credentials. 

  • Host name - url of database server   (for eg:
  • User Name - username of your database
  • Password - password of your database
  • Table Prefix - change this if you have(or want to in future) save content of several wordpress sites in the same database(i.e. one database for several sites)
  • Click on submit.
Now we come to the main focus of this Post

If all goes well then you will be directed to the Installation Page.

It is very likely that you'll get a error 'Error in Database Connection' inspite of filling all the credentials correctly.
This happens generally because your Hosting Service(for eg. DreamHost is what I use) does not allow connections from remote machines for security reasons.

There is a way to change this setting called 'Allowable Hosts'

On DreamHost the path to this is Goodies->MySQL Databases ->Users With Acess -> Click on the User 

On clicking on the user a new page will open where you will find a text-box of Allowable Hosts where you can fill in the IP address of the machine from where you want to allow access of this user to the database,

For your purpose DreamHost displays a 'You current computer is:xx.xx.xx.xx'. Simply paste that in the Allowable Hosts box and you are all set.

Try submitting the credentials again in your Wordpress installation and now it will successfully connect to your database and you can proceed with the installation.

Thats it! 

You can now customize/work on your Wordpress website on a local machine and when done simply just transfer the website to your Hosting Service using FTP without worrying about the database or other changes.

Note: Maybe this is not a clean and the only way but I find it very convenient to work in a editor of my choice. Synchronizing Databases from local to remote in PHPMyAdmin can also be another way but I haven't tried it out yet.

Thank You For Reading :D

Wednesday, 23 September 2015

Setting up WAMP and Eclipse for PHP(PDT)

For web development I have used many editors ranging from simple Notepad++, Sublime Editor to a little complex but very useful Adobe Dreamweaver.

The other day I was just checking out some good IDE's for PHP development and I came across Eclipse PDT and found it quite useful.

Download PDT
Download WAMP

Most of us after extracting and running Eclipse PDT come across this error 404 while trying out the helloworld program on localhost in PDT.

 and the simple reason is because we don't have a server running.

The easiest way to get this running(or develop PHP programs on Windows) is to install WAMP.

  • Install WAMP
  • Download Eclipse for PHP(PDT)
  • Extract PDT and run the eclipse.exe
A dialog will appear to set the workspace for your project
  • Change the path to 'C:\wamp\www'

  • Click on OK
  • Now minimize the eclipse window and start WAMP which will automatically run the Apache Server.
Now you are all set with WAMP and PDT. 

You can now build your first PHP project and run it successfully without 404 error. :D

Sunday, 6 September 2015

Configuring MongoDB and PHP on Windows

If you are reading then probably you are a beginner. This post will guide you from the basic of how to configure MongoDB and PHP on Windows.

Personally I love MongoDB because of its features and good documentation which makes it easy to learn.

The First Step:

Install MongoDB on your Windows version.
To learn how to install MongoDB visit my earlier post or click on the link below:
Setting Up MongoDB on Windows

The Second Step:

The simplest way to work with PHP on Windows is to use WAMP.

WAMP stands for:
W - Windows
A - Apache Server

You can download WAMP from Here!

Wow that was easy!

The Third Step:

Now this step can be easy or frustrating. It depends on your luck. I had a hard time figuring out the correct driver for My PHP version.

I can make it simple for you if you have downloaded the exact same as I am specifying below:

1. MongoDB 32 bit
2. WAMP 2.5 (32 Bits & PHP 5.5)

In this case:
  1.  Go to this Link to download the PHP-Mongo Driver.
  2.  Download ''.
  3.  Extract the above file.
  4.  Select 'php_mongo-1.5.1-5.5-vc11.dll' and rename it to 'php_mongo.dll'.
  5.  Paste it in the ext directory 'wamp\bin\php\php5.5.12\ext'.
  6.  Modify the php.ini file - Add 'extension=php_mongo.dll' in php.ini file.

Elaborating on the point 6 i.e modifying php.ini file, it can be done in two ways:

      1. After installing WAMP run the wamp executable(.exe).
      2. You will see a small 'W' icon on the right bottom corner of your screen(i.e. the notifications
           area) as shown in the image.

       3. The second way is to directly search for the 'php.ini' file in the  
           'C:\wamp\bin\php\php5.5.12\' directory and edit it.

For those who haven't downloaded the exact same version files, all the steps are same except Step 2 i.e 'Download ''. At this step you need to download the driver suitable to your php version and then extract it and rename the correct file to php_mongo.dll.

Now restart WAMP by clicking on Restart All Services and then click on Put Online to start the server.

You can check whether PHP has accepted the mongoDB driver(i.e. they are compatible) by opening the browser and typing 'localhost'


 Then click on phpinfo().

If mongoDB has been accepted by PHP then on scrollingd down you will find a section describing the mongo_php driver specifications.

Thats it! Your MongoDB and PHP is all set to work together.

Happy Coding! :D