Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install On Ubuntu #867

Closed
gregm123 opened this issue Jun 24, 2015 · 30 comments
Closed

Install On Ubuntu #867

gregm123 opened this issue Jun 24, 2015 · 30 comments

Comments

@gregm123
Copy link

Hello
I am struggling to follow the install guide for Linux guide, I am trying to install Snipe-it on Ubuntu server 14.04, so far I have done the following
From a fresh Server Install I have done the following
apt-get install lamp-server^
apt-get install php5 php5-mcrypt php5-curl php5-mysql
php5enmod mcrypt

I have then cloned the Snipe-it folder however I am unsure as to where the best place to put this once cloned and so far placed it in /var/www/snipe-it
I have followed the guide down to configure Apache and from here is where I am getting stuck. It is more than likely I am not creating or editing the correct conf file for the virtual host settings.
I don't think I am installing composer correctly i'm not sure if this is because I have the Snipe-it folder in the correct place.
And am not able to create a user account via php artisan.
I am a novice when it comes to unix, I have successfully installed applications in the past following user guides but I feel as though I am lacking some basic back groung knowledge to follow the guide provided successfully.

Any help would be appreciated

I have since been able to get the application up and running using GR360RY snipeit-ansible script I did have to make a few adjustments along the way to get around error 500 when trying to log into the server
For the benefit of anyone else trying to install and having difficulties the exact method I used is below

Using a fresh install of Ubuntu server with nothing else installed

At the command prompt input the following commands in order

sudo apt-get -y install python-software-properties software-properties-common
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get -y install ansible git

Clone the repositroy

cd $HOME
git clone https://github.com/GR360RY/snipeit-ansible.git
Modify the configuration
cd $HOME/snipeit-ansible
sudo nano snipeit.yml (here I changed the database password the SMTP server and username and password details)

Install Snipe-IT

sudo ansible-playbook -i hosts -c local snipeit.yml

Create User first changing permissions to write to app.php

cd /opt/snipe-it/app/config
sudo chmod -R 777 app.php (I had to do this to get allow php artisanapp:install to work)
cd .. back to opt/snipe-it
php artisan app:install
Create user using details from the modified snipeit.yml
Confirm Y to all
If successful open browser and type IP of Host machine

I would however like to know how to install everything without using a script

@mtucker6784
Copy link
Contributor

Greg,

I was on the same boat earlier today, but managed to get this going. I plan on putting a shell script tomorrow/this weekend (depending on the baby) that will do 99% of the work necessary to make Snipe It install (On Ubuntu). I appreciate GR360RY's contribution, but it just didn't install Snipe it correctly in my environment, so I scrapped it and started from a fresh OS install.

If you're monitoring this thread, feel free to reply and we will go from there.

Edit: Fixed some text and specified Ubuntu install.

@gregm123
Copy link
Author

Mtucker

Thank you for the response, can you post details of your script and any additional instructions and i will give them a try on a fresh install

@mtucker6784
Copy link
Contributor

Sorry Greg, I got caught up with family stuff and am at work now. I'll work on some install stuff and get back to you.

@mtucker6784
Copy link
Contributor

Greg,

This is a script I made today that will hopefully make it an easier install. Several things

  1. I tested this on Ubuntu 14.04 LTS x64. Seems to work OK, hopefully it will for you, too.
  2. I know the "code" is very rudimentary, and is sloppy. I'm not the most advanced programmer, by any means.
  3. I found it to work best to sudo su - and run it directly as root. Again, I know that's a horrible way to do it, but it works. Copy and paste the lines to /root/install.sh , then run chmod +x install.sh , then ./install.sh
  4. The script will create /root/mysqlpasswords.txt. This file will have the passwords which were randomly generated for the mysql install (both root and the snipeit user). You can jot down the passwords and then delete the file, OR change them altogether if you wish. If you change snipeit's password, you'll have to change it in the database.php as well.
  5. As you'll see, I don't create a new virtual host, I just simply edit the default 000-default.conf. Probably not the brightest idea, but that's how I got mine to work.
  6. You will still have to edit the mail.php file manually and edit the attributes in there to fit your environment.

If you (or anyone) care to change it or improve upon it, I only ask that my name to be left in there somewhere as I did put some time into the groundwork for this.

Thanks!

[Edited by @snipe - embedded the code, versus linking to a google drive download]:

#!/bin/bash -e

##############################################
# Snipe-IT install script June 30 2015       #
#   Script created by Mike Tucker            #
#     mtucker6784@gmail.com                  #
# No Relation to the author, just wanted     #
# to give an alternative (& maybe easier)    #
# method to install Snipe-IT on Ubuntu 14.04 #
#                                            #
# Feel free to modify, but please give       #
# credit where it's due. Thanks!             #
##############################################

#Generate lower case random passwords, and an upper case 32bit key string for Snipe's key later on
mysqlrootpw="$(echo `< /dev/urandom tr -dc _a-z-0-9 | head -c6`)"
mysqluserpw="$(echo `< /dev/urandom tr -dc _a-z-0-9 | head -c6`)"
random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)"
apachefile=/etc/apache2/sites-available/000-default.conf
echo "[FQDN] What is the FQDN of your server? (example: www.yourserver.com)"
read fqdn

#createstuff.sql will be injected to the database during install. mysqlpasswords.txt is a file that will contain the root and snipeit user passwords.
#You should probably jot these down and then blow away the file. This is at your discretion.
createstufffile=/root/createstuff.sql
passwordfile=/root/mysqlpasswords.txt

echo >> $createstufffile "CREATE DATABASE snipeit;"
echo >> $createstufffile "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"

echo "MySQL ROOT password: $mysqlrootpw"
echo "MySQL USER (snipeit) password: $mysqluserpw"
echo "32 bit random string: $random32"
echo "These passwords have been exported to /root/mysqlpasswords.txt...I recommend You deleting this file for security purposes"
echo >> $passwordfile "MySQL Passwords..."
echo >> $passwordfile "Root: $mysqlrootpw"
echo >> $passwordfile "User (snipeit): $mysqluserpw"
echo >> $passwordfile "32 bit random string: $random32"

sleep 3
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y git
sleep 5

sudo git clone https://github.com/snipe/snipe-it.git /var/www/snipe-it
sleep 3

#I already have a random root password for SQL. Carry forth.
export DEBIAN_FRONTEND=noninteractive
apt-get install -y lamp-server^
apt-get install -y php5 php5-mcrypt php5-curl php5-mysql
php5enmod mcrypt
a2enmod rewrite
ls -al /etc/apache2/mods-enabled/rewrite.load
echo "using root password: $mysqlrootpw"
echo "sending you to the mysql root account. Create the database and the user..."
sleep 1
sudo mysqladmin -u root password $mysqlrootpw
sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql
echo "If no errors, then we're continuing on."
sleep 1

replace "'www.yourserver.com'" "'$fqdn'" -- /var/www/snipe-it/bootstrap/start.php
cp /var/www/snipe-it/app/config/production/database.example.php /var/www/snipe-it/app/config/production/database.php
replace "'snipeit_laravel'," "'snipeit'," -- /var/www/snipe-it/app/config/production/database.php
replace "'travis'," "'snipeit'," -- /var/www/snipe-it/app/config/production/database.php
replace "            'password'  => ''," "            'password'  => '$mysqluserpw'," -- /var/www/snipe-it/app/config/production/database.php
replace "'http://production.yourserver.com'," "'http://$fqdn'," -- /var/www/snipe-it/app/config/production/database.php
cp /var/www/snipe-it/app/config/production/app.example.php /var/www/snipe-it/app/config/production/app.php
replace "'http://production.yourserver.com'," "'http://$fqdn'," -- /var/www/snipe-it/app/config/production/app.php
replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- /var/www/snipe-it/app/config/production/app.php
cp /var/www/snipe-it/app/config/production/mail.example.php /var/www/snipe-it/app/config/production/mail.php
echo ""
echo "Finished copying and replacing text in files. I have no idea about your mail environment, so if you want email capability, open up the following..."
echo "nano -w /var/www/snipe-it/app/config/production/mail.php"
echo "And edit the attributes appropriately."
echo ""
sleep 3

mv /etc/apache2/sites-available/000-default.conf /etc/apache2/000-default-ORIGINAL.conf
#echo $fqdn
echo >> $apachefile "<VirtualHost *:80>"
echo >> $apachefile "ServerAdmin webmaster@localhost"
echo >> $apachefile "    <Directory /var/www/snipe-it/public>"
echo >> $apachefile "        Require all granted"
echo >> $apachefile "        AllowOverride All"
echo >> $apachefile "   </Directory>"
echo >> $apachefile "    DocumentRoot /var/www/snipe-it/public"
echo >> $apachefile "    ServerName $fqdn"
echo >> $apachefile "        ErrorLog ${APACHE_LOG_DIR}/error.log" 
echo >> $apachefile "        CustomLog ${APACHE_LOG_DIR}/access.log combined"
echo >> $apachefile "</VirtualHost>"

sudo chmod -R 755 /var/www/snipe-it/app/storage
sudo chmod -R 755 /var/www/snipe-it/app/private_uploads
sudo chmod -R 755 /var/www/snipe-it/public/uploads
sudo chown -R www-data:www-data /var/www/
echo "Finished permission changes."
sudo curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
cd /var/www/snipe-it/
sudo composer install --no-dev --prefer-source
php artisan app:install --env=production

service apache2 restart
echo "Ok, open up http://$fqdn in a web browser, hope this worked for you."
echo "Remember! If you want mail capabilities, open /var/www/snipe-it/app/config/production/mail.php and fill out the attributes, then restart apache just for grins"
sleep 1

@ionreflex
Copy link

Thank you for that, it will probably help me figure out some things... I'll report back as needed!

@mtucker6784
Copy link
Contributor

No problem--thanks, I am new to github, wasn't sure of the quote structure =-(

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

@mtucker6784 FYI, some of the stuff in here will break during the 2.0 release. I'll try to update it and include the install.sh file in 2.0 after doing some testing.

@mtucker6784
Copy link
Contributor

Sure thing, like I said, it's pretty cruddy code (made in a matter of 4-5 hours with a lot of trial and error.) So I'll be glad to tune it a little bit when the time comes, if you're interested anyway

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

I think most of the tuning I'll do (or you can, or whatever) will be to variable-lize the server path (as I expect that will trip up some people who don't know what they're doing).

Also, this line:

replace "'www.yourserver.com'" "'$fqdn'" -- /var/www/snipe-it/bootstrap/start.php

That's not going to work as expected is your server's hostname is not the same as your FQDN. Laravel 4.2 needs hostname in start.php, not domain name, since that can easily be spoofed.

A lot of people also run this on a shared server with multiple sites on it already, so we may need to tweak it to handle that by naming the apache conf file.

@mtucker6784
Copy link
Contributor

@snipe, ahhh yeah, makes sense about the fqdn, didn't know laravel worked that way. I was aiming this more towards Greg's needs as he said he did a completely fresh OS install (so didn't think about shared sites.) You don't have to go out of your way to modify the script, but I'd love to see how you edit it so I can learn how it should have been 'properly' done :P Make sense?

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

Yeah, if we're going to include this (or some version of this) in core, I have to make sure it doesn't create even more support tickets for me for the unusual cases that come through quite often. ;)

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

(And let's not even talk about all of the windows users who won't be able to use it and will complain... lol)

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

hoops

@mtucker6784
Copy link
Contributor

Haha, forgot about the windows peeps..poor fellers.

@uberbrady
Copy link
Collaborator

We might be able to do a similar line-for-line port into a windows Batchfile, no? install.bat and just put similar (though not the same) stuff in it?

@snipe
Copy link
Owner

snipe commented Jun 30, 2015

@uberbrady I'm sure, but it's another component to have to keep up to date. It's why I haven't written the script before. :-/

bad-idea

@mtucker6784
Copy link
Contributor

It's been so long since I last wrote a script for a windows box. To have
the script do it from scratch (iis and all), may be better off using power
shell as we have more granular control with that
On Jun 30, 2015 3:22 PM, "Brady Wetherington" notifications@github.com
wrote:

We might be able to do a similar line-for-line port into a windows
Batchfile, no? install.bat and just put similar (though not the same)
stuff in it?


Reply to this email directly or view it on GitHub
#867 (comment).

@mtucker6784
Copy link
Contributor

Many apologies if this gets too inundating. I wanted to make note that I made some changes to accommodate @snipe's suggestions, and a couple other changes as well.
Changes:

Added $dir => /var/www/snipe-it/ and replaced all the long "/var/www/snipe-it/" in the previous script with $dir instead

(I believe I) Fixed Apache:
Created a new virtual host and enabled it (/etc/apache2/sites-available/$fqdn.conf)
Escaped Apache's ${APACHE_LOG_DIR} variables, so we don't end up with "/error.log" and "/access.log combined" paths

Added entries in /etc/hosts for the virtual host

Per snipe's clarification, /bootstrap/start.php will now only contain the hostname and Not the FQDN.
I tested this on a fresh VM Ubuntu 14.04 LTS install, seemed to work OK for me; I hope it does for others as well.

#!/bin/bash -e

##############################################
# Snipe-IT install script July 1st 2015      #
#   Script created by Mike Tucker            #
#     mtucker6784@gmail.com                  #
# No Relation to the author, just wanted     #
# to give an alternative (& maybe easier)    #
# method to install Snipe-IT on Ubuntu 14.04 #
#                                            #
# Feel free to modify, but please give       #
# credit where it's due. Thanks!             #
##############################################

#Get your FQDN, generate random characters for mysql root/snipeit users and 32bit key for later on.
echo "[FQDN] What is the FQDN of your server? (example: www.yourserver.com)"
read fqdn
mysqlrootpw="$(echo `< /dev/urandom tr -dc _a-z-0-9 | head -c6`)"
mysqluserpw="$(echo `< /dev/urandom tr -dc _a-z-0-9 | head -c6`)"
random32="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c32`)"
hostname="$(hostname)"
dir=/var/www/snipe-it
apachefile=/etc/apache2/sites-available/$fqdn.conf
hosts=/etc/hosts

#createstuff.sql will be injected to the database during install. mysqlpasswords.txt is a file that will contain the root and snipeit user passwords.
#You should probably jot these down and then blow away the file. This is at your discretion.
createstufffile=/root/createstuff.sql
passwordfile=/root/mysqlpasswords.txt

echo >> $createstufffile "CREATE DATABASE snipeit;"
echo >> $createstufffile "GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"

echo "MySQL ROOT password: $mysqlrootpw"
echo "MySQL USER (snipeit) password: $mysqluserpw"
echo "32 bit random string: $random32"
echo "These passwords have been exported to /root/mysqlpasswords.txt...I recommend You delete this file for security purposes"
echo >> $passwordfile "MySQL Passwords..."
echo >> $passwordfile "Root: $mysqlrootpw"
echo >> $passwordfile "User (snipeit): $mysqluserpw"
echo >> $passwordfile "32 bit random string: $random32"

sleep 1
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y git
sleep 1

sudo git clone https://github.com/snipe/snipe-it.git $dir
sleep 2

#We already have a random root password for SQL. Carry forth.
export DEBIAN_FRONTEND=noninteractive
apt-get install -y lamp-server^
apt-get install -y php5 php5-mcrypt php5-curl php5-mysql
php5enmod mcrypt
a2enmod rewrite
ls -al /etc/apache2/mods-enabled/rewrite.load
echo "using root password: $mysqlrootpw"
echo "sending you to the mysql root account. Create the database and the user..."
sleep 1
sudo mysqladmin -u root password $mysqlrootpw
sudo mysql -u root -p$mysqlrootpw < /root/createstuff.sql
echo "If no errors, then we're continuing on."
sleep 1

replace "'www.yourserver.com'" "'$hostname'" -- $dir/bootstrap/start.php
cp $dir/app/config/production/database.example.php $dir/app/config/production/database.php
replace "'snipeit_laravel'," "'snipeit'," -- $dir/app/config/production/database.php
replace "'travis'," "'snipeit'," -- $dir/app/config/production/database.php
replace "            'password'  => ''," "            'password'  => '$mysqluserpw'," -- $dir/app/config/production/database.php
replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/database.php
cp $dir/app/config/production/app.example.php $dir/app/config/production/app.php
replace "'http://production.yourserver.com'," "'http://$fqdn'," -- $dir/app/config/production/app.php
replace "'Change_this_key_or_snipe_will_get_ya'," "'$random32'," -- $dir/app/config/production/app.php
cp $dir/app/config/production/mail.example.php $dir/app/config/production/mail.php
echo ""
echo "Finished copying and replacing text in files. I have no idea about your mail environment, so if you want email capability, open up the following..."
echo "nano -w $dir/app/config/production/mail.php"
echo "And edit the attributes appropriately."
echo ""
sleep 1

echo >> $apachefile ""
echo >> $apachefile ""
echo >> $apachefile "<VirtualHost *:80>"
echo >> $apachefile "ServerAdmin webmaster@localhost"
echo >> $apachefile "    <Directory $dir/public>"
echo >> $apachefile "        Require all granted"
echo >> $apachefile "        AllowOverride All"
echo >> $apachefile "   </Directory>"
echo >> $apachefile "    DocumentRoot $dir/public"
echo >> $apachefile "    ServerName $fqdn"
echo >> $apachefile "        ErrorLog "\${APACHE_LOG_DIR}"/error.log"
echo >> $apachefile "        CustomLog "\${APACHE_LOG_DIR}"/access.log combined"
echo >> $apachefile "</VirtualHost>"
echo >> $hosts "127.0.0.1 $hostname $fqdn"
a2ensite $fqdn.conf

sudo chmod -R 755 $dir/app/storage
sudo chmod -R 755 $dir/app/private_uploads
sudo chmod -R 755 $dir/public/uploads
sudo chown -R www-data:www-data /var/www/
echo "Finished permission changes."
sudo curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
cd $dir/
sudo composer install --no-dev --prefer-source
php artisan app:install --env=production

service apache2 restart
echo "Ok, open up http://$fqdn in a web browser, hope this worked for you."
echo "Remember! If you want mail capabilities, open $dir/app/config/production/mail.php and fill out the attributes, then restart apache just for grins"
sleep 1

@ionreflex
Copy link

@mtucker6784 Even without the edits you made 20h ago, I've been able to use your script and have an install running, you helped a lot for a noob to reverse-engineered what was needed, compared with the documentation!

My install differs a little :

  • I use MariaDB instead of MySQL (was already installed!);
  • didn't need to install 'apache2-mpm-prefork' or 'php5-curl';

I've installed it on a test system for now, might install it on another server soon, so I will give your new script a try.

Thanks!

@mtucker6784
Copy link
Contributor

Hey there @ionreflex , very cool, glad to hear that my script at least helped a little bit. Did you make changes to the script itself, or just did your changes separately? I know @snipe said that the script I wrote will break in 2.0, but I don't know of 2.0's release timeline.

If you're able to tell me what changes you made (for MariaDB), I can at least put them in the install script as options for other people to use (ie: "select 1 for MySQL, 2 for MariaDB"). I just don't have any experience with MariaDB, so I don't know how different the commands are from mysql.

I don't want to get too crazy with it because if you give too many options, it can be just as confusing for people with minimal Linux experience. There are so many awesome features in Snipe IT; if I'm able to help streamline an install process for people, I'll gladly do it.

Snipe's documentation isn't horribly written by any means, but it is a bit technical for sure 👍

@snipe
Copy link
Owner

snipe commented Jul 2, 2015

Install for MariaDB shouldn't be much (or any) different than MySQL. MariaDB is a just community-developed fork of MySQL.

@snipe
Copy link
Owner

snipe commented Jul 2, 2015

(And timeline for 2.0 is in the next week, week and a half.)

@mtucker6784
Copy link
Contributor

Ah, good deal about MariaDB.

Dang, that soon huh? Very excited to see it!

@snipe
Copy link
Owner

snipe commented Jul 2, 2015

That soon, yep. We release aggressively :)

@snipe
Copy link
Owner

snipe commented Jul 25, 2015

Closing this out for now :)

@snipe snipe closed this as completed Jul 25, 2015
@vijaynageswaran
Copy link

I have tried to install in ubuntu server but failed to work.Can you help me the correct way to install Snipe-IT in my server.?

@snipe
Copy link
Owner

snipe commented Nov 23, 2015

@vijaynageswaran Please see the getting help documentation and open a new ticket with your issues. http://docs.snipeitapp.com/getting-help.html

@vijaynageswaran
Copy link

I didn't find the tab to open the new ticket over that link.Kindly help me with that asap.Thanks.

Or

Can you share me how to install in ubuntu server and how can i access it from web browser.I have done the steps in configuration file and set up the Virtual host.I followed this link
http://docs.snipeitapp.com/installation/server/linux-osx.html

Kindly help me with that asap.

Thanks in advance.

@snipe
Copy link
Owner

snipe commented Nov 25, 2015

@vijaynageswaran https://github.com/snipe/snipe-it/issues/new will open a new issue.

Please see the Getting Help documentation so that you can provide a more detailed description of your issue. http://docs.snipeitapp.com/getting-help.html

@TheRealBards
Copy link

Just to a quick comment to say that the script works perfectly and thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants