viernes, 19 de junio de 2015

How to Install WordPress on a Local Environment

How to Install WordPress on a Local Environment


It’s a well know fact that not many people know that WordPress can also be installed locally, and one can even work or test offline. If you are reading this post, then you have probably installed WordPress on live server. But not everything is required to be tested online. There should be a safe place where we can just experiment, without thinking twice about site visitors and what would happen if we make a mistake. And sometimes (rarely) because of some coding error like too many queries fired at one time, the entire server can crash. We really don’t want to take a chance and do all this experiment live. The solution is simple. Install WordPress on your own computer (laptop or desktop). And the best thing is that you don’t need to purchase anything and no need to be a coding ninja for this. Even a beginner can do this.
Some more reasons to install WordPress on local environment:
  • Faster loading time on local environment. On live server it may take more time to load the webpage (because of internet speed), but locally it runs fast.
  • No need to purchase domain name and webhosting
  • Test out plugins, themes, and other tweaks faster, as now there is no need for uploading each file and folder and waiting for the task to finish. Locally, you have to just download any plugin or theme, and move/copy it to wp-content, and that’s all.
  • No fear to screw up anything. Experiment the way you want.
  • Also its a best practice to never do on the fly updates on a production website without first testing it on some offline or local server.
So now, without further ado, let’s get to the point. Here’s the process to install WordPress locally:
First things first. Which platform are you working on?
Windows users can use WAMP or XAMPP
Mac users can use MAMP
And of course, we will need WordPress also.
Step 1
Download WampServer from this link. WampServer is an open source project and free to use. Once downloaded, run the installer. The installation process is very simple and you can just follow the on screen instructions.
On the first screen, press “Next” and then click on “I accept the agreement”.
This is the option to select “installation directory”. By default, its path would be c:\wamp – You can change this location if you wish to.
wamp
Select if you want to create shortcuts on Desktop or Quick Launch bar.

Now that all settings are done, the installation process is ready to install WampServer. Click on “Install”.
install wamp
It may prompt you to choose your default browser. Browse to your browser and click on open.
In this step, specify the SMTP mail server and address. If you are not sure, then just leave this as blank. Click on Next.
smtp
Installation process is completed. Check mark that “Launch WampServer 2 now” and click on Finish.

Step 2
Download WordPress from its official location and unzip it at this path – c:/wamp/www/wordpress (wordpress is just a folder name, you can give any name to this folder and unzip the files of wordpress in this folder). This is the path where you have installed WampServer.
Step 3
Now let’s check if WampServer is installed properly or not. Just type this in your browser address: http://localhost. If WampServer is working properly then you will be able to see below page:

This is the Server Configuration page. From here you can see which extensions are installed, your existing projects, and phpmyadmin link. Click on this phpmyadmin link.
Step 4
Now we will need to create a new database. If you already have a WordPress database on live server, then you can use the same database name here also. Enter the database name in “create new database” field and click on “Create”. Basically, we are just creating a new database for our WordPress installation. E.g. in below screenshot, a new database is created which is named as “wordpress”. We are not creating any new user or using a password for this task.

A message will be displayed – “Database wordpress has been created”. That’s it, your database is created.

Step 5
And here comes the final step. Enter this path on your browser and hit enter –
http://localhost/wordpress (Note that “wordpress” here is a folder’s name which we used in first step, therefore your folder name might be different)
As we have not configured wordpress, and its database and other settings, you will get this screen. Click on “Create a configuration file“.

Click on “Let’s Go“.

Now we need to enter database name, username and password (of database and not of wordpress), database host and table prefix.

Here is a detailed explanation of each of these fields:
  • Database name: The database name which we just created in step 4. In the example above, the name of database is “wordpress”
  • user name: Enter “root” here.
  • password: Just leave this field as blank
  • Database host: Enter “localhost” here
  • Table prefix: Enter wordpress table prefix here. Or you can just leave the default wp_ table prefix as it is.
WordPress will try to connect with the database and if all settings are correct, then you will see below screen:
Click on “Run the install” to run WordPress installation on your localhost web server.

Fill out site title, username, password and email address and click on “Install WordPress button“.

Finally, the success screen. Click on “Log in” to login to your WordPress installation. Go ahead enter your username and password and click on “Login”.
So now let’s recap all the steps that we have performed:
  • Downloading and installing WampServer
  • Downloading WordPress
  • Unzip the contents of WordPress at this path: c:/wamp/www/wordpress (where wordpress is just a folder name, you can give any name to this folder)
  • Enter this in browser and hit enter – http://localhost
  • Click on phpmyadmin
  • Create a new MySQL database
  • Run this path in browser: http://localhost/wordpress
  • Follow the installation process
  • Enter your desired username, password and email
  • Login
That’s done. So this is how you can install WordPress on a local environment.
Everything’s done and your WordPress should run perfectly now. If you want to use Pretty permalinks (e.g. http://example.com/this-is-post-title), instead of default ugly permalinks (http://example.com/?p=178) then you will need to do enable “mod_rewrite” setting in Wamp server. This can be done by clicking on WampServer icon in taskbar, hover mouse over Apache > Apache modules, and then find and click on rewrite_module.
Setting up a localhost webserver can really come in handy when you want to test out or experiment something without thinking twice about actual site visitors. Many professionals and web developers use this method to install WordPress. After all, this is a smart way to work. Now go ahead and test out how that plugin functions or how that theme looks like before deploying it directly on the live server.

1 comentario:

  1. Thank you, I had been looking all over the place for a guide like this. I managed to figure it out, but by God, it would have been so much easier if you guys had this guide up last year!. Thank you

    ResponderEliminar