How to Install Snipe-IT on Ubuntu 16.04
Snipe-IT is a free and open source web application for IT asset management that provides a web-based interface for tracking licenses, accessories, consumables, and components. Snipe-IT comes with beautiful built-in email notifications for users and administrators. It is cross-platform and feature-rich web-based software built using the PHP framework Laravel. You can keep track of what you own, how something has been deployed, who is working with what desktop, and the details of every server in your data center using Snipe-IT.
Features:
Supports Windows, Linux and Mac operating system.
Supports multiple languages. So translates into several languages for easy localization.
Integrates with barcode scanners and QR code reader apps.
Supports two-factor authentication with Google Authenticator.
Integrates with LDAP and Active Directory.
Web-based software so it works on any device.
Add your own custom fields for additional asset attributes.
In this tutorial, I am going to explain how to install and configure Snipe-IT on an Alibaba Cloud Elastic Compute Service (ECS) instance with Ubuntu 16.04.
Requirements
A fresh Alibaba Cloud Ubuntu 16.04 instance with minimum 2GB of RAM.
A static IP address 192.168.0.103 configured to your server.
- A root password set up on the server.
Launch Alibaba Cloud ECS Instance
First, log in to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.
Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
Install LAMP
Snipe-IT requires Apache, MariaDB, and PHP on your system. First, install Apache and MariaDB with the following command:
apt-get install apache2 mariadb-server -y
Next, you will need to add the PHP repository to your system. You can add it with the following command:
apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php
Once the repository is installed, update the repository and install PHP with all the required libraries with the following command:
apt-get install apache2 libapache2-mod-php7.2 php7.2 php7.2-pdo php7.2-mbstring php7.2-tokenizer php7.2-curl php7.2-mysql php7.2-ldap php7.2-zip php7.2-fileinfo php7.2-gd php7.2-dom php7.2-mcrypt php7.2-bcmath -y
Once all the packages are installed, you will also modify the php.ini file:
nano /etc/php/7.2/apache2/php.ini
Make the following changes:
memory_limit = 256M
upload_max_filesize = 200M
max_execution_time = 360
date.timezone = Asia/Kolkata
Save and close the file. Then start Apache and MariaDB service and enable them to start on boot time with the following command:
systemctl start apache2
systemctl start mysql
systemctl enable apache2
systemctl enable mysql
Configure MariaDB
By default, MariaDB is not hardened, so you will need to secure it first. You can do this using the mysql_secure_installation script:
mysql_secure_installation
Output:
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Next, log in to the MariaDB shell:
mysql -u root -p
Enter your root password, then create a database and user for Snipe-IT:
MariaDB [(none)]> CREATE DATABASE snipeit_db character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON snipeit_db.* TO 'snipeit_user'@'localhost' IDENTIFIED BY 'password';
Next, flush the privileges and exit from the MariaDB shell with the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit
Download and Install Snipe-IT
First, you will need to download the latest version of Snipe-IT to your system. You can download it from the GIT repository with the following command:
cd /var/www/html/
git clone https://github.com/snipe/snipe-it snipe-it
Next, change the directory to snipe-it and copy the sample .env file:
cd /var/www/html/snipe-it
cp .env.example .env
Next, open the .env file and update the database details:
nano .env
Make the following changes:
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=snipeit_db
DB_USERNAME=snipeit_user
DB_PASSWORD=password
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
Save and close the file.
Next, you will need to install Composer to your system. Composer is a dependency manager for PHP. It is used to install dependencies required by PHP. You can install it by just running the following command:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Next, install all the dependencies required by PHP by running the following command:
composer install --no-dev --prefer-source
Once all the dependencies are installed, generate the "APP_Key" with the following command:
php artisan key:generate
Output:
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Application key [base64:Ui3UGJG6QXyb+ary9K34qdohTC63vD8cKx5uetPfjVU=] set successfully.
Next, populate MySQL with Snipe-IT's default database schema with the following command:
php artisan migrate
Output:
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Migration table created successfully.
Next, give proper permissions to the snipe-it directory:
chown -R www-data:www-data /var/www/html/snipe-it
chmod -R 755 /var/www/html/snipe-it
Configure Apache Web Server
Next, you will need to create an Apache virtual host file for Snipe-IT. You can create it with the following command:
nano /etc/apache2/sites-available/snipeit.conf
Add the following lines:
<VirtualHost *:80>
ServerAdmin webmaster@your-domain.com
<Directory /var/www/html/snipe-it/public>
Require all granted
AllowOverride All
</Directory>
DocumentRoot /var/www/html/snipe-it/public
ServerName your-domain.com
ErrorLog /var/log/apache2/snipeIT.error.log
CustomLog /var/log/apache2/snipeIT.access.log combined
</VirtualHost>
Save and close the file, then enable the Apache virtual host file with the following command:
a2ensite snipeit.conf
Next, enable mcrypt, mbstring, and rewrite module using the following command:
phpenmod mcrypt
phpenmod mbstring
a2enmod rewrite
Finally, restart Apache service to apply all the changes:
systemctl restart apache2
Access the Snipe-IT Web Installation Wizard
Open your web browser and type the URL http://your-domain.com. You should see the following page:
Make sure all the system requirements are correct. Then, click on the Create Database Table button. You should see the following page:
Next, click on the Create User page. You should see the following page:
Here, provide your Site name, Admin username, and password. Then click on the Next button. You should see the following page: