Transfer site from local development to the server via ssh access

The article provides a step-by-step guide on transferring a WordPress site from local development to a server using SSH access. It covers essential commands and best practices to ensure a smooth migration, including file transfer and database import.

Transfer site from local development to the server via ssh access

What we need:

  1. Access to the server with ssh
  2. Installed on the server WP-CLI

How to install WP-CLI on the server?

  1. curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  2. php wp-cli.phar --info (should output the WP-CLI version)
  3. chmod +x wp-cli.phar
  4. sudo mv wp-cli.phar /usr/local/bin/wp

Step-by-step instructions on how to quickly transfer a site. When you need to transfer to the dev version, all content and the database, or make a deployment

  1. Ssh connect to the server
  2. Go to the folder with the site cd /path/to/wp/folder
  3. We execute the command wp core download --allow-root
  4. Create DB in host panel
  5. We need to configure our wp-confing.php file for this we execute this command replacing the parameters with our data wp core config --dbname=YOUR_DATABASE_NAME --dbuser=YOUR_DATABASE_USER --dbpass=YOUR_DATABASE_PASSWORD --dbhost=if_differs_from_a_localhost --dbprefix=dbprefix
  6. We need to dump the database from the local machine and upload it to a folder on the server
  7. We import the database wp --quiet db import /path/to/file/exported-wp-sql.sql
  8. Now we need to change all URLs from local to main domain wp search-replace http://old-url.com https://new-url.com --all-tables
  9. We transfer all the files that are in the folder wp-content/ (if you have macOS \ Linux \ Unix you can execute the command in the terminal scp -r remoteuser@remoteserver:/remote/folder/ /path/to/wp/folder)

Now our site has been successfully transferred to the server

Related posts

Insights and Tips from My Journey

JWT Token Authentication in WordPress REST API

JWT Token Authentication in WordPress REST API

  • 17.11.2024
  • 41
Effective Ways to Prevent Email Spam on Your Website

Effective Ways to Prevent Email Spam on Your Website

  • 10.11.2024
  • 69
How to Send Contact Form 7 Submissions to a Telegram Bot

How to Send Contact Form 7 Submissions to a Telegram Bot

  • 05.11.2024
  • 115
All Posts

Ready to Take Your Project
to the Next Level?

Let’s bring your vision to life with expert development and custom solutions.
Contact us now and get started on transforming your ideas into reality!