Skip to content
Tech Master Tech Master

OneStopTechnical Forum

  • Books
  • AI
  • Networking
  • Windows
  • Linux
  • Cloud
  • Mac
  • Active Directory
  • Azure
  • Cloud
  • Exchange
  • M365
  • Server 2025
  • Storage
  • Vsphere
  • Website
  • Database
  • Security
  • Knowledge Base
  • VPN
Tech Master
Tech Master

OneStopTechnical Forum

Automate scripting for installing snipeiT on Ubutu Server

blog.payperitem.com, April 7, 2025

Sure! Here’s a Bash script that automates the installation of Snipe-IT on an Ubuntu Server. This script sets up:

  • Apache
  • MySQL/MariaDB
  • PHP
  • Composer
  • Git
  • Snipe-IT with necessary permissions and configuration

Let’s assume Ubuntu 20.04+ and a fresh server.


✅ Script: install_snipeit.sh

bash#!/bin/bash

# Exit on any error
set -e

# Define MySQL root password and Snipe-IT DB info
MYSQL_ROOT_PASSWORD="StrongRootPass123!"
SNIPEIT_DB="snipeit"
SNIPEIT_USER="snipeuser"
SNIPEIT_PASS="SnipeUserPass456!"

echo "Updating system..."
apt update && apt upgrade -y

echo "Installing required packages..."
apt install -y apache2 mariadb-server php php-mysql php-curl php-gd php-mbstring php-xml php-bcmath php-zip php-tokenizer unzip git curl composer

echo "Starting and securing MySQL..."
systemctl enable mariadb
systemctl start mariadb

mysql -u root <<MYSQL_SCRIPT
ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}';
FLUSH PRIVILEGES;
CREATE DATABASE ${SNIPEIT_DB};
CREATE USER '${SNIPEIT_USER}'@'localhost' IDENTIFIED BY '${SNIPEIT_PASS}';
GRANT ALL PRIVILEGES ON ${SNIPEIT_DB}.* TO '${SNIPEIT_USER}'@'localhost';
FLUSH PRIVILEGES;
MYSQL_SCRIPT

echo "Cloning Snipe-IT..."
mkdir -p /var/www
cd /var/www
git clone https://github.com/snipe/snipe-it snipeit
cd snipeit
cp .env.example .env

echo "Configuring .env..."
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=${SNIPEIT_DB}/" .env
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=${SNIPEIT_USER}/" .env
sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=${SNIPEIT_PASS}/" .env

echo "Running composer install..."
composer install --no-dev --prefer-source

echo "Setting permissions..."
chown -R www-data:www-data /var/www/snipeit
chmod -R 755 /var/www/snipeit

echo "Generating app key..."
php artisan key:generate

echo "Creating Apache config..."
cat <<EOF > /etc/apache2/sites-available/snipeit.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/snipeit/public
<Directory /var/www/snipeit/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/snipeit_error.log
CustomLog \${APACHE_LOG_DIR}/snipeit_access.log combined
</VirtualHost>
EOF

echo "Enabling Apache config..."
a2enmod rewrite
a2ensite snipeit
a2dissite 000-default
systemctl reload apache2

echo "Snipe-IT installation completed!"
echo "Access it at: http://<your-server-ip>/"

📝 Usage Instructions

  1. Save this script: bash nano install_snipeit.sh
  2. Paste the code, save, and make executable: bashCopyEditchmod +x install_snipeit.sh
  3. Run it: bashCopyEditsudo ./install_snipeit.sh

🔐 Security Tips

  • Change passwords (MYSQL_ROOT_PASSWORD, SNIPEIT_PASS) before running.
  • Optionally secure MariaDB (mysql_secure_installation).
  • Consider using HTTPS via Let’s Encrypt.

Download ScriptDownload

Cloud Networking OpenSource Server 2025 Website

Post navigation

Previous post
Next post

Related Posts

Download Windows and Office Configuration Support Matrix Oct 2022 PDF

April 13, 2025April 13, 2025
Read More

Deep insight knowledge of lansweeper

April 4, 2025April 4, 2025

Lansweeper is a popular network management and IT asset discovery tool used by organizations to manage their IT infrastructure more effectively. It provides capabilities for network scanning, asset management, reporting, and troubleshooting. Below is a deep dive into its functionalities, features, and best practices for deploying and utilizing Lansweeper in…

Read More

Updating ManageEngine ServiceDesk Plus (HA)

April 2, 2025April 3, 2025

Step 1: Pre-Update Preparations Step 2: Updating the Secondary Node Step 3: Updating the Primary Node Step 4: Restore Failover & Sync Final Checks ✅ Login works on both nodes✅ No database errors in logs✅ Load balancer distributes traffic correctly✅ Failover test succeeds

Read More

Recent Posts

  • List of AD Schema Versions
  • OldNewExplorer Free Download For Windows 11, 10, 8 and 7 [Latest Version]
  • How to Get the Classic (old) Context Menu on Windows 11
  • BitLocker Recovery Keys
  • Active Directory and Server hardening

Recent Comments

No comments to show.
June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« May    
Log in
©2025 Tech Master | WordPress Theme by SuperbThemes
  • Login
  • Sign Up
Forgot Password?
Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.
body::-webkit-scrollbar { width: 7px; } body::-webkit-scrollbar-track { border-radius: 10px; background: #f0f0f0; } body::-webkit-scrollbar-thumb { border-radius: 50px; background: #dfdbdb }