Install Snipe-IT on Ubuntu 22.04

This article is going to take you through how to Install Snipe-IT on Ubuntu 22.04. Snipe-IT is a Laravel-based free and open-source project. Snipe-IT was created for IT asset management, allowing IT departments to keep track of who has which laptop when it was bought, what software licenses and accessories are accessible, and so on.

How to Install Snipe-IT on Ubuntu 22.04

Snipe-IT is a PHP web application developed using the Laravel PHP framework. It runs on LAMP or LEMP stack, check out our article on how to Install LAMP Stack. In this example, we will use the LAMP stack to Install Snipe-IT on Ubuntu 22.04, make sure it’s installed on your system.

Install Snipe-IT on Ubuntu 22.04

  • Start by installing Snipe-IT PHP requirements, git and unzip using the command below.
sudo apt install php-{opcache,pdo,bcmath,bz2,calendar,ctype,exif,ffi,fileinfo,ftp,gd,iconv,intl,json,mbstring,mysqli,phar,posix,readline,shmop,sockets,sysvmsg,sysvsem,sysvshm,tokenizer,zip,curl,ldap} php-cli git unzip

Sample output

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'php7.4-opcache' instead of 'php-opcache'
Note, selecting 'php7.4-common' instead of 'php-pdo'
Note, selecting 'php7.4-common' instead of 'php-calendar'
Note, selecting 'php7.4-common' instead of 'php-ctype'
Note, selecting 'php7.4-common' instead of 'php-exif'
Note, selecting 'php7.4-common' instead of 'php-ffi'
Note, selecting 'php7.4-common' instead of 'php-fileinfo'
Note, selecting 'php7.4-common' instead of 'php-ftp'
Note, selecting 'php7.4-common' instead of 'php-iconv'
Note, selecting 'php7.4-mysql' instead of 'php-mysqli'
Note, selecting 'php7.4-common' instead of 'php-phar'
Note, selecting 'php7.4-common' instead of 'php-posix'
Note, selecting 'php7.4-common' instead of 'php-shmop'
Note, selecting 'php7.4-common' instead of 'php-sockets'
Note, selecting 'php7.4-common' instead of 'php-sysvmsg'
Note, selecting 'php7.4-common' instead of 'php-sysvsem'
Note, selecting 'php7.4-common' instead of 'php-sysvshm'
unzip is already the newest version (6.0-25ubuntu1).
unzip set to manually installed.
php7.4-cli is already the newest version (7.4.3-4ubuntu2.10).
php7.4-cli set to manually installed.
php7.4-common is already the newest version (7.4.3-4ubuntu2.10).
php7.4-common set to manually installed.
php7.4-mysql is already the newest version (7.4.3-4ubuntu2.10).
php7.4-mysql set to manually installed.
php7.4-opcache is already the newest version (7.4.3-4ubuntu2.10).
php7.4-opcache set to manually installed.
The following packages were automatically installed and are no longer required:
  coturn libevent-core-2.1-7 libevent-extra-2.1-7
  libevent-openssl-2.1-7 libevent-pthreads-2.1-7
  libfprint-2-tod1 libfwupdplugin1 libhiredis0.14
  libllvm9 libpq5 sqlite3
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  git-man liberror-perl libzip5 php-xml php7.4-bcmath
  php7.4-bz2 php7.4-curl php7.4-gd php7.4-intl
  php7.4-ldap php7.4-mbstring php7.4-xml php7.4-zip
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el
  git-email git-gui gitk gitweb git-cvs git-mediawiki
  git-svn
The following NEW packages will be installed:
  git git-man liberror-perl libzip5 php-bcmath php-bz2
  php-curl php-gd php-intl php-json php-ldap
  php-mbstring php-readline php-tokenizer php-xml
  php-zip php7.4-bcmath php7.4-bz2 php7.4-curl
  php7.4-gd php7.4-intl php7.4-ldap php7.4-mbstring
  php7.4-xml php7.4-zip
0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,296 kB of archives.
After this operation, 41.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git-man all 1:2.25.1-1ubuntu3.2 [884 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git amd64 1:2.25.1-1ubuntu3.2 [4,554 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 libzip5 amd64 1.5.1-0ubuntu1 [46.7 kB]

Install Composer on Ubuntu 22.04

  • Composer is required for managing PHP dependencies, install it using the following command.
curl -sS https://getcomposer.org/installer | php
  • Move the composer.phar executable using the command below to /usr/local/bin/ so that it can be run from anywhere as a system command.
sudo mv composer.phar /usr/local/bin/composer

Create Database for Snipe-IT

  • To create the Snipe-IT database, log in as a root user to your MySQL/MariaDB server using the command below.
sudo mysql -u root -p
  • Create a database and user using the following commands. Change database name, username and password according to your details.
CREATE DATABASE snipeitdb;
CREATE USER 'snipeuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON snipeitdb.* TO 'snipeuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Install Snipe-IT

  • Navigate to your web server’s root directory using the command below.
cd /var/www/
  • Next, clone the Snipe-IT repository and save the contents in the snipe-it directory using the following command.
sudo git clone https://github.com/snipe/snipe-it snipe-it
  • Go to the Snipe-IT directory created using the command below.
cd snipe-it
  • We need .env configuration file to set up the application details. Copy the example config file and rename it i.e. .env.example to .env using the following command.
sudo cp .env.example .env
  • Open the config file and enter your database info. Run the command below to open the configuration file.
sudo nano .env
  • Under basic app settings, enter your app URL and timezone e.g.
APP_URL=http://127.0.0.1
APP_TIMEZONE='Europe/London'
  • Then under database settings enter your database details e.g.
DB_DATABASE=snipeitdb
DB_USERNAME=snipeuser
DB_PASSWORD=password

Press ctrl+s to save the file then ctrl+x to close the file.

  • Set the ownership and permissions for the Snipe-IT data directory.
sudo chown -R www-data:www-data /var/www/snipe-it
sudo chmod -R 755 /var/www/snipe-it
  • Next update Snipe-IT dependencies.
composer update --no-plugins --no-scripts

Sample output

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 94 updates, 0 removals
  - Upgrading adldap2/adldap2 (v10.3.2 => v10.4.1)
  - Locking aws/aws-crt-php (v1.0.2)
  - Upgrading aws/aws-sdk-php (3.185.0 => 3.215.1)
  - Upgrading barryvdh/laravel-debugbar (v3.6.2 => v3.6.7)
  - Upgrading behat/gherkin (v4.8.0 => v4.9.0)
  - Upgrading codeception/codeception (4.1.21 => 4.1.31)
  - Upgrading codeception/lib-innerbrowser (1.5.0 => 1.5.1)
  - Upgrading codeception/module-rest (1.3.1 => 1.4.2)
  - Upgrading codeception/module-webdriver (1.2.1 => 1.4.0)
  - Upgrading doctrine/annotations (1.13.1 => 1.13.2)
  - Upgrading doctrine/cache (1.11.3 => 1.12.1)
  - Upgrading doctrine/collections (1.6.7 => 1.6.8)
  - Upgrading doctrine/dbal (2.13.2 => 2.13.8)
  - Upgrading doctrine/instantiator (1.4.0 => 1.4.1)
  - Upgrading doctrine/lexer (1.2.1 => 1.2.3)
  - Upgrading eduardokum/laravel-mail-auto-embed (1.0.5 => 1.0.7)
  - Upgrading filp/whoops (2.13.0 => 2.14.5)
  - Upgrading firebase/php-jwt (v5.4.0 => v5.5.1)
  - Upgrading guzzlehttp/promises (1.4.1 => 1.5.1)
  - Upgrading guzzlehttp/psr7 (1.8.2 => 1.8.5)
  - Upgrading intervention/image (2.5.1 => 2.7.1)
  - Upgrading justinrainbow/json-schema (5.2.10 => 5.2.11)
  - Upgrading laravel/framework (v6.20.29 => v6.20.44)
  - Upgrading laravel/helpers (v1.4.1 => v1.5.0)
  - Upgrading laravel/slack-notification-channel (v2.3.1 => v2.4.0)
  • After updating the composer, install all application dependencies using the following command.
composer install --no-dev --prefer-source --no-plugins --no-scripts
  • In the /var/www/snipe-it/.env the configuration file you created previously, generate the Laravel APP Key-value using the command below.
sudo php artisan key:generate

Sample output

**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Application key set successfully.

Create a Virtual Host File for Snipe-IT

  • Run the command below to create the Apache config file.
sudo nano /etc/apache2/sites-available/snipeit.example.com.conf

Paste the content below to the file and replace ServerName with your server IP or domain name.

 
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        <Directory /var/www/snipe-it/public>
       Require all granted
       AllowOverride All
          </Directory>
           DocumentRoot /var/www/snipe-it/public
           ServerName 192.168.171.134
          #Redirect permanent / https://snipeit.your-server-fqdn.com/
       ErrorLog /var/log/apache2/snipeIT.error.log
       CustomLog /var/log/apache2/access.log combined
</VirtualHost>

Save and close the file.

  • Enable the new configuration file.
sudo a2ensite snipeit.example.com.conf
  • Then enable rewrite.
sudo a2enmod rewrite
  • Restart Apache to activate the new configuration.
sudo systemctl restart apache2
  • Next, disable the default site using the command below.
sudo a2dissite 000-default.conf
  • Then reload Apache.
sudo service apache2 reload
  • Make a backup of the default site and then delete it. Navigate to available sites using the command below.
cd /etc/apache2/sites-available
  • Copy default site.
sudo cp 000-default.conf 000-default.confbackup
  • Delete default site.
sudo rm 000-default.conf
  • Reset associations using the command below.
sudo phpenmod mbstring
sudo a2enmod rewrite
  • Then restart Apache for changes to take effect.
sudo service apache2 restart

Snipe-IT Setup Wizard

  • Open your web browser and open the domain or server IP that was set e.g. http://server-IP. The setup will check if your server meets all the requirements as shown below.
  • When the next button is clicked, it will migrate the database.
  • In the third step, you are required to create an Admin user for the system.
  • After finishing the wizard installation, you will be taken to the dashboard as shown below.
  • Snipe-IT got a bunch of features, click the toggle button to navigate around the system.
  • You have reached the end of the article, Cheers! You have learned how to Install Snipe-IT on Ubuntu 22.04.

Read more on Snipe-IT Documentation

Other Tutorials

Install Velociraptor agents on Ubuntu 22.04

Install Velociraptor on Ubuntu 22.04

Install Node.js on Ubuntu 22.04

System administrator | Software Developer | DevOps

2 thoughts on “Install Snipe-IT on Ubuntu 22.04”

  1. First command runs with error:

    adm@srv-snipe:~$ sudo apt install php-{opcache,pdo,bcmath,bz2,calendar,ctype,exif,ffi,fileinfo,ftp,gd,iconv,intl,json,mbstring,mysqli,phar,posix,readline,shmop,sockets,sysvmsg,sysvsem,sysvshm,tokenizer,zip,curl,ldap} php7.4-cli git unzip
    Reading package lists… Done
    Building dependency tree… Done
    Reading state information… Done
    Hinweis: »php8.1-opcache« wird an Stelle von »php-opcache« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-pdo« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-calendar« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-ctype« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-exif« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-ffi« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-fileinfo« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-ftp« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-iconv« gewählt.
    Hinweis: »php8.1-mysql« wird an Stelle von »php-mysqli« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-phar« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-posix« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-shmop« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-sockets« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-sysvmsg« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-sysvsem« gewählt.
    Hinweis: »php8.1-common« wird an Stelle von »php-sysvshm« gewählt.
    E: Unable to locate package php7.4-cli
    E: Couldn’t find any package by glob ‘php7.4-cli’
    adm@srv-snipe:~$

    Reply

Leave a Comment