Snipe-IT is the Assets Resource-Manager with an additional GUI for admin task. You can use it to build up a database with an inventory for your company by example computer, software, printers, etc… It has simple functions to make the daily life for the administrators easier. A more complex is GLPI.
This application is dynamic and is directly connected to the users who can post requests to the technicians. An interface thus authorizes the latter with if required preventing the service of maintenance and indexing a problem encountered with one of the technical resources to which they have access.
This material is copyright, check LICENSE at the end of the document! and you can also watch the mckaygerhard’s video also at https://t.me/alpine_linux/1402
This document will not explain anything; you must to obey, as must be cos just works and works very well, please if you dont know check How to use this guide section before starts:
Warning: if you already have alpine running just foward to 0 - Environment part!
Those commands are for any distro, it will create a disk and runs a virtual machine to install Alpine Linux 3.20 as base system OS for SNIPE-IT setup.
You can use alpine 3.20, to 3.22, or edge… any alpine will work since 3.20 to install SNIPE-IT system. In this document we use 3.22 only.
Warning will need to change the php command name package at older versions
mkdir -p /home/general/VM/alpine322 && cd /home/general/VM/alpine322
qemu-img create -f raw computerint1alpine-vitualdisk1-file.raw 6G
wget -c -t8 --no-check-certificate http://dl-cdn.alpinelinux.org/alpine/v3.22/releases/x86_64/alpine-extended-3.22.0-x86_64.iso
/usr/bin/qemu-system-x86_64 -m 2048 -name "computerint1alpine322" \
-cpu host -machine q35 \
-device virtio-net,netdev=nd1 -netdev user,id=nd1,restrict=off,hostfwd=tcp::3222-:22,hostfwd=tcp::9080-:80,hostfwd=tcp::9443-:443 \
-device virtio-keyboard -device virtio-mouse -device virtio-tablet -device virtio-vga,max_outputs=1 \
-drive file=computerint1alpine-vitualdisk1-file.raw,format=raw \
-cdrom alpine-extended-3.22.0-x86_64.iso -boot order=cd,once=d,menu=off
setup-alpine
Then reboot and take care of the ip addrees if you are not using virtual machine
Do not miss or bypass any package or command, or glpi will silend fails, this first part will setup main and community repositories, later install dependencies for the installation and also core running php/web software, and at last will setup console font, please if you dont know check How to use this guide section, otherwise runs all of the following commands as root user:
cat > /etc/apk/repositories << EOF
http://dl-4.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-4.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
EOF
apk update
apk add openssl perl perl-net-ssleay perl-io-socket-ssl perl-io-tty \
perl-datetime perl-datetime-timezone perl-datetime-locale attr diffutils \
at dcron man-pages nano binutils coreutils readline shared-mime-info \
grep gawk sed attr dialog lsof less groff procps wget curl terminus-font \
file findutils gawk tree pciutils usbutils lshw tzdata tzdata-utils \
zip unzip p7zip xz tar cabextract cpio binutils lha gzip lz4 \
ethtool musl-locales musl-locales-lang arch-install-scripts util-linux \
docs iproute2-minimal psmisc net-tools lsof curl wget apkbuild-cpan
rc-update add consolefont boot
cat > /etc/hosts << EOF
127.0.0.1 provision.domino.ver provision localhost.localdomain localhost
::1 localhost localhost.localdomain
EOF
echo "provision.domino.ver" > /etc/hostname
Warning: execute all the commands before, if you dont know how to, check How to use this guide
Snipeit is a Web application that will need: a webserver, PHP and a database. All of these so continue as root user and runs all the following commands:
apk add sed apache2 apache2-utils apache2-error apache2-ssl apache2-ctl
mkdir -p /var/www/localhost/htdocs /var/log/apache2
sed -i -r 's#^Listen.*#Listen 80#g' /etc/apache2/httpd.conf
sed -i -r 's#^ServerTokens.*#ServerTokens Minimal#g' /etc/apache2/httpd.conf
sed -i -r 's#.*LoadModule.*modules/mod_alias.so.*#LoadModule alias_module modules/mod_alias.so#g' /etc/apache2/httpd.conf
sed -i -r 's#.*LoadModule.*modules/mod_rewrite.so.*#LoadModule rewrite_module modules/mod_rewrite.so#g' /etc/apache2/httpd.conf
chown -R apache:www-data /var/www/localhost/
chown -R apache:wheel /var/log/apache2
echo "it works" > /var/www/localhost/htdocs/index.html
rc-update add apache2 default
IP=$(ip a s | grep 'inet ' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0' | head -n1)
HN=$(hostname)
echo "$IP $HN" >> /etc/hosts
rc-service apache2 restart
Now setups php
apk add php83-opcache php83-openssl php83-json php83-bcmath php83-mbstring \
php83-bz2 php83-zip php83-tidy php83-calendar php83-intl php83-pspell \
php83-ctype php83-dev php83-dom php83-enchant php83-fileinfo php83-shmop \
php83-simplexml php83-dom php83-sysvmsg php83-sysvsem php83-sysvshm \
php83-tokenizer php83-xml php83-xmlreader php83-iconv \
php83-xmlwriter php83-xsl php83-xmlwriter php83-sodium \
php83-exif php83-gd php83-pcntl php83-mysqli php83-pdo php83-pdo_mysql \
php83-sockets php83-curl php83-pear php83-phar php83-session \
php83 php83-apache2 composer
sed -i -r 's|.*cgi.fix_pathinfo=.*|cgi.fix_pathinfo=1|g' /etc/php*/php.ini
sed -i -r 's#.*safe_mode =.*#safe_mode = Off#g' /etc/php*/php.ini
sed -i -r 's#.*expose_php =.*#expose_php = Off#g' /etc/php*/php.ini
sed -i -r 's#memory_limit =.*#memory_limit = 536M#g' /etc/php*/php.ini
sed -i -r 's#upload_max_filesize =.*#upload_max_filesize = 128M#g' /etc/php*/php.ini
sed -i -r 's#post_max_size =.*#post_max_size = 256M#g' /etc/php*/php.ini
sed -i -r 's#^file_uploads =.*#file_uploads = On#g' /etc/php*/php.ini
sed -i -r 's#^max_file_uploads =.*#max_file_uploads = 12#g' /etc/php*/php.ini
sed -i -r 's#^allow_url_fopen = .*#allow_url_fopen = On#g' /etc/php*/php.ini
sed -i -r 's#^.default_charset =.*#default_charset = "UTF-8"#g' /etc/php*/php.ini
sed -i -r 's#^.max_execution_time =.*#max_execution_time = 150#g' /etc/php*/php.ini
sed -i -r 's#^max_input_time =.*#max_input_time = 90#g' /etc/php*/php.ini
sed -i -r 's#^session.cookie_secure =.*#session.cookie_secure = on#g' /etc/php*/php.ini
sed -i -r 's#^session.cookie_samesite =.*#session.cookie_samesite = Lax#g' /etc/php*/php.ini
cat > /var/www/localhost/htdocs/index.php << EOF
<?php
phpinfo();
?>
EOF
Now confiuguration of the database
apk add tzdata mysql mysql-client mariadb-doc mariadb-server-utils
mysql_install_db --user=mysql --datadir=/var/lib/mysql
rc-service mariadb start
mysqladmin -u root password toor1
cat > /etc/my.cnf.d/mariadb-timezone.cnf << EOF
[mysqld]
default-time-zone = 'America/Caracas'
EOF
mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root -ptoor1 mysql
sed -i "s|.*max_allowed_packet\s*=.*|max_allowed_packet = 100M|g" /etc/mysql/my.cnf
sed -i "s|.*max_allowed_packet\s*=.*|max_allowed_packet = 100M|g" /etc/my.cnf.d/mariadb-server.cnf
sed -i "s|.*bind-address\s*=.*|bind-address=0.0.0.0|g" /etc/mysql/my.cnf
sed -i "s|.*bind-address\s*=.*|bind-address=0.0.0.0|g" /etc/my.cnf.d/mariadb-server.cnf
sed -i "s|.*skip-networking.*|#skip-networking|g" /etc/mysql/my.cnf
sed -i "s|.*skip-networking.*|#skip-networking|g" /etc/my.cnf.d/mariadb-server.cnf
rc-service mariadb restart
rc-update add mariadb
mkdir -p /usr/share/webapps/adminer
wget https://github.com/vrana/adminer/releases/download/v5.3.0/adminer-5.3.0.php -O /usr/share/webapps/adminer/adminer-5.3.php
rm -rf /usr/share/webapps/adminer/index.php
ln -s adminer-5.3.php /usr/share/webapps/adminer/index.php
cat > /etc/apache2/conf.d/adminer.conf << EOF
Alias /adminer /usr/share/webapps/adminer/
<Directory /usr/share/webapps/adminer/>
Require all granted
DirectoryIndex index.php
</Directory>
EOF
rc-service apache2 restart
SNIPEIT does not have a way to automate the installation in Alpine (Debian only), and neither a way to use a subdir for deploy in webserver, only domain based:
apk add git
mkdir -p /usr/share/webapps && rm -rf /usr/share/webapps/snipeit
git clone https://github.com/grokability/snipe-it /usr/share/webapps/snipeit
cat > /etc/apache2/conf.d/snipeit.conf << EOF
Alias /snipeit /usr/share/webapps/snipeit/public
<Directory /usr/share/webapps/snipeit/public>
Require all granted
AllowOverride All
Options +Indexes
</Directory>
EOF
cat > /usr/share/webapps/snipeit/public/.htaccess << EOF
RewriteEngine On
RewriteBase /snipeit
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/\$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
EOF
IP=$(ip a s | grep 'inet ' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0' | head -n1)
HN=$(hostname)
echo "$IP $HN" >> /etc/hosts
cp "/usr/share/webapps/snipeit/.env.example" "/usr/share/webapps/snipeit/.env"
sed -i 's#^APP_URL.*=.*#APP_URL=http://$IP/snipeit#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^LIVEWIRE_URL_PREFIX.*=.*#LIVEWIRE_URL_PREFIX=/snipeit#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^APP_TIMEZONE.*=.*#APP_TIMEZONE=America/Caracas#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^APP_LOCALE.*=.*#APP_LOCALE=es-ES#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^ALLOW_IFRAMING.*=.*#ALLOW_IFRAMING=true#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^REFERRER_POLICY.*=.*#REFERRER_POLICY=origin-when-cross-origin#g' "/usr/share/webapps/snipeit/.env"
chown -R apache:www-data /usr/share/webapps/snipeit
chown -R snipeit /usr/share/webapps/snipeit/storage
chown -R snipeit /usr/share/webapps/snipeit/public/uploads
chown -R snipeit /usr/share/webapps/snipeit/bootstrap/cache
rc-service apache2 restart
After runs last command, we need to run installer of database so continue as root user and runs following commands to setup database
mysql -u root -ptoor -e "CREATE DATABASE snipeit;"
mysql -u root -proot -e "CREATE USER 'snipeit_dbuser'@'%' IDENTIFIED BY 'snip.1';FLUSH PRIVILEGES;"
mysql -u root -proot -e "CREATE USER 'snipeit_dbuser'@'localhost' IDENTIFIED BY 'snip.1';FLUSH PRIVILEGES;"
mysql -u root -ptoor -e "GRANT ALL PRIVILEGES ON snipeit.* TO 'snipeit_dbuser';"
mysql -u root -ptoor -e "GRANT ALL PRIVILEGES ON snipeit.* TO 'snipeit_dbuser'@'localhost' WITH GRANT OPTION;"
mysql -u root -ptoor -e "GRANT SELECT ON mysql.time_zone_name TO 'snipeit_dbuser'@'localhost';"
cd /usr/share/webapps/snipeit
sed -i 's#^DB_HOST.*=.*#DB_HOST=localhost#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^DB_DATABASE.*=.*#DB_DATABASE=snipeit#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^DB_USERNAME.*=.*#DB_USERNAME=snipeit_dbuser#g' "/usr/share/webapps/snipeit/.env"
sed -i 's#^DB_PASSWORD.*=.*#DB_PASSWORD=snip.1#g' "/usr/share/webapps/snipeit/.env"
git config --global --add safe.directory /usr/share/webapps/snipeit
chown apache:root /var/www
su -s /bin/bash -l apache -c "composer install --no-dev --prefer-source --working-dir /usr/share/webapps/snipeit"
chown apache:www-data /usr/share/webapps/snipeit/vendor
chmod 777 /usr/share/webapps/snipeit/storage/framework/cache
chmod 775 /usr/share/webapps/snipeit/storage
su -s /bin/bash -l apache -c "php /usr/share/webapps/snipeit/artisan key:generate --force"
su -s /bin/bash -l apache -c "php /usr/share/webapps/snipeit/artisan migrate --force"
su -s /bin/bash -l apache -c "php /usr/share/webapps/snipeit/artisan cache:clear"
Now after that, you can access and finish setup using
The installation only covers web ui administration, but for full access apart of the web UI you will need ssh setup so runs the following commands to setup the SSH software on th server and then fix any extra parameters by example when to install extra modules of the system, so please if you dont know check How to use this guide section, otherwise runs all of the following commands as root user:
apk add doas bash shadow shadow-uidmap musl-locales musl-locales-lang \
e2fsprogs btrfs-progs exfat-utils f2fs-tools dosfstools xfsprogs jfsutils zfs \
acpi patch coreutils mdadm e2fsprogs-extra attr smartmontools doas-sudo-shim \
iproute2 netpbm poppler-utils libjpeg-turbo-utils perl-socket6 libqrencode-tools
cat > /etc/doas.d/apkgeneral.conf << EOF
permit general as root cmd apk
permit general as root cmd service
EOF
useradd -m -U -c "" -s /bin/bash -G wheel,input,disk,floppy,cdrom,dialout,audio,video,lp,netdev,games,users,ping,wheel general
for u in $(ls /home); do for g in disk lp floppy audio cdrom dialout video lp netdev games users ping wheel; do addgroup $u $g; done;done
echo "general:general.1" | chpasswd
sed -i -r 's|#PermitRootLogin.*|PermitRootLogin no|g' /etc/ssh/sshd_config
echo AllowUsers general >> /etc/ssh/sshd_config
service sshd restart
Now everything will be using the “general” user, so RUNS “su -l general” or LOGIN WITH general USER (same password so obvious), this user will have the power to install packages and also restart services as super user. Also will be from now the only user to get access using ssh to the machine.
This guide structure all the commands in blocks, each block its separated by a line spaced, so you must type each line as is.. and hit enter, so you noted that then you typed each separated clocks of commands, copy/type only blocks separated by an empty line, all new(next) lines are made by just enter. the terminal will detect if must execute or not.
This guide is for install process, many parts will need you understand minimal knowledge of linux.
This guide assumed you have a serial port allowed in the targeted computer, also its important you shuold understand the way of the configuration in this guide.
Warning Some Linux or/and Mac terminals have security cut/paste locks, so if you paste, the first line will be preceded by garbage, check always the first char of your paste.
##alpine_telegram_english
#alpine_linux_english
CC BY-NC-SA: the project allows reusers to distribute, remix, adapt, and build upon the material in any medium or format for noncommercial purposes only, and only so long as attribution is given to the creators involved. If you remix, adapt, or build upon the material, you must license the modified material under identical terms, includes the following elements:
For more information check the [alpine/copyright.md](../../alpine/copyright.md)