Using cPanel to Import a Live Website

Using cPanel to Import a Live Website

Many hosting providers use cPanel as their control panel for website administration. You can use cPanel features alone to copy your WordPress website and run a mirror image locally on DesktopServer. In this article, I’ll show you how to copy your existing live WordPress website to your local computer. Note that this requires DesktopServer Premium. We are going to use DesktopServer’s import feature which will ask you for a zip archive file containing your WordPress website (plugin files, theme files, etc.) and a “database export” file that contains your posts, pages, configurations, and settings. You can create this zip archive file in a two step process that I will detail below. The first step will be to download all of your WordPress files and the second will be to obtain the database export file. Both can be done easily through cPanel. The third step will be to simply import the zip file as a new website in DesktopServer.

Download Your Website FilesFirst, you will want to download the files that make up your WordPress website. You could do this with your favorite FTP program. But as we mentioned, we’re going to demonstrate how to do this with cPanel alone. Within cPanel is an icon dedicated to managing your website files. Login to your live website’s cPanel and locate the ‘File Manager’ icon and click it. File Manager is usually found in the group titled ‘Files’.

When you click the File Manager icon for the first time, you should see a pop-up window with the option to display hidden files. We are interested in preserving the permalink settings that are stored in the .htaccess hidden file. However, if you do not obtain this file, you can simply re-save your permalink settings using WordPress’ admin menu Settings ? Permalinks. Once the File Manager loads, you will be presented with a list of folders on the left hand side of your screen and the contents of the currently selected folder on the right hand side. The folder containing your WordPress installation may vary depending on how your hosting company chooses to configure their services. Typically, your files will be located inside a folder titled public_html or www. You might have both a public_html and www folder which is okay as one may simply be an alias or “shortcut” to the other.

Click the folder containing your WordPress files for your website (typically public_html folder) and you should see your WordPress website files in the results pane on the right hand side. The right hand side should also contain the files and folders beginning with “wp” such as the wp-content folder and the wp-config.php file. Select all the files that make up your WordPress installation by using the Command button on Mac or Alt+Ctrl buttons on Windows and clicking the various files and folders. WordPress files and folders begin with “wp”. In addition, you should select “index.php”, “xmlrpc.php” and optionally “.htaccess” for permalinks. Once you have selected all of WordPress’ files, select the Compress option to create a zip archive. You will be given a pop-up to select the compression type and input a file name. Select the “Zip archive” (usually the first) option and note the file name or specify one. When the compression operation completes, you can download the archive by selecting it and pressing the download icon on the main toolbar. If you don’t initially see the zip archive file, try pressing the reload icon on the toolbar and locate the zip archive in the results pane. Once you finish downloading the file, unpack the contents and set the folder aside. Don’t forget to delete the archive file from your website as leaving it there might pose a security risk.

Create a Database ExportNext, we are going to want to create our database export file using phpMyAdmin. cPanel usually provides this option under the group heading “Databases”. Click the icon to access phpMyAdmin. If your hosting provider has setup cPanel with the standard options, you should be automatically logged into phpMyAdmin. The first screen you will see in phpMyAdmin should be a list of databases on the left hand side. Select the database that is associated with your WordPress website. If you don’t know the database name, take a peek inside the wp-config.php file that is apart of the zip archive that you downloaded in the first part of this article. Look for the line that begins with “define(‘DB_NAME’,”. The last portion of the database name should match a listing in phpMyAdmin. Click the database name in phpMyAdmin to select it. If phpMyAdmin instead prompts you for a username and password, you maybe able to login using the credentials you find in the wp-config.php file.

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘scarroll_postmy1′);

The wp-config.php contains the database name.

Locate and click the “Export” option after selecting your WordPress database in phpMyAdmin. The “Export” option can be found as a dedicated menu/tab item at the top of the webpage. With the most current version of phpMyAdmin, you’ll be presented with two options 1) Quick or 2) Custom. In both cases you will want to ensure that the format option is set to SQL.

You can proceed with the easy Quick export option in most cases. If you have a larger website, it maybe more efficient to select the Custom export option and set the additional parameter for “INSERT INTO tble_name VALUES (1, 2, 3)”. In the current version of phpMyAdmin this option is also known as “neither of the above” in the data dump options section. This setting may increase the time it takes for imports to be processed but can also isolate “bad data” or malformed content (possibly from a misbehaving third-party plugin) from interfering with your post and page data. Click the Go button to download the database SQL dump file. After downloading the file, rename it to database.sql and place it in the folder that you set aside in step 1. The folder should now contain all of your WordPress website files in addition to the database.sql file. It is important that the database.sql file is located in the same folder as your site’s wp-config.php file. Now you may zip the folder by simply right-clicking it (Ctrl+Click on Mac), followed by the pop-up menu Send To ? Compressed (zipped) folder on Windows or Compress folder on Mac. You will now have a portable zip file containing your entire WordPress website and accompanying database. If you have a lot of media such as video or pictures, you can omit including the wp-content folder in the zip file to save space. All that is essential to create a valid import archive is the wp-config.php file and an accompanying database.sql file. If you do omit the other folders and files, simply be sure to move them over to your website’s folder after the import process completes within DesktopServer.

Import WebsiteYour last step is to import the zip archive you created into DesktopServer. To get started, select the “Export or import a website” option and click next, followed by the “Import an existing WordPress website archive” option and click next. You can select the zip you created to import as a new WordPress website by simply clicking the first field (Import File). An open dialog window will allow you to locate and select your zip file. Note that Mac users may see their file system as an Administrator which differs from your normal user account. You may need to locate your files by starting with the Macintosh HD:Users path to locate the exact location of your zip archive. The additional fields will allow you to specify a domain name by altering the Site Name field. For security purposes DesktopServer will change the top-level domain to .dev (dot DEV). You can use the browse button to specify a different Site Root to store your website files. Click the Browse button to display a folder selection dialog window if you want to choose a different location to store your website’s files. Lastly, clicking the next button will start the import process and your new website URL will be presented to you on the last screen. Don’t forget to visit your WordPress admin screen and re-save permalinks under the Settings ? Permalink menu if you didn’t copy over your .htaccess file. You may need to re-save permalinks if your website’s links don’t appear to be resolving correctly. DesktopServer’s import routine will automatically scrub (search and replace) your links from your live domain name and replace it with your chosen .dev development top-level domain name. If all goes well, you will have successfully re-created your website on your local machine without the use of a migration plugin.

As the Founder of ServerPress, LLC and the Coding Genius behind DesktopServer, Stephen J. Carnam continues to invent new ways to improve developer Workflow through technology. As a huge Advocate of Open Source Software, he promotes Creativity, Community and Collaboration.