Working with XAMPP and WordPress

In this tutorial, you will learn how to work with WordPress in a XAMPP (X, Apache, MySQL, PHP, and PERL) environment, including deployment and migration tips and techniques.

One of the best practices for developing a WordPress website starts in the development server. An example of a great development server to work with WordPress is XAMPP. The primary reason for testing and developing WordPress with XAMPP is simple:

  •  It allows a faster development environment, since you will not be uploading files to a remote web host just to test your designs, plug-in, etc. Uploading and downloading files consumes a lot of time.
  • You will not be disrupting user experience on your website, since XAMPP local host is only accessible to you and not the users on the Internet.
  • It’s more secure. It’s normal to commit mistakes in the early phases of WordPress website development and if you do this directly to your remote hosting server, you will be exposing a lot of errors to the public, which can compromise your website.

Working with XAMPP and WordPress Flowchart

Before you can begin, you need to have XAMPP installed on your computer. If you do not have XAMPP installed, please refer to the following tutorials:

Install XAMPP in Ubuntu/Linux: http://www.devshed.com/c/a/Administration/How-to-Install-XAMPP-on-Ubuntu-Linux/

 

Install XAMPP in Windows: http://www.devshed.com/c/a/Administration/Install-XAMPP-on-Windows/

To give you an idea of the website development process using XAMPP and WordPress, refer to the flowchart below:



As usual, you will be downloading the latest version of WordPress (highly recommended for security reasons). After downloading it, you can install it to your XAMPP localhost, a process which will be covered in the coming sections. After the successful install, you can start developing your WordPress website. This includes installing themes, required plug-ins for desired website functionality, initial content, etc.

Once it is complete, you can safely deploy your website on the remote hosting server. It will then be accessible to all users on the world wide web/Internet.

Necessary Preparation

Follow these steps:

  • Download the latest version of WordPress here: http://wordpress.org/latest.zip
  • Go to the downloads folder where you will find wordpress-3.1.1.zip (WordPress 3.1.1 is the latest version as of the time this tutorial has been written). Right click on it  and click “Extract here”. A folder named “wordpress” will then be extracted.
  • Rename the folder from “wordpress” to “wordpressdemo”. If you click on the "wordpressdemo" folder, you should see these files:




  • Copy and paste the "wordpressdemo" folder to your XAMPP htdocs folder.
  • You need to ensure that XAMPP local server is turned on as well as MySQL.


In Ubuntu:

  • Go to Applications – Accessories – Terminal.
  • Login as root: type this in the command prompt: sudo -s -H
  • Type your Linux root password.
  • Type this command and press enter: /opt/lampp/lampp status
  • Check the results. If the results says that Apache is not running, etc you need to enable XAMPP.

Enable XAMPP by typing this command and press enter: /opt/lampp/lampp start

In Windows:

  • Go to Start – All Programs – Apache friends – XAMPP – XAMPP Control Panel.
  • You should then see the status whether Apache and MySQL are running. You can simply turn them on if they are off.

{mospagebreak title=Create WordPress Databases and Configure wp_config.php}

This time you need to create a WordPress database in a XAMPP environment using phpMyAdmin and configure wp_config.php.

  • Type this URL in your browser address bar: http://localhost/phpmyadmin. Use the credentials you have configured during your XAMPP installation. You need to log-on to the phpMyAdmin using your root credentials.
  • After logging in, you will see “Create New Database”. Type wordpressdemo_database
  • When you see “Database wordpressdemo_database has been created”. Logout from phpMyAdmin.
  • Go to the "wordpressdemo" folder in XAMPP htdocs. Find a file named as “wp-config-sample.php”. Open this file using your favorite PHP editor or Notepad ++
  • Supposing you have the following WordPress database and MySQL credentials:

Database name: wordpressdemo_database
Database user: root
Database password: abcxyz
Database host: localhost


This is the code:


<?php
define('DB_NAME', 'wordpressdemo_database');

//MySQL database username
define('DB_USER', 'root');

//MySQL database password
define('DB_PASSWORD', 'abcxyz');

//MySQL hostname
define('DB_HOST', 'localhost');

//rest of the wp-config-sample code here

 

  • You need to input the unique phrases and secret keys. Go to this URL: https://api.wordpress.org/secret-key/1.1/salt/


Copy the outputted results as shown in the browser then overwrite the following lines in the wp-config-sample.php

define(‘AUTH_KEY’,         ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’,  ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’,    ‘put your unique phrase here’);
define(‘NONCE_KEY’,        ‘put your unique phrase here’);
define(‘AUTH_SALT’,        ‘put your unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);
define(‘LOGGED_IN_SALT’,   ‘put your unique phrase here’);
define(‘NONCE_SALT’,       ‘put your unique phrase here’);

  • Save the edited file as wp-config.php and save it in the same location/path as wp-config-sample.php.
  • You can then safely delete “wp-config-sample.php”.

Install WordPress

Now that you have completely configured the necessary files for installation, you are ready to install WordPress:

  • Type this URL in the browser address: http://localhost/wordpressdemo/
  • The five minute installation screen will then show. You need to type the site title, username (do not use “admin” and change it to something else, for security reasons), your desired WordPress password and your email.
  • Just check the “Allow my site to appear in search engines..”.
  • Finally click “Install WordPress”.
  • If you see the message “Wordpress has been installed”. The installation has been successful.
  • Click Login and type your WordPress login credentials.
  • To see your WordPress website at its default. Open new tab in your browser and type this address: http://localhost/wordpressdemo/ , this is the default homepage. For example:




Note: As the flowchart mentions in the first section of this tutorial. This is the start of the WordPress website development. Feel free to change the default theme to something you like and execute other website development tasks depending on your needs.

{mospagebreak title=Wordpress Deployment and Migration Tips} 

The following are the things that you need to take note of very carefully when you deploy your WordPress website to a web hosting server or if you plan to deploy your WordPress website which was previously setup in the web hosting server to your XAMPP local host.

Tip#1: The wp-config.php entries should be correct if you deploy your WordPress website to remote hosting. Of course, it will use the web hosting database NOT your XAMPP database anymore. Basically you just need to export your local WordPress database to your hosting database server and then update the wp-config.php entries as shown previously.

Tip#2: Same thing with deploying WordPress to your XAMPP localhost. You need to import your WordPress database to XAMPP phpMyAdmin and then update the wp-config.php.

Tip#3: Whenever you deploy or migrate WordPress from one location to another (XAMPP localhost to web hosting server or vice versa). You need to update important entries in the wp_options table in the WordPress database. These are the option_names:

  • siteurl
  • home

Example: supposing you need to deploy the WordPress website developed in XAMPP localhost (http://locahost/wordpressdemo) to a remote hosting server in your domain: http://www.example.com/. The following are the steps to update siteurl and home:

  • Login to http://localhost/phpmyadmin.
  • Go to your WordPress database and click wp_options table.
  • Change the following:

siteurl option name:

 

siteurl: http://localhost/wordpressdemo


TO:

siteurl: http://www.example.com


b.) home option_name

home: http://localhost/wordpressdemo


TO:

home: http://www.example.com

If you are doing the opposite (migrating from remote server to localhost), the same method applies.

Tip#4: If possible always use relative URL structure (http://www.webdevelopersnotes.com/design/relative_and_absolute_urls.php3 ) so that you can easily migrate your WordPress website from XAMPP localhost to hosting server or vice versa.

 

[gp-comments width="770" linklove="off" ]
antalya escort bayan antalya escort bayan