Installing Snipe-IT on CentOS involves setting up a robust LAMP (Linux, Apache, MariaDB, PHP) stack, configuring system-level settings, and then deploying the Snipe-IT application. This guide walks you through the comprehensive process for a successful installation, ensuring all dependencies and configurations are handled properly.
How to Install Snipe-IT on CentOS
To install Snipe-IT on CentOS, you'll first prepare your server with necessary prerequisites, including a web server, database, and PHP, then proceed with the Snipe-IT specific installation script, followed by crucial configuration steps like enabling HTTPS and performing data migration if applicable.
1. Initial Server Setup and Prerequisites
Before installing Snipe-IT, ensure your CentOS system is updated and has the necessary tools and services.
Update System and Install EPEL Release
It's always a good practice to start with an updated system. The EPEL (Extra Packages for Enterprise Linux) repository provides additional packages, including some that Snipe-IT or its dependencies might need, like Certbot.
sudo yum update -y
sudo yum install epel-release -y
sudo yum upgrade -y # For CentOS 7
sudo dnf upgrade -y # For CentOS 8+
Configure YUM Proxy (If Applicable)
If your CentOS server is behind a corporate proxy, you must configure yum
to use it. This ensures that package installations and updates can connect to the repositories.
Edit the yum
configuration file:
sudo vi /etc/yum.conf
Add the following lines at the end of the file, replacing proxy.yourcompany.com:port
with your actual proxy address and port:
proxy=http://proxy.yourcompany.com:port
proxy_username=your_username # Optional, if your proxy requires authentication
proxy_password=your_password # Optional
Save and exit the file.
Install LAMP Stack Components
Snipe-IT requires a web server (Apache is commonly used), a database (MariaDB is recommended), and PHP with several extensions.
-
Install Apache HTTP Server:
sudo yum install httpd -y sudo systemctl start httpd sudo systemctl enable httpd
-
Install MariaDB Database Server:
sudo yum install mariadb-server mariadb -y sudo systemctl start mariadb sudo systemctl enable mariadb sudo mysql_secure_installation # Follow prompts to set root password and secure the installation
-
Install PHP and Required Extensions:
Snipe-IT requires a specific PHP version (check the official Snipe-IT documentation for the latest requirements). For CentOS 7, you might need to enable theremi-php74
(or desired version) repository. For CentOS 8,dnf
handles modular repositories better.For CentOS 7 (using Remi repository for modern PHP):
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y sudo yum-config-manager --enable remi-php74 # Or remi-php80, remi-php81, etc. sudo yum install php php-cli php-fpm php-mysqlnd php-gd php-ldap php-mbstring php-xml php-bcmath php-json php-zip php-pdo php-curl php-intl php-dom php-fileinfo php-tokenizer -y
For CentOS 8 (using AppStream):
sudo dnf module enable php:7.4 # Or php:8.0, php:8.1, etc. sudo dnf install php php-cli php-fpm php-mysqlnd php-gd php-ldap php-mbstring php-xml php-bcmath php-json php-zip php-pdo php-curl php-intl php-dom php-fileinfo php-tokenizer -y
After installation, restart Apache:
sudo systemctl restart httpd
Configure Firewall (Firewalld)
Allow HTTP and HTTPS traffic through your firewall.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Create a Database for Snipe-IT
Log in to MariaDB as root and create a database and a user for Snipe-IT. Replace snipeit_db
, snipeit_user
, and your_strong_password
with your desired values.
sudo mysql -u root -p
CREATE DATABASE snipeit_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'snipeit_user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON snipeit_db.* TO 'snipeit_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
2. Install Snipe-IT and Dependencies from Script
Snipe-IT provides an official installation script that simplifies the process of downloading the application and its Composer dependencies.
Download the Install Script
You can download the Snipe-IT install script directly from their GitHub repository. Navigate to the /var/www/
directory where web applications are typically hosted.
cd /var/www/
sudo git clone https://github.com/snipe/snipe-it snipeit
cd snipeit
Run the Snipe-IT Installation Script
The install.sh
script will guide you through the process, prompting for database details and other configurations. Make sure the script is executable.
sudo chmod +x install.sh
sudo ./install.sh
Follow the on-screen prompts. When prompted for database details, use the snipeit_db
, snipeit_user
, and your_strong_password
you created earlier. The script will also generate your application key.
Configure Directory Permissions
Proper file permissions are crucial for Snipe-IT to function correctly and securely. The web server user (usually apache
on CentOS) needs ownership and write access to specific directories.
sudo chown -R apache:apache /var/www/snipeit
sudo chmod -R 755 /var/www/snipeit
sudo chmod -R 755 /var/www/snipeit/storage
sudo chmod -R 755 /var/www/snipeit/public/uploads
sudo chcon -R -t httpd_sys_rw_content_t /var/www/snipeit/storage
sudo chcon -R -t httpd_sys_rw_content_t /var/www/snipeit/public/uploads
These chcon
commands are for SELinux. If you have SELinux enabled, they are necessary.
Configure Apache Virtual Host
Create an Apache virtual host configuration file for Snipe-IT.
sudo vi /etc/httpd/conf.d/snipeit.conf
Add the following content, replacing your_domain.com
with your actual domain or server IP address:
<VirtualHost *:80>
ServerName your_domain.com
DocumentRoot /var/www/snipeit/public
<Directory /var/www/snipeit/public>
AllowOverride All
Order Allow,Deny
Allow from All
Require all granted
</Directory>
ErrorLog /var/log/httpd/snipeit_error.log
CustomLog /var/log/httpd/snipeit_access.log combined
</VirtualHost>
Save and exit. Then, restart Apache:
sudo systemctl restart httpd
3. Finalizing Snipe-IT Configuration
After the basic installation, access Snipe-IT via your web browser (e.g., http://your_domain.com
or http://your_server_ip
). You should be guided through the final web-based setup to create your administrator account.
Set Up Cron Job
Snipe-IT requires a cron job to handle scheduled tasks like email notifications, backups, and various maintenance tasks.
sudo crontab -e
Add the following line at the end of the file:
* * * * * /usr/bin/php /var/www/snipeit/artisan schedule:run >> /dev/null 2>&1
This cron job runs every minute, executing Snipe-IT's scheduled tasks.
4. Enable HTTPS (Recommended)
Securing your Snipe-IT instance with HTTPS is crucial for protecting sensitive asset data. This involves obtaining an SSL certificate and configuring Apache.
Get Certificate from Your Certificate Authority
You can obtain free SSL/TLS certificates from Let's Encrypt using Certbot.
-
Install Certbot:
sudo yum install certbot python-certbot-apache -y # For CentOS 7 sudo dnf install certbot python3-certbot-apache -y # For CentOS 8+
-
Obtain and Install Certificate:
sudo certbot --apache -d your_domain.com
Follow the prompts. Certbot will automatically configure Apache for HTTPS and set up automatic renewal.
-
Verify Apache Configuration:
Certbot usually creates a newyour_domain.com-le-ssl.conf
file in/etc/httpd/conf.d/
and configures it for HTTPS.
Restart Apache to ensure changes take effect:sudo systemctl restart httpd
Now, try accessing your Snipe-IT instance using
https://your_domain.com
.
5. Update Snipe-IT
Regularly updating Snipe-IT is important for security patches, bug fixes, and new features.
cd /var/www/snipeit
sudo php artisan down # Put Snipe-IT into maintenance mode
sudo git pull # Pull the latest code from the repository
sudo composer install --no-dev --prefer-source # Update PHP dependencies
sudo php artisan migrate # Run database migrations
sudo php artisan config:clear # Clear configuration cache
sudo php artisan view:clear # Clear view cache
sudo php artisan cache:clear # Clear application cache
sudo php artisan up # Bring Snipe-IT out of maintenance mode
Always back up your database and files before performing a major update.
6. Migrate Production Data (If Applicable)
If you are migrating from an existing Snipe-IT installation or another asset management system, this step involves importing your existing asset data.
-
From another Snipe-IT instance:
- Perform a database backup of your old instance.
- Restore the database backup to your new MariaDB server (
snipeit_db
). - Copy the
/var/www/snipeit/public/uploads
directory from your old server to the new one. - Ensure your
.env
file reflects the correct application key and database credentials.
-
From a different system:
- Snipe-IT offers CSV import functionality for assets, users, and other data. Prepare your data in CSV format according to Snipe-IT's import templates.
- Navigate to People > Import or Assets > Import within the Snipe-IT web interface to upload your CSV files.
Summary of Key Steps
The table below provides a concise overview of the critical installation and configuration tasks:
Step | Description | Key Commands/Actions |
---|---|---|
Initial Setup | Update OS, configure proxy, install LAMP stack. | sudo yum update , vi /etc/yum.conf , sudo yum install httpd mariadb-server php... |
Database Creation | Set up Snipe-IT's dedicated database and user. | CREATE DATABASE ... , CREATE USER ... , GRANT ALL ... |
Snipe-IT Installation | Download Snipe-IT code and run the install script. | sudo git clone ... , sudo ./install.sh |
Permissions & SELinux | Ensure web server has correct file permissions and SELinux contexts. | sudo chown -R apache:apache ... , sudo chcon -R -t httpd_sys_rw_content_t ... |
Apache Configuration | Create a virtual host for Snipe-IT. | sudo vi /etc/httpd/conf.d/snipeit.conf |
Cron Job | Schedule background tasks for Snipe-IT. | sudo crontab -e , add * * * * * ... artisan schedule:run |
Enable HTTPS | Secure your Snipe-IT instance with an SSL certificate. | sudo certbot --apache -d your_domain.com |
Update Snipe-IT | Keep your Snipe-IT installation current. | cd /var/www/snipeit , sudo git pull , sudo php artisan migrate |
Migrate Production Data | Import existing asset management data. | Database restore or CSV import via web interface. |
By following these steps, you will have a fully functional and secure Snipe-IT installation on your CentOS server, ready for managing your assets.