-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up the remote server and installing prerequisites
To ensure our application runs smoothly, we need to set up a remote server with all the necessary prerequisites. This includes installing Git, Python, pip, and PostgreSQL. This guide walks you through each step, ensuring your server is ready for deployment.
- Accessing the Remote Server To access the remote server, you will need SSH credentials. Use the following command to connect to your server:
ssh username@your_server_ipReplace username with your server's username and your_server_ip with the server's IP address.
- Updating the System Before installing any software, it's good practice to update the system packages to their latest versions:
sudo apt update && sudo apt upgrade -y- Installing Git Git is essential for cloning the repository and managing code. Install Git and verify the version installed by using the following commands:
sudo apt install git -y
git --version- Installing Python and pip Our application is built using Python, so we need to install Python and pip (Python's package installer):
sudo apt install python3 python3-pip -yVerify the installation:
python3 --version
pip3 --version- Installing PostgreSQL. PostgreSQL is our database of choice. Install PostgreSQL using the following commands:
- Add the PostgreSQL APT repository:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'- Import the repository signing key:
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -- Update the package lists and install the latest stable version of PostgreSQL:
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib- Start and enable the postgresql service
sudo systemctl start postgresql
sudo systemctl enable postgresql- Check the status
sudo systemctl status postgresql- Configuring PostgreSQL
- Switch to the PostgreSQL user to configure the database:
sudo -i -u postgres-Setup Databases and Users Create a new PostgreSQL user and databases for the application:
- Create a new user:
createuser <user-name> --pwpromptThis will prompt for the password of the new user. Enter a secure password following best practices. Replace in the command with your desired user name.
- Create a new database:
createdb <new-db>Create three databases for the dev, staging and prod respectively by replacing with the appropriate names.
e.g
python_dev_db, python_staging_db, python_prod_db
- Grant all privileges on the database to the new user:
GRANT ALL PRIVILEGES ON DATABASE <new-db> TO <user-name>;Assuming username is pythonguru
GRANT ALL PRIVILEGES ON DATABASE python_dev_db TO pythonguru;Repeat this for staging and prod databases respectively.
Exit the PostgreSQL prompt:
\q- Home
- CI CD Pipeline Configuration for the Python Application
- Deployment with Systemd
- NGINX Reverse Proxy Setup and SSL Configuration
- Setting up the remote server and installing prerequisites
(Content not available in the provided HTML)
(Content not available in the provided HTML)