Installing Snipe-IT on CentOS 7 and MariaDB
-
I am receiving the error when running the php artisan app:install command. This seems to be my only hold up for getting Snipe-IT running. Any help is greatly appreciated.
-
@brandon.hay
I am getting the same error. Prior to the red box warning the system says "sed: can't read app/config/app.php: No such file or directory"Oddly SnipeIT starts, I can even reach it from another PC on the network though after I log in the screen is blank.
EDIT: SO I cannot find app/config/app.php, there is an app.php under var/www/html/snipe/config. -
Hey guys, I'm tied up most of the afternoon but I'll totally look into this for you. Sorry for the delay.
-
@scottalanmiller
Thanks in advance! -
Any idea on the best way to upgrade from V2.1.1 to the latest V3 release??
-
@scottalanmiller Any chance you've has an opportunity to look at this?
-
When i run the command i got the following error,please help.
[root@oc snipeit]# php artisan app:install
PHP Warning: require(/var/www/html/snipeit/vendor/composer/../aws/aws-sdk-php/src/functions.php): failed to open stream: No such file or directory in /var/www/html/snipeit/vendor/composer/autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required '/var/www/html/snipeit/vendor/composer/../aws/aws-sdk-php/src/functions.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/snipeit/vendor/composer/autoload_real.php on line 66 -
I finally nailed the install to Ubuntu 16.04. It's no single line code and was very manual but I wanted to debug where this was failing and finally figured it out. Here is what I had to do (pardon the elementary nature of the process, I'm still a real Linux noob)...
CAUTION:
These instructions only work for Ubuntu 16.04 Xenial because I deleted all code referencing other builds. If your version is different, make sure to retain what is relevant for your build.AMATEUR HOUR WARNING
As I mentioned before, as I'm still very new to Linux, If someone here can likely figure out a much better way to get this setup, even better. I hadn't been able to find any instructions on the internet that proved useful even though my google-foo is quite strong, and I was determined to get this setup, if for no other reason than this would be a great learning experience.- Setup a VM in Hyper-V and completed a fresh install of Ubuntu 16.04 server
- During the install I selected to manually install the necessary packages so this was a minimal server install
- Full update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
- Manually install apache
sudo apt-get install apache2 apache2-utils
- Enable apache to autostart
sudo systemctl enable apache2
- Set ownership of root directory
sudo chown www-data /var/www/html/ -R
- Install MariaDB
sudo apt-get install mariadb-server mariadb-client
- Enable MariaDB to autostart
sudo systemctl enable mysql
- Complete MariaDB setup. When prompted, select pwd, remove anonymous, disallow remote root, remove test db and reload db
sudo mysql_secure_installation
- Install PHP
sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl libapache2-mod-php7.0
- Enable apache PHP module and restart apache
sudo a2enmod php7.0
sudo systemctl restart apache2
That got me to my base LAMP install. I was now ready to download Snipe-IT. From the documentation I selected #3 and ran each command one at a time.
sudo wget https://raw.githubusercontent.com/snipe/snipe-it/master/install.sh
chmod 744 install.sh
Then before running the final command I decided to examine the "install.sh" contents to see what was happening. Turns out it downloads and calls another script so before running that second script, I wanted to have a look at it so I commented out the final command that executes the second script so it would only download the file to my home directory and set permissions. I then ran the script and got the second script so I could look at it.
sudo ./install.sh
Once I looked in the second script (snipeit.sh) I noticed there is a lot of content that is trying to account for various Linux builds so I went through and deleted everything that didn't have anything to do with my version of Linux in order to simplify the debugging process. I also deleted every code reference to
>> /var/log/snipeit-install.log 2>&1
since I had noticed on a previous run that this was causing permissions errors. Rather than have to deal with permissions, I didn't care about saving the install log and instead allowed it to display on the terminal session.The next error I got was related to the composer where the code was trying to install using
sudo
(you'll note that this is set at the top of the script). Apparently composer cannot be installed this way. Keep reading for how I addressed that.I then also removed most references to updates or installing the LAMP stack as I had already done this. Something that kept causing errors in the script even when I chose to run from nothing but a minimal Ubuntu install without apache, mysql or php. I ended-up modifying the script quite a bit, hard-coding some of the variables to make debugging a little easier. This is the final script I had saved as "snipeit.sh"
#!/bin/bash ###################################################### # Snipe-It Install Script # # Script created by Mike Tucker # # [email protected] # # This script is just to help streamline the # # install process for Debian and CentOS # # based distributions. I assume you will be # # installing as a subdomain on a fresh OS install. # # Right now I'm not going to worry about SMTP setup # # # # Feel free to modify, but please give # # credit where it's due. Thanks! # ###################################################### # ensure running as root if [ "$(id -u)" != "0" ]; then exec sudo "$0" "$@" fi #First things first, let's set some variables and find our distro. clear name="snipeit" si="Snipe-IT" hostname="$(hostname)" fqdn="$(hostname --fqdn)" ans=default hosts=/etc/hosts file=master.zip tmp=/tmp/$name fileName=snipe-it-master rm -rf $tmp/ mkdir $tmp echo " _____ _ __________ / ___/____ (_)___ ___ / _/_ __/ \__ \/ __ \/ / __ \/ _ \______ / / / / ___/ / / / / / /_/ / __/_____// / / / /____/_/ /_/_/ .___/\___/ /___/ /_/ /_/ " echo "" echo "" echo " Welcome to Snipe-IT Inventory Installer for Centos and Debian!" echo "" #Get your FQDN. echo -n " Q. What is the FQDN of your server? ($fqdn): " read fqdn if [ -z "$fqdn" ]; then fqdn="$(hostname --fqdn)" fi echo " Setting to $fqdn" echo "" #Do you want to set your own passwords, or have me generate random ones? until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do echo -n " Q. Do you want me to automatically create the snipe database user password? (y/n) " read setpw case $setpw in [yY] | [yY][Ee][Ss] ) mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c16`)" ans="yes" ;; [nN] | [n|N][O|o] ) echo -n " Q. What do you want your snipeit user password to be?" read -s mysqluserpw echo "" ans="no" ;; *) echo " Invalid answer. Please type y or n" ;; esac done #Snipe says we need a new 32bit key, so let's create one randomly and inject it into the file random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)" #db_setup.sql will be injected to the database during install. #Again, this file should be removed, which will be a prompt at the end of the script. dbsetup=$tmp/db_setup.sql echo >> $dbsetup "CREATE DATABASE snipeit;" echo >> $dbsetup "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" #Let us make it so only root can read the file. Again, this isn't best practice, so please remove these after the install. sudo chown root:root $dbsetup sudo chmod 700 $dbsetup ## TODO: Progress tracker on each step ##################################### Install for Ubuntu ############################################## webdir=/var/www #Update/upgrade Debian/Ubuntu repositories, get the latest version of git. echo "" echo "## Updating ubuntu in the background. Please be patient." echo "" apachefile=/etc/apache2/sites-available/$name.conf echo "## Installing packages." echo "## Setting up LAMP." sudo apt-get install -y git unzip php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring #Enable mcrypt and rewrite echo "## Enabling mcrypt and rewrite" sudo phpenmod mcrypt sudo phpenmod mbstring sudo a2enmod rewrite # Get files and extract to web dir echo "" echo "## Downloading snipeit and extract to web directory." sudo wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file sudo unzip -qo $tmp/$file -d $tmp/ sudo cp -R $tmp/$fileName $webdir/$name sudo ls -al /etc/apache2/mods-enabled/rewrite.load #Create a new virtual host for Apache. echo "## Create Virtual host for apache." echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "<VirtualHost *:80>" echo >> $apachefile "ServerAdmin webmaster@localhost" echo >> $apachefile " <Directory $webdir/$name/public>" echo >> $apachefile " Require all granted" echo >> $apachefile " AllowOverride All" echo >> $apachefile " </Directory>" echo >> $apachefile " DocumentRoot $webdir/$name/public" echo >> $apachefile " ServerName $fqdn" echo >> $apachefile " ErrorLog /var/log/apache2/snipeIT.error.log" echo >> $apachefile " CustomLog /var/log/apache2/access.log combined" echo >> $apachefile "</VirtualHost>" echo "## Setting up hosts file." echo >> $hosts "127.0.0.1 $hostname $fqdn" sudo a2ensite $name.conf cat > $webdir/$name/.env <<-EOF #Created By Snipe-it Installer APP_TIMEZONE=$(cat /etc/timezone) DB_HOST=localhost DB_DATABASE=snipeit DB_USERNAME=snipeit DB_PASSWORD=$mysqluserpw APP_URL=http://$fqdn APP_KEY=$random32 EOF # Setup Mysql, then run the command. /usr/bin/mysql_secure_installation echo "## Creating MySQL Database and user. " echo "## Please Input your MySQL/MariaDB root password: " mysql -u root -p < $dbsetup echo "## Securing Mysql" # Have user set own root password when securing install # and just set the snipeit database user at the beginning echo "" echo "" echo "## Cleaning up..." rm -f snipeit.sh rm -f install.sh rm -rf $tmp/ echo "## Done!" sleep 1
This got me about 90% of the way there. I then had to run the following commands one at a time (note that composer is not run from the elevated command)
cd /var/www/snipeit
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --prefer-source
To finish it off, I set the required permissions.
sudo chmod -R 755 /var/www/snipeit/storage sudo chmod -R 755 /var/www/snipeit/storage/private_uploads sudo chmod -R 755 /var/www/snipeit/public/uploads sudo chown -R www-data:www-data /var/www/snipeit sudo service apache2 restart
Because I'm using this internally, I edited the sites-available/snipeit.conf file as follows...
<VirtualHost *:80> ServerAdmin [email protected] <Directory /var/www/snipeit/public> Require all granted AllowOverride All </Directory> DocumentRoot /var/www/snipeit/public ServerName snipeit.domain.com ServerAlias XXX.XXX.XXX.XXX #This is the server IP address ServerAlias localhost ErrorLog ${APACHE_LOG_DIR}/sniptit.error.log CustomLog ${APACHE_LOG_DIR}/snipeit.access.log combined </VirtualHost>
The installation will have created a .env file in your root folder however, I figured out that this file was incomplete. So I added the missing values based on documentation for Snipe-IT and this is the resulting /var/www/snipeit/.env file...
#Created By Snipe-it Installer # -------------------------------------------- # REQUIRED: BASIC APP SETTINGS # -------------------------------------------- APP_TIMEZONE=Canada/Eastern #The above is set during install APP_ENV=production APP_DEBUG=false APP_LOCALE=en APP_URL=http://snipeit.domain.com #This has to be exactly the correct FQDN to get to your Snipt-IT install. If you are using local IP address only then this must be in the IP address format like http://XXX.XXX.XXX.XXX APP_KEY=XXXXXXXXXXXXXXXX #The above is set during install # -------------------------------------------- # REQUIRED: DATABASE SETTINGS # -------------------------------------------- DB_CONNECTION=mysql DB_HOST=localhost DB_DATABASE=snipeit DB_USERNAME=XXXXXXXXX #The above is set during install DB_PASSWORD=XXXXXXXXXXXX #The above is set during install DB_PREFIX=null DB_DUMP_PATH='/usr/local/bin' # -------------------------------------------- # REQUIRED: OUTGOING MAIL SERVER SETTINGS # -------------------------------------------- MAIL_DRIVER=smtp MAIL_HOST=outlook.office365.com #This is correct if you are using Office 365 for your email MAIL_PORT=587 MAIL_USERNAME=XXXXXXXXXXX #Mail username, usually same as email address MAIL_PASSWORD=XXXXXXXXXXX #Your email password MAIL_ENCRYPTION=TLS [email protected] [email protected] # -------------------------------------------- # REQUIRED: IMAGE LIBRARY # This should be gd or imagick # -------------------------------------------- IMAGE_LIB=gd # -------------------------------------------- # OPTIONAL: SESSION SETTINGS # -------------------------------------------- SESSION_LIFETIME=12000 EXPIRE_ON_CLOSE=false ENCRYPT=false COOKIE_NAME=snipeit_session COOKIE_DOMAIN=null SECURE_COOKIES=false
Once that was updated, I rebooted the server for good measure and was able to navigate to my server IP address http://XXX.XXX.XXX.XXX and was presented with the Pre-flight & Setup screen.
For reference, this is where to find the .env file config details.
Once you're at the pre-flight page and everything is green, you can navigate your way to setting up the db and user and begin to enter your first assets.
Hope this proves useful.
-
Is Snipe-IT still recommended?
-
@Jstear Sadly I just got it installed so can't comment on how effective it will be for me. Will report back when I have more.
-
@Jstear said in Installing Snipe-IT on CentOS 7 and MariaDB:
Is Snipe-IT still recommended?
Getting ready to test again. It's certainly recommended to try out, not many products like it out there.
-
@sawgwa said in Installing Snipe-IT on CentOS 7 and MariaDB:
@scottalanmiller Any chance you've has an opportunity to look at this?
Getting the VM fired up now.
-
@scottalanmiller Im new to the forum, any update with Centos 7 and Maria DB installation and configuration? Haven't started since Snipe IT documentation looks confusing and less details for a not so linux expert like me....
-
@jfc Setup you CentOS 7 vm and only use their install script.
wget https://raw.githubusercontent.com/snipe/snipe-it/master/install.sh chmod 744 install.sh ./install.sh
It will download everything you need and get you to a working Snipe IT installation, I just setup my own Snipe IT vm like this =).
-
Can't seem to grasp how to upgrade from V2 to V3 as I've used the above method and used the install.sh
So not sure if I should be using GIT to clone the new version and then how to install/move the latest version and what files need editing.
-
@Romo said in Installing Snipe-IT on CentOS 7 and MariaDB:
@jfc Setup you CentOS 7 vm and only use their install script.
wget https://raw.githubusercontent.com/snipe/snipe-it/master/install.sh chmod 744 install.sh ./install.sh
It will download everything you need and get you to a working Snipe IT installation, I just setup my own Snipe IT vm like this =).
Tested on centOS 7 installs great. Wonder how we update.
-
@tiagom Taken from here https://snipe-it.readme.io/docs/how-to-upgrade:
Upgrading
Updating Snipe-IT should be pretty straightforward. Simply pull down the newest release, copy the files over, and run whatever commands the release notes specify. Your configuration won’t be overwritten, since the .env file isn't checked into version control.Always backup your database and configuration files before upgrading. We try very hard to make sure that all database changes are non-destructive, but you should always backup beforehand anyway. You will never regret backing up your database. You may regret not doing so, so it’s just better to get into the habit.
Whenever you pull down a new version from master or develop, or when you grab the latest official release, make sure to run the following commands via command line:
php composer.phar install --no-dev --prefer-source
php composer.phar dump-autoload
php artisan migrate
php artisan config:clear
php artisan config:cache
(Developers should remove the --no-dev flag, so they have unit test frameworks and debugging tools.)Forgetting to run these commands can mean your DB might end up out of sync with the new files you just pulled, or you may have some funky cached autoloader values.
It’s a good idea to get into the habit of running these every time you pull anything new down. If there are no database changes to migrate, it won't hurt anything to run migrations anyway, you’ll just see "Nothing to migrate".
If you have any issues upgrading, check the Common Issues page for a fix. If you don’t see your issue listed there, open an issue on Github and we’ll try to get you sorted out. Be sure to provide the information outlined in the Getting Help section of this site so that we have the info we need to assist you.
-
@Romo said in Installing Snipe-IT on CentOS 7 and MariaDB:
Upgrading
Updating Snipe-IT should be pretty straightforward. Simply pull down the newest release, copy the files over, and run whatever commands the release notes specify. Your configuration won’t be overwritten, since the .env file isn't checked into version control.That's the first issue I have. I used the install.sh method so how do we download the latest?
Do I GIT the latest into the var/www/snipeit folder?
Do I download a zip/tar and unpack into the folder etc etc. -
@hobbit666 You can use either way, they both accomplish the same thing that is downloading the newest source files.
Step 1: Backup your database
While logged in, go to Admin > Backups and generate a new backup. Download that file and keep it somewhere safe, in case you need to restore back to that version if something goes wrong with your upgrade.Step 2: Backup your old version
The easiest way to do this will be to just rename your old Snipe-IT install directory and create a new, empty directory that uses the old directory name, but you can handle this any way that works for you.For example, if your Snipe-IT was installed in
/var/www/snipe-it
, you could rename that directory to/var/www/snipe-it-backup
and then create a new directory/var/www/snipe-it
.Step 3: Download/clone the new release
Download the zip from: https://github.com/snipe/snipe-it/archive/master.zip
or
git clone https://github.com/snipe/snipe-it.gitStep 4: Update dependencies
Whenever you pull down a new version, you should update the dependencies via Composer and dump the autoloader.NOTE: Never run composer as a super-user or Administrator. Always run it as the user that owns the Snipe-IT files. Running composer as a super-user will break things in ways that will be difficult to debug later. Just don't do it.
1st you'll need to install composer into the directory if you don't have it installed globally:
cd <install-dir> curl -sS https://getcomposer.org/installer | php
Noq update dependencies and dump the auto-loader.
php composer.phar install --no-dev --prefer-source php composer.phar dump-autoload
Step 5: Copy over your configuration settings
IMPORTANT:
This step will only need to be done once, while upgrading to v3.0. Once you've upgraded to v3.0, you won't ever have to do this part again.Open up your .env file in your new Snipe-IT install directory, and update the configuration placeholders you see there with the values you were previously using in your individual config files.
If you don't have a .env file, just copy the existing .env.example over to .env and use that:
cp .env.example .env
The files you'll be copying from are:
app/config/app.php
app/config/production/app.php
app/config/production/database.php
app/config/production/mail.php
app/config/production/session.php
New .env Setting Old Config File Old Config File Key Notes APP_ENV N/A N/A Set to production APP_DEBUG /app/config/production/app.php
debug APP_KEY /app/config/production/app.php key Make SURE you keep this app key the same from your old version. APP_URL /app/config/production/app.php url APP_TIMEZONE /app/config/app.php timezone APP_LOCALE /app/config/app.php locale DB_CONNECTION /app/config/production/database.php default This should be mysql
DB_HOST /app/config/production/database.php connections-> mysql-> host DB_DATABASE /app/config/production/database.php connections-> mysql-> database DB_USERNAME /app/config/production/database.php connections-> mysql-> username DB_PASSWORD /app/config/production/database.php connections-> mysql-> password DB_PREFIX /app/config/production/database.php connections-> mysql-> prefix DB_DUMP_PATH N/A N/A Path to your dabase dump binary (such as mysqldump)e.g. '/usr/local/bin' MAIL_DRIVER /app/config/production/mail.php driver MAIL_HOST /app/config/production/mail.php host MAIL_PORT /app/config/production/mail.php port MAIL_USERNAME /app/config/production/mail.php username MAIL_PASSWORD /app/config/production/mail.php password MAIL_ENCRYPTION /app/config/production/mail.php encryption MAIL_FROM_ADDR /app/config/production/mail.php from->address MAIL_FROM_NAME /app/config/production/mail.php from->name IMAGE_LIB N/A N/A Should be set to gd or imagick, depending on which library you have on your server. SESSION_LIFETIME /app/config/production/session.php lifetime EXPIRE_ON_CLOSE /app/config/production/session.php expire_on_close ENCRYPT N/A N/A Should be set to true if you wish to encrypt your cookies. COOKIE_NAME /app/config/production/session.php cookie COOKIE_DOMAIN /app/config/production/session.php domain SECURE_COOKIES /app/config/production/session.php secure Everything else in your .env can be left alone, as they are more advanced settings that are not commonly used.
Step 6: Move uploaded files and check permissions
Since Laravel's file structure has changed, you're going to need to move a few files around to make sure your uploaded files (logo, uploaded asset files, asset model files, etc) are in their new location.cp ../snipe-it-backup/app/storage/dumps/* snipe-it/storage/app/backups/ cp ../snipe-it-backup/app/private_uploads/* snipe-it/storage/private_uploads/ cp ../snipe-it-backup/public/uploads/* snipe-it/public/uploads/
Also confirm that your entire storage directory (and subdirectories) is writable by the web server.
Step 7: Migrate the database
Always run your database migrations on any upgrade, as this will make sure your database schema is up to date with what the new code expected.php artisan migrate
Forgetting to run these commands can mean your DB might end up out of sync with the new files you just pulled, or you may have some funky cached autoloader values.
It’s a good idea to get into the habit of running these every time you pull anything new down. If there are no database changes to migrate, it won't hurt anything to run migrations anyway, you’ll just see "Nothing to migrate".
Step 8: Launch Snipe-IT in a browser
You should be all set now, so just go to your old Snipe-IT URL and make sure everything is working. -
@Romo said in Installing Snipe-IT on CentOS 7 and MariaDB:
@hobbit666 You can use either way, they both accomplish the same thing that is downloading the newest source files.
Step 1: Backup your database
While logged in, go to Admin > Backups and generate a new backup. Download that file and keep it somewhere safe, in case you need to restore back to that version if something goes wrong with your upgrade.Thanks Romo will give it a try Monday/Tuesday