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

ZFS and Partitions

March 31, 2025April 2, 2025

1. ZFS and Partitions 2. Using Partitions with ZFS 3. Why Whole Disks Are Preferred? Would you like help setting up ZFS with a specific partitioning scheme? 4o You said: setting up ZFS with a specific partitioning scheme ChatGPT said: If you want to set up ZFS with a specific…

Read More

Snipe-IT is an open-source IT asset management system

April 3, 2025April 3, 2025

Snipe-IT is an open-source IT asset management system that runs on a LAMP/LEMP stack. Below are the steps to install Snipe-IT on Ubuntu (22.04 or later). Step 1: Update and Install Dependencies bashsudo apt update && sudo apt upgrade -ysudo apt install -y apache2 mariadb-server php php-cli php-mbstring php-xml php-bcmath…

Read More

Configure Radius Server

April 11, 2025April 11, 2025

Configuring a Windows RADIUS Server (typically via NPS – Network Policy Server) in a deep and secure way involves more than just installing the role and creating a basic policy. You’ll want to cover advanced aspects like: 🔧 1. NPS (RADIUS) Server Installation and Registration 🔐 2. Secure RADIUS with…

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 }