### Download and Prepare Installer Script Source: https://snipe-it.readme.io/docs/downloading Download the installation script using wget, make it executable, and then run it. This installer is intended for fresh CentOS/Red Hat or Debian/Ubuntu systems. Ensure your system meets the version requirements. ```bash wget https://raw.githubusercontent.com/grokability/snipe-it/master/install.sh chmod 744 install.sh ./install.sh ``` -------------------------------- ### Install Dependencies on Linux/OSX Source: https://snipe-it.readme.io/docs/install-dependencies Use these commands to install dependencies locally within the installation directory. ```shell $ cd $ curl -sS https://getcomposer.org/installer | php $ php composer.phar install --no-dev --prefer-source ``` -------------------------------- ### Install Passport for API Tokens Source: https://snipe-it.readme.io/docs/common-issues Run this command to install Passport, which is necessary for creating API tokens. ```text # Install passport $ php artisan passport:install ``` -------------------------------- ### Copy Example Config File Source: https://snipe-it.readme.io/docs/configuration Use this command to copy the example configuration file to a new .env file if it doesn't exist. This is the first step in setting up your environment variables. ```shell # Copy the example config file if it doesn't exist $ cp .env.example .env ``` -------------------------------- ### Check Git Installation Source: https://snipe-it.readme.io/docs/switching-to-a-git-install Verify if Git is installed on your system by checking its version. If the command is not found, you need to install Git. ```bash # Check if you have git installed $ git --version ``` -------------------------------- ### Install Homestead CLI Tools with Composer Source: https://snipe-it.readme.io/docs/vagrant-via-homestead Installs the Homestead command-line interface using Composer. Make sure your Composer vendor bin directory is in your system's PATH. ```text composer global require "laravel/homestead=~2.0" Changed current directory to /Users/wjgilmore/.composer ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) - Installing symfony/process (v2.6.3) Downloading: 100% - Installing laravel/homestead (v2.0.8) Downloading: 100% Writing lock file Generating autoload files ``` -------------------------------- ### Standalone Database Configuration Source: https://snipe-it.readme.io/docs/docker Example configuration for connecting to an external, non-containerized database. ```shell # Mysql Parameters MYSQL_PORT_3306_TCP_ADDR=XXX.XXX.XXX.XXX MYSQL_PORT_3306_TCP_PORT=3306 MYSQL_DATABASE=snipe_it MYSQL_USER=snipe_it_db_user MYSQL_PASSWORD=snipe_it_db_user_password ``` -------------------------------- ### Install Dependencies with Global Composer Source: https://snipe-it.readme.io/docs/install-dependencies Use this command if Composer is already installed globally on the system. ```shell $ cd $ composer install --no-dev --prefer-source ``` -------------------------------- ### Install Snipe-IT Dependencies with Composer Source: https://snipe-it.readme.io/docs/switching-to-a-git-install Install the necessary dependencies for Snipe-IT using Composer. Use the '--no-dev' flag to exclude development dependencies and '--prefer-source' to prefer source installations. ```bash # Install Snipe-IT dependencies $ composer install --no-dev --prefer-source ``` -------------------------------- ### Create a new webserver user Source: https://snipe-it.readme.io/docs/configuration Example command to create a new Linux user and assign them to the apache group. ```bash # Create a new webserver user and add it to the apache group $ useradd -g apache snipeit ``` -------------------------------- ### Composer Install with Source Preference Source: https://snipe-it.readme.io/docs/installation-issues When encountering GitHub API rate limit issues during composer installs, using the `--prefer-source` flag can help by fetching code directly from repositories. ```bash composer install --prefer-source ``` -------------------------------- ### Configure XAMPP Virtual Host for Snipe-IT Source: https://snipe-it.readme.io/docs/xampp Add these lines to your `httpd-vhosts.conf` file to configure a virtual host for Snipe-IT. This setup redirects `snipe-it.local` to your Snipe-IT installation and includes a necessary ScriptAlias for the `/licenses` route. ```apache # VirtualHost for SNIPE-IT.LOCAL DocumentRoot "C:\\xampp\\htdocs\\snipe-it\\public" ServerAdmin snipe-it.local Options Indexes FollowSymLinks AllowOverride All Require all granted # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # # We have to use this script alias for Snipe-IT because # XAMPP has a built-in URL for /licenses. # See https://github.com/snipe/snipe-it/issues/4031 for more info ScriptAlias /licenses/ "C:\\xampp\\htdocs\\snipe-it\\public" ``` -------------------------------- ### Get Snipe-IT Command List Source: https://snipe-it.readme.io/docs/command-line-utilities Run this command to get a list of all available Snipe-IT command-line utilities and their descriptions. ```bash # Get a list of Snipe-IT command-line utilities and what they do $ php artisan snipeit --help (... lots of output here...) ``` -------------------------------- ### Example Homestead.yaml Configuration Source: https://snipe-it.readme.io/docs/vagrant-via-homestead A sample Homestead.yaml file demonstrating common configurations for IP, memory, CPUs, databases, SSH keys, folder mappings, and site definitions. ```yaml --- ip: "192.168.10.10" memory: 2048 cpus: 1 databases: - homestead authorize: /Users/agianotto/.ssh/id_rsa.pub keys: - /Users/agianotto/.ssh/id_rsa folders: - map: /Users/agianotto/projects to: /home/snipe-it sites: - map: snipe-it.app to: /home/vagrant/Code/snipe-it/public variables: - key: APP_ENV value: local ``` -------------------------------- ### Start Snipe-IT Container with SSL Source: https://snipe-it.readme.io/docs/docker Launches a Snipe-IT container with SSL support enabled. Requires copying SSL certificates to the storage volume after initialization. ```shell docker run -d -p YOUR_PORT_NUMBER:80 -p YOUR_SSL_PORT:443 --name="snipeit" --link snipe-mysql:mysql --mount source=snipe-vol,dst=/var/lib/snipeit --env-file=my_env_file snipe/snipe-it ``` ```shell docker run -d -p YOUR_PORT_NUMBER:80 -p YOUR_SSL_PORT:443 --name="snipeit" --link snipe-mysql:mysql --mount source=snipe-vol,dst=/var/lib/snipeit --env-file=my_env_file snipe/snipe-it:v4.1.13 ``` -------------------------------- ### Copy Old Files to New Git Install Source: https://snipe-it.readme.io/docs/switching-to-a-git-install Transfer essential files and directories from your old manual installation to the new Git-based installation. This includes uploads, .env file, and keys. ```bash # Copy over necessary files $ cp -R snipe-it-backup/public/uploads/* snipe-it/public/uploads $ cp -R snipe-it-backup/storage/private_uploads/* snipe-it/storage/private_uploads $ cp -R snipe-it-backup/storage/app/backups/* snipe-it/storage/app/backups $ cp -R snipe-it-backup/.env snipe-it/ $ cp -R snipe-it-backup/storage/oauth-private.key snipe-it/storage/oauth-private.key $ cp -R snipe-it-backup/storage/oauth-public.key snipe-it/storage/oauth-public.key ``` -------------------------------- ### Install Dependencies in Container Source: https://snipe-it.readme.io/docs/docker Run composer install inside the running container after mounting local code. ```shell docker exec -i -t snipeit composer install ``` -------------------------------- ### Initialize Homestead Configuration Source: https://snipe-it.readme.io/docs/vagrant-via-homestead Initializes the Homestead configuration by creating the Homestead.yaml file. This command should be run after installing the Homestead CLI tools. ```text homestead init Creating Homestead.yaml file... ok Homestead.yaml file created at: /Users/agianotto/.homestead/Homestead.yaml ``` -------------------------------- ### Check Composer Dependencies Source: https://snipe-it.readme.io/docs/common-issues Verify that the system has all required PHP extensions installed. ```text # Check composer dependencies $ composer check-platform-reqs ``` ```text # Check composer dependencies $ composer check-platform-reqs Checking platform requirements for packages in the vendor dir ext-bcmath 7.4.12 success ext-ctype 7.4.12 success ext-curl 7.4.12 success ext-date 7.4.12 success ext-dom 20031129 success ext-fileinfo 7.4.12 success ext-filter 7.4.12 success ext-gd 7.4.12 success ext-iconv 7.4.12 success ext-json 7.4.12 success ext-ldap 7.4.12 success ext-libxml 7.4.12 success ext-mbstring 7.4.12 success ext-openssl 7.4.12 success ext-pcre 7.4.12 success ext-pdo 7.4.12 success ext-phar 7.4.12 success ext-simplexml 7.4.12 success ext-tokenizer 7.4.12 success ext-xml 7.4.12 success ext-xmlwriter 7.4.12 success ext-zip 1.15.6 success lib-pcre 10.35 success php 8.2 success ``` -------------------------------- ### Display Database Information Source: https://snipe-it.readme.io/docs/command-line-utilities Shows general information about the database configured in your .env file. This command provides an overview of your database setup. ```bash # Display information about the given database $ php artisan db:show ``` -------------------------------- ### Launch Snipe-IT Instance Source: https://snipe-it.readme.io/docs/docker Starts the Snipe-IT containers in detached mode. ```bash # Launch your Snipe-IT instance! $ docker compose up -d ``` -------------------------------- ### Create Docker Work Environment Source: https://snipe-it.readme.io/docs/docker Create a directory for your Snipe-IT Docker setup and navigate into it. This directory will serve as the root for your Docker Compose configuration. ```bash # Create docker work environment $ mkdir snipeit $ cd snipeit ``` -------------------------------- ### Generate Snipe-IT App Key Source: https://snipe-it.readme.io/docs/generate-your-app-key Run this artisan command after setting up your .env file and installing dependencies. It automatically sets the APP_KEY in your .env file. Keep this key secure. ```bash # Generate an app key php artisan key:generate ``` -------------------------------- ### Resolve Cipher Errors During Installation Source: https://snipe-it.readme.io/docs/installation-issues Reset the application key and encryption settings in the .env file before regenerating the key. ```bash # Install dependencies $ composer install --no-dev # Generate a new app key $ php artisan key:generate ``` -------------------------------- ### Start Snipe-IT Container without SSL Source: https://snipe-it.readme.io/docs/docker Launches a Snipe-IT container using a named volume for persistent storage. Replace YOUR_PORT_NUMBER with the desired host port. ```shell docker run -d -p YOUR_PORT_NUMBER:80 --name="snipeit" --link snipe-mysql:mysql --env-file=my_env_file --mount source=snipe-vol,dst=/var/lib/snipeit snipe/snipe-it ``` ```shell docker run -d -p YOUR_PORT_NUMBER:80 --name="snipeit" --link snipe-mysql:mysql --env-file=my_env_file --mount source=snipe-vol,dst=/var/lib/snipeit snipe/snipe-it:v.4.1.13 ``` -------------------------------- ### Run accessibility tests Source: https://snipe-it.readme.io/docs/contributing-overview Install and execute pa11y-ci to identify accessibility issues. Note that these tests are slow as they utilize a headless Chrome browser. ```bash # Install pa11y-ci $ npm install -g pa11y-ci # Run the pa11y tests $ pa11y-ci ``` -------------------------------- ### OSX Apache VirtualHost Configuration Source: https://snipe-it.readme.io/docs/linuxosx Example Apache virtual host configuration for Snipe-IT on an OS X system. Adjust paths to match your local setup. ```apache Allow From All AllowOverride All Options -Indexes ServerName "www.yourserver.com" DocumentRoot "/Users/youruser/Sites/snipe-it/public" ``` -------------------------------- ### Re-run Composer Install Source: https://snipe-it.readme.io/docs/installation-issues If you encounter errors related to missing PHP extensions or other dependency issues, try deleting your vendor directory and re-running composer install. This ensures all dependencies are correctly installed. ```bash composer install --no-dev ``` -------------------------------- ### Configure Environment Variables Source: https://snipe-it.readme.io/docs/contributing-overview Recommended settings for the .env file to enable local development and debugging. ```text APP_ENV=local APP_DEBUG=true DEBUGBAR_ENABLED=true ``` -------------------------------- ### Show Application Configuration Source: https://snipe-it.readme.io/docs/command-line-utilities Displays general application configuration settings. Useful for checking various app parameters. ```bash # Show app configs php artisan config:show app ``` -------------------------------- ### Create Snipe-IT Database and User Source: https://snipe-it.readme.io/docs/creating-a-database-and-user Execute these SQL commands to create the database and user. Remember to replace 'YOUR_DB_PASSWORD_HERE' with a strong password. ```sql # Step 1: Login to MySQL/MariaDB as root $ user@server:~$ mysql -u root -p # It will prompt you for your database root password $ Enter password: # Step 2: Create the Database $ create database snipeit; # Step 3: Verify that it was created correctly $ show databases; # Step 4: Create the Snipe-IT user $ create user snipe_user; # Step 5: Grant privileges while assigning the password $ grant all on snipeit.* to 'snipe_user'@'localhost' identified by 'YOUR_DB_PASSWORD_HERE'; ``` -------------------------------- ### SAML SLS Error Log Example Source: https://snipe-it.readme.io/docs/saml Example of an error message found in laravel.log when SAML logout response signature validation fails. ```text There was an error with SAML SLS: invalid_logout_response Reason: Signature validation failed. Logout Response rejected ``` -------------------------------- ### Configure Backup Settings in .env Source: https://snipe-it.readme.io/docs/configuration Placeholder for optional backup configuration settings. ```text # -------------------------------------------- # OPTIONAL: BACKUP SETTINGS ``` -------------------------------- ### SCIM Authorization Header Example Source: https://snipe-it.readme.io/docs/scim This is an example of the Authorization header format required for SCIM clients to authenticate with Snipe-IT. Ensure 'Bearer' is followed by a space and your generated API token. ```http Authorization: Bearer abcdefghijklmnopqrstuvwxyz1234567890 ``` -------------------------------- ### Create and Verify Database Source: https://snipe-it.readme.io/docs/wamp Use these SQL commands to create a new database named 'snipeit' and then verify its existence. ```sql create database snipeit; show databases; ``` -------------------------------- ### Show Database Configuration Source: https://snipe-it.readme.io/docs/command-line-utilities Displays the current database connection configuration settings. Verify your database credentials and settings. ```bash # Show database configs php artisan config:show database ``` -------------------------------- ### Fix Snipe-IT File and Directory Permissions Source: https://snipe-it.readme.io/docs/debugging-permissions Use these commands to correct user, group, and file permissions for the Snipe-IT installation. Ensure you replace 'my-user' with your actual Linux username and '/var/www/snipe-it' with your installation path. The web server user is assumed to be 'www-data'. These commands should only be run with sudo initially to fix permissions. ```bash # Use sudo to fix user/groups permissions $ sudo chown -R my-user:www-data /var/www/snipe-it $ sudo usermod -a -G www-data your-linux-user $ sudo find /var/www/snipe-it -type f -exec chmod 664 {} \; $ sudo chmod -R 775 /var/www/snipe-it/storage $ sudo chmod -R 775 /var/www/snipe-it/public/uploads $ sudo chmod -R 775 /var/www/snipe-it/bootstrap/cache ``` -------------------------------- ### Example Unit Test Structure Source: https://snipe-it.readme.io/docs/testing Standard structure for a PHPUnit test class in the Unit directory. ```php assertTrue(true); } } ``` -------------------------------- ### Download Docker Configuration Files Source: https://snipe-it.readme.io/docs/docker Download the docker-compose.yml and .env files from the official Snipe-IT GitHub repository. These files are essential for configuring and running Snipe-IT with Docker. ```bash # Download the docker files $ curl https://raw.githubusercontent.com/snipe/snipe-it/master/docker-compose.yml --output docker-compose.yml $ curl https://raw.githubusercontent.com/snipe/snipe-it/master/.env.docker --output .env ``` -------------------------------- ### Merge users via CLI Source: https://snipe-it.readme.io/docs/merging-users Executes the user merge command from the root directory of the Snipe-IT installation. ```bash # Merge users without an email address username into the email address username version $ php artisan snipeit:merge-users ``` -------------------------------- ### View Cache Directory Error Source: https://snipe-it.readme.io/docs/common-issues Example of an error message found in storage/logs/laravel.log indicating permission issues. ```text The /var/www/snipe-it/bootstrap/cache directory must be present and writable. ``` -------------------------------- ### Run Snipe-IT for Development Source: https://snipe-it.readme.io/docs/docker Mount the local directory over the container's web root to reflect code changes. ```shell docker run -d -v /Path/To/My/snipe-it/checkout:/var/www/html -P --name="snipeit" --link mysql:mysql snipeit ``` -------------------------------- ### Identify Migration Error Source: https://snipe-it.readme.io/docs/database-issues Example of an error log entry indicating a duplicate column name during migration. ```php Migrating: 2019_02_12_182750_add_actiondate_to_actionlog In Connection.php line 669: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'action_date' ``` -------------------------------- ### Send User Inventory via CLI Source: https://snipe-it.readme.io/docs/user-inventory Executes the command from the project root directory to email all users with checked-out items. ```bash # Send current checked-out inventory to all users with an email address $ php artisan snipeit:user-inventory ``` -------------------------------- ### Factory Error Example Source: https://snipe-it.readme.io/docs/testing Common error message when factories are used without the correct base test class. ```text InvalidArgumentException: Unable to locate factory with name [default] [App\Models\MyModel]. ``` -------------------------------- ### Update Vendor Files and Run Migrations Source: https://snipe-it.readme.io/docs/upgrading After pulling new version files, run these commands to update dependencies via composer and apply database migrations. ```bash # Get the latest files $ git pull # Get the latest vendor files via composer $ php composer.phar install --no-dev --prefer-source # Clear any composer caches $ php composer.phar dump-autoload # Run database migrations $ php artisan migrate ``` -------------------------------- ### Validate IMEI with Regex Source: https://snipe-it.readme.io/docs/custom-fields Example of using the CUSTOM format with a regex expression to validate a 15-digit numeric IMEI. ```text regex:/^[0-9]{15}$/ ``` -------------------------------- ### Run the CLI Importer Source: https://snipe-it.readme.io/docs/item-importer Execute the import process by providing the path to the CSV file. ```bash # Run the importer via cli $ php artisan snipeit:import path/to/your/file.csv ``` -------------------------------- ### XSS Vulnerability Test Payloads Source: https://snipe-it.readme.io/docs/contributing-security Example payloads used to test for XSS vulnerabilities in user-inputted text fields. ```text http://localhost:81/DVWA/vulnerabilities/xss_r/?name= ``` ```text ``` ```javascript ``` ```html http://localhost:81/DVWA/vulnerabilities/xss_r/?name=

Please login to proceed

Username:

Password:



``` ```javascript ``` ```html Click Me ``` -------------------------------- ### Regenerate Asset Tags with Flags Source: https://snipe-it.readme.io/docs/regenerate-asset-tags Optional flags to control the starting auto-increment value or display process output. ```bash # Regenerate asset tags, overriding the next auto-increment in Admin Settings > Asset Tags with the number specified in --start= $ php artisan snipeit:regenerate-tags --start=1 ``` ```bash # Regenerate asset tags with a summary output $ php artisan snipeit:regenerate-tags --output=info ``` -------------------------------- ### Seed the database with dummy data Source: https://snipe-it.readme.io/docs/seeding-the-database Executes the database seeder to populate the system with sample data. This command is destructive and will overwrite existing data. ```bash # Seed the database with dummy data - THIS IS DATA DESTRUCTIVE $ php artisan db:seed ``` -------------------------------- ### Show Mail Configuration Source: https://snipe-it.readme.io/docs/command-line-utilities Displays the current mail configuration settings for the Snipe-IT application. Useful for verifying email setup. ```bash # Show mail configs $ php artisan config:show mail ``` -------------------------------- ### Enable Swap Memory on Linux Source: https://snipe-it.readme.io/docs/linuxosx Commands to create and activate a swap file for memory-constrained environments. ```bash # Enable swap memory $ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 $ sudo /sbin/mkswap /var/swap.1 $ sudo /sbin/swapon /var/swap.1 ``` -------------------------------- ### Backup Snipe-IT Data Source: https://snipe-it.readme.io/docs/switching-to-a-git-install Create a backup of your existing Snipe-IT data, including uploaded files and database, before switching to a Git install. ```bash # Run a backup of your existing Snipe-IT data $ php artisan snipeit:backup ``` -------------------------------- ### Configure Environment Backup Source: https://snipe-it.readme.io/docs/moving-snipe-it Set this variable in your .env file to ensure the environment configuration is included in the backup. ```text BACKUP_ENV=true ``` -------------------------------- ### Configure Outgoing Mail Settings Source: https://snipe-it.readme.io/docs/configuration Set up your outgoing mail server details in the .env file for Snipe-IT to send emails. Ensure all required fields are correctly populated. ```shell # -------------------------------------------- # REQUIRED: OUTGOING MAIL SERVER SETTINGS # -------------------------------------------- MAIL_MAILER=smtp MAIL_HOST=email-smtp.us-west-2.amazonaws.com MAIL_PORT=587 MAIL_USERNAME=YOURUSERNAME MAIL_PASSWORD=YOURPASSWORD MAIL_FROM_ADDR=you@example.com MAIL_FROM_NAME=Snipe-IT MAIL_REPLYTO_ADDR=you@example.com MAIL_REPLYTO_NAME=Snipe-IT MAIL_AUTO_EMBED=true MAIL_AUTO_EMBED_METHOD=base64 MAIL_TLS_VERIFY_PEER=false ``` -------------------------------- ### Enable network and mail SELinux booleans Source: https://snipe-it.readme.io/docs/linuxosx Commands to permit web server network connections and mail delivery. ```shell # Allow network connections and allow the system to send mail $ setsebool -P httpd_can_network_connect 1 $ setsebool -P httpd_can_sendmail 1 ``` -------------------------------- ### Clone Snipe-IT Git Repository Source: https://snipe-it.readme.io/docs/switching-to-a-git-install Clone the Snipe-IT Git repository to your desired location. This command sets up the new project root for your Git-based installation. ```bash # Clone the git repo $ git clone https://github.com/grokability/snipe-it your-folder ``` -------------------------------- ### View Laravel email error logs Source: https://snipe-it.readme.io/docs/linuxosx Example of the permission denied error encountered in Laravel logs when SELinux blocks outgoing mail connections. ```shell [2017-12-07 15:34:32] production.ERROR: Swift_TransportException: Connection could not be established with host masked_ip [Permission denied #13] in /var/www/html/snipeit/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:268 ``` -------------------------------- ### Show Container Logs Source: https://snipe-it.readme.io/docs/docker Displays the logs for the running applications. ```bash # Show the logs $ docker compose logs -f ``` -------------------------------- ### Sync Asset Locations Source: https://snipe-it.readme.io/docs/asset-location-sync Run this artisan command from your Snipe-IT project root to sync asset locations with whoever or whatever they are checked out to. Use the --output=all flag to see all sync operations. ```bash # Sync locations with whoever/whatever they're checked out to $ php artisan snipeit:sync-asset-locations --output=all ``` -------------------------------- ### Invoke Status Labels Transformer - PHP Source: https://snipe-it.readme.io/docs/architecture Example of how to invoke the StatuslabelsTransformer in an API controller to ensure consistent JSON payload structure for status label data. ```php return (new StatuslabelsTransformer)->transformStatuslabels($statuslabels, $total); ``` -------------------------------- ### Allow SELinux Network Connections Source: https://snipe-it.readme.io/docs/common-issues On Linux systems with SELinux enabled, use this command to allow the web server to make network connections, which can resolve Swift_TransportException errors. ```text # Allow SELinux to make network connections $ setsebool -P httpd_can_network_connect on ```