From Pine View Farm

Cloning Your Website with XAMPP 0

As my two or three regular readers know, recently–well, for most of February–my website experienced some issues. So as to research them, I cloned the site to my local computer using XAMMP, which is available from ApacheFriends.org.

Look below the fold for more.

XAMMP includes a complete webserver stack (Apache, MariaDB, PHP, and Perl) in a single package, configured to work and play nicely with each other out-of-the-box. (On a Linux system this is commonly called a “LAMPP stack,” for Linux, Apache, MariaDB, PHP, and Perl.) XAMMP is available for Linux, Windows, and Mac.

In a Linux system, XAMPP installs to /opt, and the default “www” directory (the location for your website files) is /opt/lampp/htdocs.

Cloning my website involved the following steps, as the website includes a WordPress blog:

      1. Copy the website files, including subdirectories, which I had already downloaded from my hosting provider, into /opt/lampp/htdocs.
      2. Use phpMyAdmin to configure MariaDB to receive the database (see below).
      3. Import the database into MariaDB.

Note that, by default, none of XAMPP’s processes are password protected, as it’s designed for development, not for production. See the Note on Security at the end of this post for information about how to establish passwords.

Testing XAMPP

Once you have completed Step One, you can test XAMPP by issuing the following command as root:

cd /opt/lampp
./lampp start

XAMMP will respond as follows:

# ./lampp start
Starting XAMPP for Linux 5.6.30-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

At that point, you can point your browser at http://localhost and you will see either the XAMPP dashboard page (if you have no files in /opt/lampp/htdocs) or the home page of your website, if you have successfully put your files in place and you are running an HTML website.

Website running on "localhost" using XAMPP

If you are running a PHP website, such as a WordPress blog, there are still a few steps to complete. Note that a valid backup of your database in a format that phpMyAdmin understands is necessary for the following steps.

Importing a Database

Preparing MariaDB: By default, your MariaDB user is root. It is best to create a user with all rights over that database, but without other rights. By convention, such users are commonly given the same name as the database they will administer.

Point your browser at http://localhost/phpmyadmin/ and log in as root. Then click User Accounts–>New and create the new account by filling out the required fields. Next, under “Database for user account,” check to “Create database with same name and grant all privileges.”

Preparing phpMyAdmin: Normally, I use phpMyAdmin’s “Import” function to put my database in place. To do that, though, you must change two settings in /opt/lampp/etc/php.ini file:

memory_limit=
post_max_size=

The default setting for each is 8M. Unless your database is extremely small, you will need to increase those to accommodate the size of your backup file.

Importing: Once you’ve complete the above, log into phpMyAdmin as your database user, then open your database; it will be empty with no tables present. Click the “Import” item, navigate to the location of your database file, and start the import. Note: Do not leave your computer unattended. If your database is sizable, the import is likely to stop with a message about latency or some such thing (I forget the exact wording) and instructions to “click here” to resume it.

Once the import is complete, you have cloned your website and can begin troubleshooting or redesigning it.

A Note on Security

By default, XAMPP is not password protected in any way. From the website:

XAMPP is not meant for production use but only for development environments. The way XAMPP is configured is to be open as possible to allow the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

You institute password protection by running, as root:

cd /opt/lampp/
./lampp security

The script will ask you to create passwords for the various XAMPP functions.

See the XAMMP Linux FAQ for more.

Afterthought:

At last night’s TWUUG meeting, we watched a video at the XAMPP website. For some reason, the XAMPP folks pronounce XAMPP as “shamp,” which causes one immediately to ask, “What about Moe and Larry?”

Share

Comments are closed.