# Roll Your Own Asset Management System with Snipe-IT

## What is Snipe-IT?

Snipe-IT is a Free Open Source (FOSS) project built on Laravel. 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. - https://snipe-it.readme.io/docs

## Installation

1. Log into the Linux device
2. Run the following commands in a terminal window:
   # update software respositories
   sudo apt update
   # install available software updates
   sudo apt upgrade -y
   # install prerequisites
   sudo apt install git openssl curl wget zip composer -y
   # install Apache HTTPD and MySQL
   sudo apt install apache2 mariadb-server mariadb-client -y
   # install PHP components
   sudo apt install php7.3 libapache2-mod-php7.3 php7.3-curl php7.3-tokenizer php7.3-ldap php7.3-cli php7.3-json php7.3-gd php7.3-mbstring php7.3-mysql php7.3-xml php7.3-zip php7.3-bcmath -y
   # configure the MySQL database
   sudo su
   mysql_secure_installation
3. Press Enter to login as root
4. Type Y and press Enter to set a root password, type the password twice to confirm
5. Type Y and press Enter to remove anonymous users
6. Type Y and press Enter to disallow root login remotely
7. Type Y and press Enter to remove the test database
8. Type Y and press Enter to reload privilege tables
9. Run the following command to login into MySQL:
   mysql -u root -p
10. Authenticate with the root password set earlier
11. Run the following commands to create the Snipe-IT database and database user
    CREATE DATABASE snipe_it;
    GRANT ALL ON snipe_it.* to 'snipe_it_rw'@'localhost' IDENTIFIED BY '$nip3-IT!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
12. Continue with the following commands:
    # clone snipe-it from github
    sudo git clone https://github.com/snipe/snipe-it /var/www/snipe-it
    # create a copy of the sample .env file
    sudo cp /var/www/snipe-it/.env.example /var/www/snipe-it/.env
    # edit the .env file
    sudo nano /var/www/snipe-it/.env
13. Edit the following environment variables as needed

    APP_ENV=production
    APP_DEBUG=false
    APP_KEY=SomethingSecure
    APP_URL=http://debian/snipe_it
    APP_TIMEZONE='America/New_York'
    APP_LOCALE=en
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_DATABASE=snipe_it
    DB_USERNAME=snipe_it_rw
    DB_PASSWORD=$nip3-IT!
    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.i12bretro.local
    MAIL_PORT=25
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null
    MAIL_FROM_ADDR=snipe-it@i12bretro.local
    MAIL_FROM_NAME='Snipe-IT'
    MAIL_REPLYTO_ADDR=snipe-it@i12bretro.local
    MAIL_REPLYTO_NAME='Snipe-IT'
    MAIL_AUTO_EMBED_METHOD='attachment'

14. Press CTRL+O, Enter, CTRL+X to write the changes to .env
15. Continue with the following commands:
    # set the owner of the snipe-it directory
    sudo chown -R www-data:www-data /var/www/snipe-it
    # setup composer working directory
    sudo mkdir /var/www/.composer
    sudo chown -R www-data:www-data /var/www/.composer
    cd /var/www/snipe-it
    # install dependencies with composer
    sudo -u www-data composer install --no-dev --prefer-source
    # generate app key, type yes to confirm generating a new key
    sudo php artisan key:generate
    # create snipe-it apache configuration
    sudo nano /etc/apache2/sites-available/snipe-it.conf
16. Paste the following configuration into snipe-it.conf

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

17. Press CTRL+O, Enter, CTRL+X to write the changes to snipe-it.conf
18. Run the following command to enable the snipe-it site
    # enable rewrite module
    sudo a2enmod rewrite
    # enable the snipe-it site
    sudo a2ensite snipe-it
    # restart the apache2 service
    sudo systemctl restart apache2

## Snipe-IT Web Installer

1. Open a web browser and navigate to http://DNSorIP/snipe-it
2. Review the Pre-Flight Checks summary > Click the Next: Create Database Tables button
3. Once the database tables are created, Click the Next: Create User button
4. Create a user by inputting a site name, first name, last name, email address, username and password > Click the Next: Save User button
5. Welcome to Snipe-IT

Source: https://snipe-it.readme.io/docs/installation