Uploading code to a VPS can be done in several ways. Here is a step-by-step guide for some common methods:
1. Using Secure Copy Protocol (SCP)
Install SCP (if not already installed):
-
Linux/Mac: usually pre-installed
-
Windows: use tools like PuTTY or WinSCP
Upload files using SCP:
Upload directories using SCP:
2. Using SFTP
Install an SFTP client:
-
Linux/Mac: terminal or GUI client like FileZilla
-
Windows: WinSCP or FileZilla
Connect and transfer files:
-
Open your SFTP client
-
Enter your VPS IP, username, and password
-
Navigate to your local and remote directories
-
Drag and drop files between local and VPS
3. Using Git
Install Git on your VPS:
Clone your repository:
Push updates from your local machine:
Pull updates on your VPS:
4. Using rsync
Install rsync (if not already installed):
-
Linux/Mac: usually pre-installed
-
Windows: use Cygwin or WSL (Windows Subsystem for Linux)
Upload files using rsync:
5. Using FTP
Install an FTP server on your VPS:
Configure and start the FTP server:
-
Edit the configuration file, e.g.,
/etc/vsftpd.conf
-
Start the server:
Upload files using an FTP client:
-
Connect with your VPS IP, username, and password
-
Drag and drop files from local to server
Example Setup
SCP Example:
Git Example:
-
Push your changes to GitHub from your local machine
-
SSH into your VPS and navigate to your project directory
-
Pull the latest changes: