SnipeIT ( Ubuntu 22.04 )
安装SnipeIT资产管理平台
1. Update the server and install dependencies:
1 | sudo apt update -y && apt upgrade -y |
1.1 Install unzip dependency
1 | sudo apt-get install unzip git -y |
2. Install Apache Webserver
1 | sudo apt install apache2 -y |
In case, you enabled firewall and firewall block requests of the apache web server,
open a port in the firewall.
1 | sudo ufw allow 80/tcp |
Now, verify the Apache installation. Open browser and test default page.
1 | http://localhost |
Enable Apache’s mod_rewrite module. Snipe-IT requires this extension to rewrite URLs more cleanly.
1 | sudo a2enmod rewrite |
Restart your Apache web server to apply the changes.
1 | sudo systemctl restart apache2 |
3. Install MariaDB
1 | sudo apt install mariadb-server mariadb-client -y |
The default configuration of the MariaDB will not be secured. Let’s secured the installation using the following command:
1 | sudo mysql_secure_installation |
Once the script gets executed, it will ask multiple questions.
It will ask you to enter the current password for root (enter for none):
Then enter yes/y to the following security questions:
1 | Set a root password? [Y/n]: y |
4. Install PHP and PHP Composer
Here we are installing the default PHP version 8.1 and other modules for web deployments using the following command:
1 | sudo apt install php php-common php-bcmath php-bz2 php-intl php-gd php-mbstring php-mysql php-zip php-opcache php-intl php-json php-mysqli php-readline php-tokenizer php-curl php-ldap -y |
Install PHP Composer, which is a PHP dependency management tool to install and update libraries in your Snipe-IT.
Download the Composer installer.
1 | sudo curl -sS https://getcomposer.org/installer | php |
Move the composer.phar executable to /usr/local/bin/.
1 | sudo mv composer.phar /usr/local/bin/composer |
5. Create a Database
Create a database and database user for Snipe-IT. First login into MySQL/MariaDB as a root user.
1 | sudo mysql -u root -p |
Run following commands to perform this task:
1 | CREATE DATABASE snipe_it; |
Note: Replace snipe_it_user to your choice username and replace EXAMPLE_PASSWORD to you choice password.
6. Install Snipe-IT
Navigate to the root directory of your web server.
1 | cd /var/www/ |
Use git to clone the latest Snipe-IT repository from the https://github.com/snipe/snipe-it URL and copy the downloaded files to a snipe-it directory.
1 | sudo git clone https://github.com/snipe/snipe-it snipe-it |
Switch to the snipe-it directory.
1 | cd snipe-it |
Snipe-IT ships with a sample configuration file. Copy it to /var/www/snipe-it/.env.
1 | sudo cp /var/www/snipe-it/.env.example /var/www/snipe-it/.env |
Edit the configuration file.
1 | sudo nano /var/www/snipe-it/.env |
In the Snipe-IT configuration file, locate these settings.
1 | APP_URL=null |
Set APP_URL to your server’s Fully Qualified Domain Name, or it’s public IP address. If you use a time zone other than UTC, change the timezone to a PHP-supported timezone, and enclose it in single quotes.
1 | APP_URL=example.com |
Locate these settings.
1 | DB_DATABASE=null |
Change those values to the database information you set up in Step 3.
1 | DB_DATABASE=snipe_it |
Save and close the file.
Install the Snipe-IT dependencies with Composer. You’ll receive a warning not to run this as root on each command. It’s okay to continue as root for the Snipe-IT install, so type yes and hit ENTER.
1 | composer update — no-plugins — no-scripts |
Set the correct ownership and permission for the Snipe-IT data directory.
1 | sudo chown -R www-data:www-data /var/www/snipe-it |
Once the Composer finishes running, generate a Laravel APP_Key value in the /var/www/snipe-it/.env configuration file you created earlier. Type yes and hit ENTER when prompted to continue.
1 | sudo php artisan key:generate |
7. Create a Virtual Host File
First we’ll disable default Apacheconf file and create new vhost conf file.
Disable the default Apache configuration file.
1 | sudo a2dissite 000-default.conf |
Create a new Apache configuration file.
1 | sudo nano /etc/apache2/sites-available/snipe-it.conf |
Paste the information below and replace example.com with your server’s domain name or public IP address.
1 | <VirtualHost *:80> |
Save and exit the file
Enable your new configuration file
1 | sudo a2ensite snipe-it.conf |
Restart your Apache web server to apply the changes.
1 | sudo systemctl restart apache2 |
8. Run the Setup Wizard
Navigate to your browser and access the setup wizard using your server IP or domain name you have mentioned in vhost conf file.
More info : Documentation