Manual Installation on LEMPP Stack (NGINX) Linux Server

Manual Installation on LEMPP Stack (NGINX) Linux Server

Posted on : 06 Dec, 2024    |    Last Update - 1 year ago   

How to Install the Web-Based Inventory System on a Linux Server (LEMPP Stack with NGINX)

This guide explains how to perform a fresh installation of the Web-Based Inventory System on a Linux server (Debian/Ubuntu) with LEMPP Stack (Linux, NGINX, MySQL/MariaDB, PHP). Ensure your server meets the following requirements:

  • PHP Version: 8.2
  • Required Extensions: fileinfo, gd, intl, mbstring, exif, mysqli, pdo_mysql, sodium
  • Database: MySQL or MariaDB

Step 1: Install Required Packages

Update the system and install LEMPP components:

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php8.2 libapache2-mod-php8.2 php8.2-cli php8.2-mysql php8.2-gd php8.2-intl php8.2-mbstring php8.2-exif php8.2-sodium -y

Step 2: Configure MySQL/MariaDB

Secure the MySQL installation and create the database for the application:

sudo mysql_secure_installation

# Log in to MySQL
sudo mysql -u root -p

# Create a new database and user
CREATE DATABASE inventory_db;
CREATE USER 'inventory_user'@'localhost' IDENTIFIED BY 'securepassword';
GRANT ALL PRIVILEGES ON inventory_db.* TO 'inventory_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Deploy the Application Files

Download and place the application in the NGINX web root:

wget https://github.com/YuukioFuyu/Inventaris-Barang/archive/refs/heads/main.zip
unzip main.zip
sudo mv Inventaris-Barang-main /var/www/inventory

Step 4: Set File Permissions

Ensure proper ownership and permissions for the web application:

sudo chown -R www-data:www-data /var/www/inventory
sudo chmod -R 755 /var/www/inventory

Step 5: Configure NGINX VirtualHost

Create a new configuration file for the application:

sudo nano /etc/nginx/sites-available/inventory

# Add the following content:
server {
    listen 80;
    server_name inventory.example.com;

    root /var/www/inventory;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; # Adjust for your PHP version
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(git|env|ht|svn|idea|vscode) {
        deny all;
    }
}

Enable the configuration and restart NGINX:

sudo ln -s /etc/nginx/sites-available/inventory /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Step 6: Import Database

Import the database schema into MySQL:

mysql -u inventory_user -p inventory_db < /var/www/inventory/database/inventory.sql

Step 7: Access the Application

Open your browser and navigate to http://inventory.example.com. Log in with the default credentials provided in the README file.


Cara Install Sistem Inventarisasi Barang Berbasis Web di Linux Server (LEMPP Stack dengan NGINX)

Panduan ini menjelaskan cara instalasi baru untuk Sistem Inventarisasi Barang Berbasis Web pada server Linux (Debian/Ubuntu) dengan LEMPP Stack (Linux, NGINX, MySQL/MariaDB, PHP). Pastikan server Anda memenuhi persyaratan berikut:

  • Versi PHP: 8.2
  • Ekstensi yang Dibutuhkan: fileinfo, gd, intl, mbstring, exif, mysqli, pdo_mysql, sodium
  • Database: MySQL atau MariaDB

Langkah 1: Instalasi Paket yang Dibutuhkan

Perbarui sistem dan instal komponen LEMPP:

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php8.2 libapache2-mod-php8.2 php8.2-cli php8.2-mysql php8.2-gd php8.2-intl php8.2-mbstring php8.2-exif php8.2-sodium -y

Langkah 2: Konfigurasi MySQL/MariaDB

Amankan instalasi MySQL dan buat database untuk aplikasi:

sudo mysql_secure_installation

# Masuk ke MySQL
sudo mysql -u root -p

# Buat database dan pengguna baru
CREATE DATABASE inventory_db;
CREATE USER 'inventory_user'@'localhost' IDENTIFIED BY 'securepassword';
GRANT ALL PRIVILEGES ON inventory_db.* TO 'inventory_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Langkah 3: Unggah File Aplikasi

Unduh dan letakkan aplikasi di root web NGINX:

wget https://github.com/YuukioFuyu/Inventaris-Barang/archive/refs/heads/main.zip
unzip main.zip
sudo mv Inventaris-Barang-main /var/www/inventory

Langkah 4: Atur Izin File

Pastikan kepemilikan dan izin file untuk aplikasi web:

sudo chown -R www-data:www-data /var/www/inventory
sudo chmod -R 755 /var/www/inventory

Langkah 5: Konfigurasi VirtualHost NGINX

Buat konfigurasi baru untuk aplikasi:

sudo nano /etc/nginx/sites-available/inventory

# Tambahkan konten berikut:
server {
    listen 80;
    server_name inventory.example.com;

    root /var/www/inventory;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; # Sesuaikan dengan versi PHP Anda
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(git|env|ht|svn|idea|vscode) {
        deny all;
    }
}

Aktifkan konfigurasi dan restart NGINX:

sudo ln -s /etc/nginx/sites-available/inventory /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Langkah 6: Impor Database

Impor skema database ke MySQL:

mysql -u inventory_user -p inventory_db < /var/www/inventory/database/inventory.sql

Langkah 7: Akses Aplikasi

Buka browser Anda dan akses http://inventory.example.com. Masuk dengan kredensial default yang tertera pada file README.

Still No Luck ? Contact via WhatsApp

Please do not delete the message template!

Open WhatsApp