How to transfer a website from virtual hosting to VPS using LAMP

How to transfer a website from virtual hosting to VPS using LAMP

01.06.2022
Author: HostZealot Team
2 min.
1335

One of the most reliable and proven ways to transfer a website from a virtual hosting on the VPS is a LAMP stack – with this software you can sequentially:

  • create a backup database;
  • transfer files to VPS;
  • set up a new hosting;
  • delimit access rights for users;
  • create a database;
  • configure and prepare the site for operation;
  • check the correctness of the transfer.

In the example we are considering now, the site will run under WordPress, and the transfer is carried out on the Ubuntu 18.04 operating system. This is one of the most popular bundles, so the guide will be relevant for most network administrators.

How to install LAMP

The LAMP complex is necessary to ensure the operation of most web servers. It includes 4 key software products:

  1. Apache Web Server.
  2. OS Linux.
  3. MariaDB or MySQL database management system.
  4. The PHP language pack required for web applications to work.

To install LAMP on Ubuntu, it is enough to enter a series of commands sequentially:

sudo apt install apache2
sudo apt install mysql-server
sudo apt install php7.2 libapache2-mod-php7.2 php-mysql
sudo apt install php-curl php-json php-cgi php-gd php-zip php-mbstring php-xml php-xmlrpc

If desired, you can also order an additional LAMP installation service at the stage of choosing a tariff plan from HostZealot. 

Also, after installation, you must allow access to your server from the outside, add its port to the exceptions with the command:

sudo ufw allow in 80/tcp

If your port number is different, we change the command accordingly.

Above we described the manual way to install LAMP components, but there are other, simpler options – most often the stack can be installed automatically through the control panel. This feature is not available on all PU, so we considered it necessary to describe the manual installation method. Now let's look directly at how to transfer a website from virtual hosting to VPS.

Creating a database backup

If you are using the cPanel control panel, open it and go to the "Backup" section. There is nothing complicated here – just click on the "Download a Full Account Backup" button and specify the place where to save the archive. Transfer the saved copy of the database to another computer or VPS. Yes, you can immediately export it to a virtual private server using the FTP, SFTP, or SSH protocol.

how to transfer a website from virtual hosting to vps using lamp

Copying site files to VPS/VDS

On the VPS server where you want to transfer a copy of the database, you need to open the control panel on behalf of a user with root access rights.  Then, in the "Data Recovery" section, you need to select the previously created archive and confirm the action.

As a result of your actions, all the data that was previously on the virtual hosting will be deployed on the server – site files, databases, mail, and even cron tasks.

The sequence of actions may vary slightly, depending on the control panel used, but in all cases it looks similar. Create a full copy of all data on the old server, transfer it to the new VPS and restore, simple as that. 

Setting up Virtual Hosting

First of all, you need to configure the web server so that it functions correctly in a new place. To do this, edit the configuration file wp-config.php by changing the details of the MySQL database in it to new ones. Open it in edit mode and use the keyboard shortcut "Ctrl+F" to find the key "MySQL settings". You will see something like this in front of you:

// ** MySQL settings - You can get this info from your web host ** //
 /** The name of the database for WordPress */
 define('DB_NAME', 'u694443746_meryr');/** MySQL database username */
 define('DB_USER', 'u694443746_tatym');/** MySQL database password */
 define('DB_PASSWORD', 'fjg#fKLO033j');/** MySQL hostname */
 define('DB_HOST', 'mysql');

Here you need to update the values:

  • DB_NAME is the name of the MySQL database.
  • DB_USER is the MySQL user name.
  • DB_PASSWORD is the password for the database.
  • DB_HOST – here we simply register localhost, because our database is located on the same server.

Save the changes, the final touch is to update the A-record.

Changing the domain A-record

To do this, go to the "DNS Zone Editor" section in the control panel and specify the IP address of your new VPS server, and then save the changes. This completes the transfer of the virtual server to the VPS, everything should work properly. If you still have questions or difficulties, feel free to contact us using the telephone numbers listed on the website or by writing to Livechat.

Related Articles