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.
What we need:
- Access to the server with ssh
- Installed on the server WP-CLI
How to install WP-CLI on the server?
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- php wp-cli.phar --info (should output the WP-CLI version)
- chmod +x wp-cli.phar
- 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
- Ssh connect to the server
- Go to the folder with the site cd /path/to/wp/folder
- We execute the command wp core download --allow-root
- Create DB in host panel
- 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
- We need to dump the database from the local machine and upload it to a folder on the server
- We import the database wp --quiet db import /path/to/file/exported-wp-sql.sql
- 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
- 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
- Category:
- Dev
- Live coding
JWT Token Authentication in WordPress REST API
- Category:
- Maintenance
Effective Ways to Prevent Email Spam on Your Website
- Category:
- Dev
How to Send Contact Form 7 Submissions to a Telegram Bot
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!