Just to give you a bit of background here, I had two sites across two seperate server instances. The challenge was to take one of them, and put it on the other server so I was only left with one of the instances.
On my part this was simply a cost saving measure.
Consolidating two Linux servers into one. Google Cloud Platform
SSH to old server and zip up files in the directory of the site you wish to move.
sudo zip -r backupyoursite ./
Go to PHPMyAdmin on the old server and export the database. Download it to a folder on your computer. Zip it up.
Login to SSH on the other server.
Browse to
sudo cd /var/www/html
Create folder:
sudo mkdir yoursite
Copy all your files into that folder by copying from the old server. E.g
sudo /usr/bin/wget http://yoursite.com/backyoursite.zip /backyoursite.zip
Remove the zip from your old server
sudo rm backyoursite.zip
Unzip into folder
sudo /usr/bin/unzip backyoursite.zip -d ./
Remove the zip file from your new server.
sudo rm backyoursite.zip
Update the permissions
sudo chown -R www-data:www-data yoursite
Create your database in MySQL. Then import the zip file that you saved earlier. This will add all the tables and data that you need.
Make sure you create a user that has rights as well and edit the wp-config.php to reflect what you have created.
Edit the default.conf file inside the
/etc/apache2/sites-available folder to include the below details for your new site name.
E.g
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName yoursite.com ServerAlias www.yoursite.com DocumentRoot /var/www/html/yoursite <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/html/yoursite> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Restart apache
sudo /etc/init.d/apache2 restart
Test your site by changing your local hosts file to point to the new server. Test everything.
Once you are happy, update your DNS for your site name to point to it’s new home.