TSF – Giải pháp IT toàn diện cho doanh nghiệp SMB | HCM

Installing Snipe-IT on Ubuntu Server is one of the best ways to build a powerful and open-source IT asset management system for your organization. Snipe-IT allows you to easily track hardware, software licenses, accessories, and users in one central dashboard. In this step-by-step guide, you’ll learn how to install all the necessary components — Apache or Nginx, PHP, MySQL/MariaDB, and Composer — to run Snipe-IT smoothly on Ubuntu. We’ll also cover how to configure environment variables, set file permissions, and complete the web-based setup. This process helps ensure a secure and stable installation suitable for both small businesses and enterprise environments. Whether you’re using Ubuntu Server 20.04 or 22.04, the commands and configuration steps remain the same. By the end of this guide, you’ll have a fully functional Snipe-IT asset management platform ready for production use. Perfect for IT administrators and sysadmins looking for an open-source IT inventory solution.

Step 1: Environment Setup

#1: Update System

sudo apt update && sudo apt upgrade -y

#2: Install Apache, PHP and required extensions

sudo apt install apache2 -y

sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-mysql \
php-common php-zip php-gd php-tokenizer unzip curl git -y

Step 2: Install MariaDB (or MySQL)

#Install MariaDB
sudo apt install mariadb-server mariadb-client -y

#Enable mariaDB service
sudo systemctl enable mariadb
sudo systemctl start mariadb

#Configure MySQL security. Create SQL administrator root password
sudo mysql_secure_installation
enter for none

Step 3: Create database for SnipeIT

#Enter MariaDB (MySQL) shell interface with command and enter root password created above
sudo mysql -u root -p

#Create database, user, grant permission to database administrator user (Ex: user: snipeuser pass: Abc@1234)
CREATE DATABASE snipeit;
CREATE USER ‘snipeuser’@’localhost’ IDENTIFIED BY ‘Abc@1234’;
GRANT ALL PRIVILEGES ON snipeit.* TO ‘snipeuser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;

Step 4: Install Composer (PHP package manager)

cd ~
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Step 5: Download Snipe-IT source

#Official link: https://snipeitapp.com/download .Click to select version

cd /var/www/
sudo wget https://github.com/grokability/snipe-it/archive/refs/tags/v8.1.15.tar.gz

#Extract the file
sudo tar -xzf v8.1.15.tar.gz

#Check and Rename the snipe folder to snipe-it
sudo mv snipe-it-8.1.15 snipe-it

#Change owner and copy the .env.excample file to .env
sudo chown -R www-data:www-data snipe-it
cd snipe-it
sudo cp .env.example .env

Step 6: Configure .env file

sudo nano .env

#Edit the following lines
APP_URL=http://192.168.16.208

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=snipeit
DB_USERNAME=snipeuser
DB_PASSWORD=Abc@1234

Step 7: Install PHP libraries using Composer

#Set secure for /var/www/snipe-it

git config –global –add secure.directory /var/www/snipe-it

#Upgrade PHP (if using version 8.1). Latest Snipe-IT (Laravel 11) requires PHP 8.2 or higher
#1: Add PPA containing new PHP
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update

#2: Install PHP 8.2
sudo apt install php8.2 php8.2-cli php8.2-mysql php8.2-mbstring php8.2-xml \
php8.2-bcmath php8.2-curl php8.2-zip php8.2-gd php8.2-common php8.2-tokenizer -y

#3: Set PHP 8.2 as default
sudo update-alternatives –install /usr/bin/php php /usr/bin/php8.2 1
sudo update-alternatives –config php

#Select PHP 8.2 from the list displayed.

#4: Install additional PHP 8.2 module for Apache:
sudo apt install libapache2-mod-php8.2 -y
sudo a2dismod php8.1
sudo a2enmod php8.2
sudo systemctl restart apache2

#5: Check again
php -v

#Install composer. Grant permissions to current user (using user bao)
sudo chown -R bao:www-data /var/www/snipe-it
sudo chmod -R 755 /var/www/snipe-it
cd /var/www/snipe-it
composer install –no-dev –prefer-source
#takes about 10-20 minutes

Step 8: Set up application key and migrate database

cd /var/www/snipe-it/
php artisan key:generate
php artisan migrate:fresh

Step 9: Create admin user to manage Web UI

php artisan snipeit:create-admin \
–email=”admin@example.com” \
–first_name=”Admin” \
–last_name=”User” \
–username=”admin” \
–password=”Abc#1234″

Step 10: Configure Apache Virtual Host

#Create configuration file:
sudo nano /etc/apache2/sites-available/snipeit.conf

#Add content
<VirtualHost *:80>
ServerName http://192.168.16.208
DocumentRoot /var/www/snipe-it/public

<Directory /var/www/snipe-it/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/snipeit_error.log
CustomLog ${APACHE_LOG_DIR}/snipeit_access.log combined
</VirtualHost>

#Enable configuration and mod_rewrite:
sudo a2ensite snipeit.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

#Assign write permissions to Snipe-IT in folders
sudo chown -R www-data:www-data /var/www/snipe-it/storage /var/www/snipe-it/bootstrap/cache
sudo chmod -R 775 /var/www/snipe-it/storage /var/www/snipe-it/bootstrap/cache

Step 11: Configure web UI

Login to the IP address to proceed with setup.