Setup Snipe-IT on Ubuntu.

Snipe-IT Open Source Asset Management

Installation Details

  • Infrastructure: AWS
  • AMI ID: RHEL-8.2.0_HVM-20200423-x86_64-0-Hourly2-GP2 (ami-07dfba995513840b5)
  • Instance type : t2.medium
  • Instance Hardware: 2vcpu , 4G Memory.

What is it Snipe-IT

Snipe-IT was made for IT asset management, to enable IT departments to track who has which laptop, when it was purchased, which software licenses and accessories are available, and so on.


Lets Start:

Update Ubuntu:

sudo apt update
sudo apt upgrade

Install Apache2 HTTP:

sudo apt install apache2 -y

To find out if Apache2 HTTP server is installed, simply open your web browser and type in the server’s IP or hostname.

When you see the page similar to the one below, then Apache2 is installed and working.

apache2 ubuntu install

Install PHP:

sudo apt install php -y
sudo apt install php7.2-mbstring php7.2-curl php7.2-mysql php7.2-ldap php7.2-zip php7.2-bcmath php7.2-xml php7.2-gd -y

Install MySQL:

sudo apt install mysql-server -y

Create the database:

sudo mysql -u root

You should now have the mysql prompt mysql>

Create the database and the user and grant permissions to the user.

mysql> create database snipeit;
mysql> create user snipe_user;
mysql> grant all on snipeit.* to 'snipe_user'@'localhost' identified by 'YOUR_DB_PASSWORD';
mysql> exit (to leave the mysql shell)
sudo apt install git vim -y

Download Snipe-IT into the web server directory:

sudo mkdir /var/www/html/snipe-it
sudo chown yourusername:yourusername /var/www/html/snipe-it

cd to the new directory and download

cd /var/www/html/snipe-it
git clone https://github.com/snipe/snipe-it .

Set up Snipe-IT config file:

Copy the .env.example file to a new .env file and open it in your text editor.

cp .env.example .env
vim .env

Make sure APP_ENV is set to production and APP_DEBUG is set to false

APP_ENV=production
APP_DEBUG=false

Setup APP_URL:

This is the url to your application, beginning with http:// or https:// (if you’re running Snipe-IT over SSL). This should not have a trailing slash, and you should not have public in the URL.Images and javascript will not load correctly if this is not set to EXACTLY the URL you access your Snipe-IT app from.

You can set APP_URL to an IP address for setup or testing and change it to another domain name later.

APP_URL=your.domain.name

Set the timezone. Use one of the PHP supported time zone strings from https://www.php.net/manual/en/timezones.php

APP_TIMEZONE='YOURTIMEZONE'

Set your language. Default is English (en). See https://snipe-it.readme.io/docs/configuration#section-setting-a-language:

APP_LOCALE=en

Fill in the database settings with the database name, database user name and password you created in the mysql setup step:

DB_DATABASE=snipeit
DB_USERNAME=snipe_user
DB_PASSWORD=YOUR_DB_PASSWORD

Install snipe-IT dependencies

Make sure you are still in the snipe-it directory. If you are following this guide it will be /var/www/html/snipe-it

cd /var/www/html/snipe-it

Snipe-IT uses a PHP dependency manager called Composer to manage its dependencies so install it and then install the dependencies: (This might take a few minutes)

curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --prefer-source

Generate your app key

php artisan key:generate

This will generate an encryption key and set APP_KEY in your .env file. Copy the key and save it in secure location.

Grant appropriate filesystem permissions so apache can access the files:

sudo chown -R yourusername:www-data /var/www/html/snipe-it

Now remove group write permission from the files. There’s no reason for apache to be able to write to all these files:

sudo chmod -R g-w /var/www/html/snipe-it

Now add back write permission for the areas we want Snipe-IT to be able to write to:

sudo chmod -R g+w /var/www/html/snipe-it/storage
sudo chmod -R g+w /var/www/html/snipe-it/public/uploads

Configure the server

Copy the default vhost file and open the copy in your text editor.

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/snipe-it.conf
sudo vim /etc/apache2/sites-available/snipe-it.conf

Edit the file to look like this:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port 
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/snipe-it/public

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ServerName 10.64.118.91

        <Directory /var/www/html/snipe-it/public>
                Allow From All
                AllowOverride All
                Options -Indexes
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Save the file and close your text editor

Disable the old default vhost and enable your new vhost

sudo a2dissite 000-default.conf
sudo a2ensite snipe-it.conf

Also enable mod_rewrite

sudo a2enmod rewrite
sudo systemctl reload apache2

And we finish! you can now point your web browser at the address of your web server.You should get the Snipe-IT Pre-Flight and your Pre-Flight check should be all green check mark.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.