Import Wordpress site from Cpanel¶
Overview¶
Wordpress is the most used tool in the world for creating websites and blogs.
Cpanel is the most used hosting control panel currently.
In this tutorial you will learn how to import a website made with Wordpress and hosted in a Cpanel server.
Quick Start¶
Login¶
Open the admin in your browser http://admin.daspanel.site
The admin user and your password are the ones you choose when creating your project as instructed here.
Create new site¶
Go to the Sites module
- Add new site clicking the "+" icone in the upper right of the Sites panel to see the page with the options for the new site:
- Description: Write an description for your new site
- Type: Choose 'Wordpress' as Type
- Engine: And 'PHP 5.6' as Engine
- Click on the button 'CREATE SITE'
PHP version
The site that will be imported is hosted in a Cpanel account that uses PHP 5.6. Thus, we chose the equivalent Daspanel PHP engine.
After the site has been created, a screen will be displayed to upload any remote content that is in a ZIP file. For this howto we will NOT use this feature.
- Click the left arrow
at the top of the screen to return to the sites page.
Import site content files¶
The firebase-tools
is a program that must be run through a console. To do this open
the console of the site that was created:
- Click the second bullet to display the toolbox management area of the chosen site.
The site card will be changed to the toolbox management area:
- Click on the console icon to access it.
If this is the first time you access the console in the current session of your browser, a screen like this will appear to log in:
- User Name: Is the console user.
- Password: Is the console user passord.
- Click the login in button.
Login credentials
You can easily obtain login credentials in the *** Console *** section of
the Daspanel System->Services Users
module using the link below:
After your browser has an authentication token with console access permission, the web page of the console will be displayed:
Cpanel account info | |
---|---|
FTP Server | ftp.cpanelserver.com |
Cpanel Account | cpanelaccount |
Cpanel Account Password | mysupersecrectpassword |
Site Directory | public_html |
Now run this command on the console:
lftp -u cpanelaccount,mysupersecrectpassword -e 'mirror -v --ignore-time --parallel=4 public_html public_html; bye' ftp.cpanelserver.com
When the command finish you see an screen like this:
Set root dir of the site¶
When the site was created its content is initially served from the directory of its default version.
That is, when you access, for example, https://wonderful-bartik.sites.daspanel.site/
the content displayed is being fetched from a directory like this
content/cjb71wzv1000365o420pyc5np/v/cjb71wzxb000465o4u7cquskg
.
However, when importing the Cpanel site the content of it is in the sub directory
content/cjb71wzv1000365o420pyc5np/v/cjb71wzxb000465o4u7cquskg/public_html
.
Before viewing the site configure the root dir of it going to manage the available versions of a site go to the Sites module
- Click the third bullet to display the version management area of the chosen site.
The site card will be changed to the version management area:
- Click the MANAGE buttom to go the management page.
On the next page you will see a list of all the existing versions for the site:
- Click the Edit button for the choosen site.
- Set the directory relative to the top level directory where the site version
exists. In this case it is
/public_html
. - Click UPDATE VERSION to save changes.
Update Wordpress configuration¶
Before proceeding, you need to make a small adjustment to the wp-config.php file: change the MySql hostname.
Access the site file manager, enter into
the public_html
dir, click on the wp-config.php
file icon and you will see
its contents:
Almost always the value set for the DB_HOST
variable will be equal to localhost
.
In Daspanel the MySql server is in a separate container and so we need to change
the value to the correct hostname.
- Click the Edit button.
Being in edit mode:
- Change he
DB_HOST
variable to the valuedaspanel-mysql
: - Click the Save file button.
Before proceeding take note of the database access information, they will be needed in the next step:
Create Wordpress database in Daspanel¶
Before import the Wordpress database you need a MySQL database in Daspanel. Click the link below to find out how to use the Daspanel database management service:
Remember to create your database and its user with the information that is in
wp-config.php
as in the previous section of this tutorial.
Import Wordpress database¶
In Cpanel the tool that has to be used to export the database is phpmyadmin. It is beyond the scope of this tutorial to explain how to use it, but on wordpress.org this page explains how to export the database of a wordpress website.
After the exported database file is saved to your local computer, use the Daspanel database management service to create an new local database and import the Wordpress database exported from the Cpanel server.
In the Daspanel database management page:
- Make sure you have select the correct database.
- Click Import buttom.
In the next page:
- Select the database exported sql file.
- Click Execute to start the import.
When the import finishes successfully a page similar to this will be displayed:
Changing the site URL¶
When you import a Wordpress site to be used with another domain name, it usually stops working, it has problems with redirection, broken images, etc.
This is because Wordpress saves its content information to the database with the domain for which it was originally created.
The internet is full of information about this and also with several ways to solve the problem. In this tutorial we will adopt one suggested in wordpress.org in the link below:
Go back to the site console and run the following commands:
cd public_html
wp option get siteurl
wp option get siteurl
is the current set value set for this
Wordpress option.
wp command
Daspanel comes with wp-cli installed on the engines that support Wordpress.
It can be executed by running the wp
command. Learn more about wp-cli at
this link:
Go to the Sites module and copy the URL of the new wordpress site created in Daspanel:
The URL will look something like https://boring-pare.sites.daspanel.site
With the original siteurl
value and the site URL in Daspanel in hand run the
following commands:
wp option update siteurl 'https://boring-pare.sites.daspanel.site' wp option update home 'https://boring-pare.sites.daspanel.site' wp search-replace 'http://oldsiteurl.com' 'https://boring-pare.sites.daspanel.site' --skip-columns=guid --report-changed-only wp search-replace 'htts://oldsiteurl.com' 'https://boring-pare.sites.daspanel.site' --skip-columns=guid --report-changed-only
View the new site¶
Go to the Sites module. You will see a page like this:
- Click the "PREVIEW" button and a new window will open in your browser displaying the contents of the active version of the site.