Deploying your WordPress website from your desktop to a live server is easy if your host uses cPanel. You won’t even need to mess around with FTP software as cPanel includes a file manager utility that can greatly simplify and speed this task for you. DesktopServer Premium also features a Quick Deploy feature that can make it faster for small to medium-sized sites. But in this post I’ll show you how to deploy a site manually with cPanel alone which is better suited for larger or more complex sites that Quick Deploy may not support. There are three basic steps to deploying manually:
- Create an Empty Database
- Export Your Development Website
- Upload Your Website Data
Use cPanel to Create an Empty Database
WordPress separates style and content by storing page and post content in a MySQL database. This requires that you create an empty database for storing your website content. Thankfully, cPanel makes it simple to create a new database for your content.
First login to cPanel, navigate to the Databases section and click on the icon titled “MySQL Database Wizard”. The database wizard will allow you to quickly do the following:
- Create a database and name it.
- Create a username for the database.
- Specify a password for the database.
- Grant the username privileges to the database.
After clicking the “MySQL Database Wizard” icon, you can then specify your database name. Your database name may be prefixed with your cPanel account username followed by an underscore. Be sure to record your complete database name with the prefix and underscore (i.e. scarroll_example). Click the “Next Step” button to continue.
Next, you will be prompted for a database username. Like the name of your database, your chosen database username maybe prefixed with your cPanel account username followed by an underscore. For simplicity, you can use the same name for both the database username and the database name (this will also make it easier for phpMyAdmin to manage). Next, specify a password or click the “Password Generator” button to have a password generated for you. Click the “Create User” button to continue.
Be sure to record your database name, username and password on the following screen as you will need this information when exporting your website from DesktopServer. Lastly, you will see the privileges section. Simply click the “All Privileges” checkbox as WordPress will need all privileges to work effectively. Click the last “Next Step” button to finish and complete the MySQL Database Wizard.
Now that you have an empty database created on your live server with valid credentials, your next step will be to give the database credentials to DesktopServer’s export process. This will allow DesktopServer to prepare a copy of your wp-config.php file for hosting on your live server.
Use DesktopServer to Export Your Development Website
Provide those user credentials you recorded from your live server in step 1 to DesktopServer so that we can create an export that will work on your live server.
First, start DesktopServer and select the last option to “Export, import or share a website”, followed by the option “Export or deploy a WordPress website”.
The export options screen will display a drop down list of websites that you have created on DesktopServer. Select the website that you want to export to your live server followed by filling out the “Export As” text box with the valid domain name of your destination server. Be sure to select the option for “Export to a website archive (.zip file)” and click the “Next” button.
Next, obtain the document root value from your server where your website will live. You can find this via cPanel’s File Manager icon and looking at the tree structure or by visiting a page with a little script to your server (click here for more info). Fill out the database name and credentials you obtained using the MySQL Database Wizard. Unless you were provided with a specific host, be sure to type
localhost for the “Host” field. Then click the “Next” button to continue. You can leave the “Fetch live hosting server details” unchecked.
Lastly, you will need to provide the filename and output folder for your portable website archive or just accept the default. Optionally, you may want to check or uncheck “Encourage search engine visibility”. Some users may want to turn this feature off if you are providing a preview of the site on a temporary or alternate domain name (this can help prevent SEO contamination).
Click the “Next” button and DesktopServer will start exporting your website, replacing .dev with your chosen top level domain in the database and php files. You will see a link to the folder containing your file archive. The archive will contain your complete WordPress website which includes the WordPress core files, themes, plugins, and a complete export of your database as a text file called database.sql.
Upload Your Website Data
Deploying your website manually is a simple two-part process: 1) Import your database and 2) Upload your WordPress files. We will start with extracting the database.sql file from our archive. Decompress the archive file by double clicking it (on Macintosh) or right-clicking it and selecting “Extract All…” from the pop-up context menu (on Windows). Open the extracted folder and move the database.sql file to the desktop or a new place by dragging it from the folder.
Your database.sql file may be large if your website has a lot of posts and pages or uses third-party plugins to store an extensive amount of data (i.e. real estate listings, list of products for eCommerce, etc.). In either case you may wish to compress the database.sql for faster uploading as a separate zip archive. Simply right-click the database.sql file and select the ‘Send To ? Compressed (zipped) Folder’ (on Windows) or ‘Compressed “database.sql”‘ (on Macintosh) from the pop-up context menu. It is important to make sure that the file name ends with a “.sql.zip” otherwise cPanel’s phpMyAdmin may not know what to do with the file. By default, Windows renames the file and removes the sql extension to read just “database.zip”. Windows users must rename the file (right-click and select rename) to database.sql.zip for compatibility.
Import Your Database
Now go to your live website’s cPanel and click on the phpMyAdmin icon. phpMyAdmin should appear and present you with a list of databases on the left hand side. Select the database by the name you used in Step 1. Be sure to select your database first as we’ll be uploading the database.sql.zip file and it is important to have the proper database selected. Next, click the Import tab at the top of the phpMyAdmin page, followed by the “Browse” button and select the database.sql.zip file. Lastly, click the “Go” button to begin uploading and importing your data into your live website database.
Upload You WordPress Files
Next, you will need to upload your WordPress website files and folders. Once again, cPanel makes this incredibly easy and significantly faster then having to use a client FTP program. You will be able to take advantage of maximum compression without having to wait on uploading multiple files because cPanel will allow you to use the server to decompress and move files. Start by going back to your extracted folder from your website archive. This folder will be much smaller since you’ve moved the database.sql file out of it. Before compressing it, be sure to move or discard the original website archive that contained the database.sql file to avoid confusion (as it will have a similar .zip name). To re-compress the extracted folder that has only your WordPress website files (minus the database.sql you moved out), right-click the folder and select the ‘Send To ? Compressed (zipped) Folder’ (on Windows) or ‘Compressed’ (on Macintosh) from the pop-up context menu.
After compression, you can upload the file using cPanel’s File Manager. Select the File Manager icon from cPanel and select your website root folder. The website root folder is usually labeled www or public_html. You might have both folders where one is simply an alias for the other. Highlight the folder in the left hand side of the File Manager and select the “Upload” icon from the toolbar.
Clicking “Upload” will cause File Manager to present you with a webpage to upload your website archive file. Click “Browse” and select your file. A progress bar will automatically be displayed indicating the progress of your upload. The status will change to “Complete” when the upload has finish. After the file finishes uploading, go back to File Manager’s list of files. If the uploaded archive isn’t initially visible, try the “Reload” icon above the list of files.
Next, find and click the archive file to highlight it. Use the “Extract” icon on the button toolbar to extract the contents of the website archive. By default, the contents of the file will be extracted to a folder with the same name as the archive file. You may need to wait while the server extracts the files. If the folder does not appear visible, try the “Reload” button above the list of files.
You will need to move the contents of the extracted files folder to the site root. cPanel makes moving the files easy. Select the extracted folder in the folder list (left hand side) or double-click the extracted folder in the file list view (right hand side in the File Manager) to view the list of extracted files. With the folder contents revealed, simply click the “Select all” button above the list of files followed by the “Move File” icon on the icon toolbar. Use the backspace (delete on Macintosh) key to correct the folder path to read /public_html/ as we will want to move the files to the site root.
After moving the files to the correct location, you can discard (delete) the website archive along with the extracted folder by simply highlighting (click) the items in File Manager and clicking the “Delete” icon (red ‘X’) on the icon toolbar. You should now be able to visit your website’s home page (i.e. http://www.example.com). However, you may need to first update your .htaccess file by re-saving your permalink settings from WordPress’ admin pages. To access WordPress’ admin pages, visit the sub-folder ‘wp-admin’ (i.e. http://www.example.com/wp-admin). Go to the Settings ? Permalinks menu followed by clicking the “Save Changes” button. If you are installing a WordPress multisite, you may need to update your .htaccess file manually by visiting the Settings ? Network Setup menu and updating the .htaccess file with the suggested settings found there. You can use cPanel’s File Manager to edit any PHP file by selecting the file and using the “Edit” icon on the toolbar. By using DesktopServer’s export functions to prepare your website along with cPanel’s built-in File Manager, you can speed deployment of your complex or larger WordPress websites on a live server without any extra tools or utilities. Equipped with this experience and knowledge will make you a more skilled and valuable WordPress developer. You will be able to take on larger projects on a multitude of professional hosting providers that support the cPanel interface.
Error establishing a database connection – This is an indicator of an incorrect username, database name, or password in the wp-config.php file. You can correct and/or double-check these items from within File Manager. Simply find the file using cPanel’s File Manager by clicking the public_html folder from the folder list (left hand side of File Manager). Select the wp-config.php file in the file list and click the “Edit” icon on the toolbar to edit the file contents on the live server. An editor will appear that will allow you to edit the file contents. Look carefully at the definitions for the DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. You can save changes via the “Save Changes” button in the upper right hand corner of your web browser.
You will have to turn on hidden files if you need to open the .htaccess file manually to edit it. The opportunity to show hidden files is shown when first you click on the File Manager icon in cPanel. A prompt will ask you if you want to see hidden files or if you want to dismiss the prompt in future sessions. To reset the prompt and to see the view hidden files checkbox again, use the reset interface link in cPanel.