Installing OSPoS on Nginx

Installing OSPoS on Nginx

Learn how to install Open Source Point of Sale (OSPoS) on Nginx for a fast and efficient retail management system. Follow our step-by-step guide to set up and optimize OSPoS on your server

Posted by Teddy Mutuma, Tue Mar 04 2025 | App Hosting

This guide details the process of installing OSPoS—an open-source point-of-sale system, on a server running Nginx. The instructions assume you have a LEMP stack (Linux, Nginx, MySQL, PHP-FPM) in place, along with the necessary PHP extensions.

Prerequisites.

Before starting, ensure that your server has:

  • Server Environment:

    • Ubuntu (or another Linux distribution) with Nginx, PHP-FPM, and MySQL installed.
    • For a smoother setup, consider learning how to install Ubuntu and using control panels like aapanel.
  • PHP Extensions:

    • php-gd
    • php-bcmath
    • php-intl
    • php-openssl
    • php-mbstring
    • php-curl
    • php-xml

Make sure these extensions are installed and enabled.

Step 1: Download OSPoS

Download the OSPoS codebase from GitHub. You can either clone the repository or download the files directly:

  • Clone the Repository:

    git clone https://github.com/opensourcepos/opensourcepos.git

  • Alternative Download:
    You can also download the compressed files from GitHub and then upload them to your server.

Step 2: Configure the Database

OSPoS requires a MySQL database for data storage:

  1. Create a Database:
    Log into your MySQL server and create a new database along with a dedicated user having the appropriate permissions.

  2. Update the Configuration File:
    Open the file application/config/database.php in the OSPoS folder and update it with your new database credentials.

  3. Import the Database:
    Locate the database file in the database folder within the OSPoS package and import it into your newly created database.


    Step 3: Configure Nginx

    To serve OSPoS through Nginx, set up a new server block that points to the public folder of the OSPoS installation.

    1. Create a Server Block:
      Create a new configuration file (e.g., in /etc/nginx/sites-available/) and define your server block.

    2. Set the Root Directory:
      Configure the root directive to point to the public folder inside your OSPoS installation.

    3. Configure PHP-FPM:
      Set up Nginx to process PHP files through PHP-FPM.

    4. Handle URL Rewriting:
      Enable clean URLs using rewrite rules.

    Here’s an example configuration:

    server { listen 80; server_name your_domain.com;

    root /path/to/opensourcepos/public;

    index index.php index.html index.htm;

    location / { rewrite ^/(.*)$ /public/$1 permanent; }

    `location / {
         try_files $uri $uri/ /public/index.php?$args;
    }
    
    

    location ~ .php$ { fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;

    }
    }
    
    


    Important:

    • Replace your_domain.com with your actual domain name.
    • Adjust the root path and the fastcgi_pass socket path to match your server’s configuration.

    Step 4: Restart Nginx and PHP-FPM

    Apply your configuration changes by restarting both services:

    sudo systemctl restart nginx

    sudo systemctl restart php7.4-fpm

    Final Thoughts

    Once completed, your OSPoS installation should be accessible via your configured domain. This setup ensures that your point-of-sale system operates on a robust and secure LEMP environment. Always remember to maintain your server by applying updates and securing your services.

    Happy deploying!

    you can watch a video here


    Comments

    Please log in or sign up before commenting.