2023/02/17
Check out the official requirements page here.
1. Install dependancies.
apt install apache2 apache2-doc mariadb-server mariadb-client libapache2-mod-php8.1 php8.1-{bcmath,cli,common,curl,gd,imagick,ldap,mbstring,mysql,opcache,readline,xml,zip}
2. Create a new unix user.
adduser snipeit --disabled-password
3. Use git clone to obtain Snipe-IT.
git clone https://github.com/snipe/snipe-it /var/www/snipe-it
4. Change ownership of Snipe-IT root.
chown -R snipeit:snipeit /var/www/snipe-it
1. Run the secure installation. Set a secure root password.
mysql_secure_installation
2. Login to MariaDB with the MariaDB root user we just created.
mysql -u root
3. Create DB user for Snipe-IT.
CREATE USER 'snipeit'@'localhost' IDENTIFIED BY 'secure-password-here';
4. Create a new DB for PartKeepr.
CREATE DATABASE SnipeIT CHARACTER SET UTF8;
5. Set privileges for new DB user.
GRANT ALL PRIVILEGES ON SnipeIT.* TO 'snipeit'@'localhost';
6. Flush privileges and exit.
FLUSH PRIVILEGES;
exit
1. Make sure you are in Snipe-IT's root directory.
cd /var/www/snipe-it
2. Copy the .env.example
file to a new .env
file.
cp .env.example .env
3. Edit the new .env
file.
# --------------------------------------------
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
APP_ENV=production <-- Should not be changed unless you are doing developement.
APP_DEBUG=false <-- Can be used for troubleshooting. Should NOT be left enabled permenantley.
APP_KEY=ChangeMe <-- This will be set later.
APP_URL=http://snipeit.mydomain.com <-- The URL used to access Snipe-IT server. (HTTP/HTTPS)
APP_TIMEZONE='America/Denver' <-- Set your timezone. Must a PHP supported timezone enclosed in single quotes.
APP_LOCALE=en
MAX_RESULTS=500
# --------------------------------------------
# REQUIRED: UPLOADED FILE STORAGE SETTINGS
# --------------------------------------------
PRIVATE_FILESYSTEM_DISK=local
PUBLIC_FILESYSTEM_DISK=local_public
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql <-- Must leave this as 'mysql' as this is the only supported DB type.
DB_HOST=127.0.0.1 <-- Whereever you are running the DB.
DB_DATABASE=SnipeIT <-- The name of the DB.
DB_USERNAME=snipeit <-- The DB user.
DB_PASSWORD=*DB-user-password* <-- The DB user's password.
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin' <-- This will be fine for most users.
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
# --------------------------------------------
# OPTIONAL: SSL DATABASE SETTINGS
# --------------------------------------------
DB_SSL=false
DB_SSL_IS_PAAS=false
DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null
# --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS <-- I'm not going to explain the mail settings.
# --------------------------------------------
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mydomain.com
MAIL_PORT=587
MAIL_USERNAME=myusername
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null
MAIL_FROM_ADDR=snipeit@mydomain.com
MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=snipeit@mydomain.com
MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment'
# --------------------------------------------
# REQUIRED: IMAGE LIBRARY
# This should be gd or imagick
# --------------------------------------------
IMAGE_LIB=gd
# --------------------------------------------
# OPTIONAL: BACKUP SETTINGS
# --------------------------------------------
MAIL_BACKUP_NOTIFICATION_DRIVER=null
MAIL_BACKUP_NOTIFICATION_ADDRESS=null
BACKUP_ENV=true
# --------------------------------------------
# OPTIONAL: SESSION SETTINGS
# --------------------------------------------
SESSION_LIFETIME=12000
EXPIRE_ON_CLOSE=false
ENCRYPT=false
COOKIE_NAME=snipeit_session
COOKIE_DOMAIN=lpcbroadband.net
SECURE_COOKIES=false
API_TOKEN_EXPIRATION_YEARS=15
# --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS
# --------------------------------------------
APP_TRUSTED_PROXIES=
ALLOW_IFRAMING=false
REFERRER_POLICY=same-origin
ENABLE_CSP=false
CORS_ALLOWED_ORIGINS=null
ENABLE_HSTS=false
# --------------------------------------------
# OPTIONAL: CACHE SETTINGS
# --------------------------------------------
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
CACHE_PREFIX=snipeit
# --------------------------------------------
# OPTIONAL: REDIS SETTINGS
# --------------------------------------------
REDIS_HOST=null
REDIS_PASSWORD=null
REDIS_PORT=null
# --------------------------------------------
# OPTIONAL: MEMCACHED SETTINGS
# --------------------------------------------
MEMCACHED_HOST=null
MEMCACHED_PORT=null
# --------------------------------------------
# OPTIONAL: PUBLIC S3 Settings
# --------------------------------------------
PUBLIC_AWS_SECRET_ACCESS_KEY=null
PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: PRIVATE S3 Settings
# --------------------------------------------
PRIVATE_AWS_ACCESS_KEY_ID=null
PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: LOGIN THROTTLING
# --------------------------------------------
LOGIN_MAX_ATTEMPTS=5
LOGIN_LOCKOUT_DURATION=60
RESET_PASSWORD_LINK_EXPIRES=900
# --------------------------------------------
# OPTIONAL: MISC
# --------------------------------------------
APP_LOG=single
APP_LOG_MAX_FILES=10
APP_LOCKED=false
APP_CIPHER=AES-256-CBC
APP_FORCE_TLS=false
GOOGLE_MAPS_API=
LDAP_MEM_LIM=500M
LDAP_TIME_LIM=600
IMPORT_TIME_LIMIT=600
IMPORT_MEMORY_LIMIT=500M
REPORT_TIME_LIMIT=12000
4. Add the snipeit
user to the web server's user group.
adduser snipeit www-data
5. Set ownership on ./public/uploads
chown -R snipeit storage /var/www/snipe-it/public/uploads
6. Set permissions
chmod -R 755 /var/www/snipe-it/storage
chmod -R 755 /var/www/snipe-it/public/uploads
We will be using Composer here. NEVER run Composer as root, it will break things that are difficult to revert.
1. We will install Composer locally, in the project directory - /var/www/snipe-it
sudo -u snipeit curl -sS https://getcomposer.org/installer | php
2. Run Composer to install dependancies.
sudo -u snipeit php composer.phar install --no-dev --prefer-source
If it complains about ‘not being up to date’, run:
sudo -u snipeit php composer.phar update
1. To generate the Application Key that we talk about during the Configuration.
php artisan key:generate
1. Enable required modules.
a2enmod rewrite
2. Create a new vhost for Snipe-IT
vim /etc/apache2/sites-available/snipe-it.conf
Use this configuration
<VirtualHost *:80>
<Directory /var/www/snipe-it/public>
Allow From All
AllowOverride All
Options -Indexes
</Directory>
ServerName snipe-it.mydomain.com
DocumentRoot /var/www/snipe-it/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerSignature Off
</VirtualHost>
3. Enable the new site, disable the default site.
a2ensite snipe-it.conf
a2dissite 000-default.conf
systemctl restart apache2.service
4. Change the entire snipe-it
root directory to the ownership of www-data
chown -R www-data:www-data /var/www/snipe-it
1. Navigate to http://[IP-or-Hostname-of-server]/setup
in your browser.