How to Install Saleor on Debian Latest

Saleor is a free and open-source e-commerce platform, built on Python and Django. It offers a customizable and scalable solution for online merchants. In this tutorial, we will explore the steps to install Saleor on Debian Latest in detail.

Prerequisites

Step 1: Install Required Packages

Before starting with the installation of Saleor, we need to install some packages that are required for its dependencies.

sudo apt update
sudo apt install -y nginx libpq-dev python-dev python3-dev python3-venv python3-pip nodejs npm build-essential git

Step 2: Install and Configure PostgreSQL

We need to install and configure PostgreSQL, which is used as a database for Saleor.

sudo apt install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql

Next, we need to create a new PostgreSQL user and database for Saleor.

sudo -u postgres createuser -P saleoruser
sudo -u postgres createdb -O saleoruser saleor

Step 3: Install Saleor

We can install Saleor using pip or by cloning the GitHub repository. In this tutorial, we will go with the pip installation.

python3 -m venv saleor
cd saleor
source bin/activate
pip install wheel
pip install saleor

Step 4: Configure Saleor

Next, we need to configure Saleor by creating a configuration file and defining environment variables.

cp $(python -m site --user-base)/lib/python*/site-packages/saleor/conf/saleor.yaml{.dist,}
nano saleor.yaml

Update the values of the following variables based on your configurations:

DATABASE_URL: 'postgis:///saleor'
ALLOWED_HOSTS: ['your_domain', 'localhost']
SECRET_KEY: 'your_secret_key'

Save the changes and exit the editor.

Step 5: Migrate the Database

We need to migrate the database schema to create the tables used by Saleor.

DEBUG=True saleor migrate

Step 6: Create a Superuser

We need to create a superuser account to manage the Saleor e-commerce platform. Run the following command and enter the required information.

saleor createsuperuser

Step 7: Configure Nginx

We need to configure the Nginx server to serve Saleor.

sudo nano /etc/nginx/sites-available/saleor.conf

Add the following configuration and replace the your_domain with your domain name.

server {
    listen 80;
    server_name your_domain;
    server_tokens off;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 600s;
        proxy_request_buffering off;
    }

    location /media/ {
        alias /path/to/saleor/media/;
        expires 1d;
    }

    location /static/ {
        alias /path/to/saleor/static/;
        expires 1d;
    }

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always;
}

Save the file and exit the editor.

Next, create a symbolic link of the Nginx configuration file in the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/saleor.conf /etc/nginx/sites-enabled/saleor.conf

Finally, restart the Nginx server using the following command.

sudo systemctl restart nginx

Step 8: Run Saleor Server

We can run the Saleor server using the following command.

saleor runserver

Alternatively, we can use Gunicorn to run the server.

gunicorn saleor.wsgi:application --bind 127.0.0.1:8000

Conclusion

In this tutorial, we installed Saleor on Debian Latest, configured PostgreSQL, and Nginx. We also explored the steps to migrate the database schema, create a superuser, and run the Saleor server. Now, you can start exploring Saleor and customize it based on your requirements.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!