Hey Guys, I guess you want to checkout and install SkyHopper on your local PC or on an EC2 server with Ubuntu which is a Debian based Linux OS. The purpose of this is to checkout SkyHopper to another linux based OS as currenlty, we only support Amazon Linux for the installation instruction.
Now, here are some tips and instruction when installing the service into Ubuntu Version 14.04 LTS Client or server.
First is to remove old ruby version and upgrade it to version 2.2.4. Please careful not to over-upgrade it a more higher version as it will have dependency problems in the future. As of now we would only use Ruby version 2.2.4
1 |
<span class="pln">sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> remove ruby</span> |
The next step is to install some dependencies for Ruby.
1 2 |
<span class="pln">sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> update sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install git</span><span class="pun">-</span><span class="pln">core curl zlib1g</span><span class="pun">-</span><span class="pln">dev build</span><span class="pun">-</span><span class="pln">essential </span><span class="pln">libreadline</span><span class="pun">-</span><span class="pln">dev libyaml</span><span class="pun">-</span><span class="pln">dev libsqlite3</span><span class="pun">-</span><span class="pln">dev sqlite3 libxml2</span><span class="pun">-</span><span class="pln">dev libxslt1</span><span class="pun">-</span><span class="pln">dev libcurl4</span><span class="pun">-</span><span class="pln">openssl</span><span class="pun">-</span><span class="pln">dev</span><span class="pln"> libffi</span><span class="pun">-</span><span class="pln">dev</span> |
Next we're going to be installing Ruby using rbenv. Take note that there are other ways to install ruby that have their own benefits, most people prefer using rbenv these days, but if you're familiar with rvm you can install using that method as you please. But for now I will just use rbenv.
Installing with rbenv
is a simple two step process. First you install rbenv
, and then ruby-build
:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<span class="pln">cd git clone git</span><span class="pun">:</span><span class="com">//github.com/sstephenson/rbenv.git .rbenv</span><span class="pln"> echo </span><span class="str">'export PATH="$HOME/.rbenv/bin:$PATH"'</span> <span class="pun">>></span> <span class="pun">~/.</span><span class="pln">bashrc echo </span><span class="str">'eval "$(rbenv init -)"'</span> <span class="pun">>></span> <span class="pun">~/.</span><span class="pln">bashrc </span><span class="kwd">exec</span><span class="pln"> $SHELL git clone git</span><span class="pun">:</span><span class="com">//github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build</span><span class="pln"> echo </span><span class="str">'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"'</span> <span class="pun">>></span> <span class="pun">~/.</span><span class="pln">bashrc </span><span class="kwd">exec</span><span class="pln"> $SHELL rbenv install </span><span class="lit">2.2</span><span class="pun">.4</span><span class="pln"> rbenv </span><span class="kwd">global</span> <span class="lit">2.2</span><span class="pun">.4</span><span class="pln"> ruby </span><span class="pun">-</span><span class="pln">v</span> |
Install bundler using gem to get out from dependency hell, and ensures that the gems you need are present.
1 |
<span class="pln">gem install bundler</span> |
Install nodejs and npm for frontend dependencies
1 |
<span class="pln">sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install nodejs nodejs</span><span class="pun">-</span><span class="pln">legacy npm </span> |
Install bower using npm
1 |
<span class="pln">sudo npm install bower </span><span class="pun">--</span><span class="kwd">global</span> |
Install necessary development libraries needed
1 |
<span class="pln">sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install <span class="pln">libreadline</span><span class="pun">-</span><span class="pln">gplv2</span><span class="pun">-</span><span class="pln">dev</span> libncurses5</span><span class="pun">-</span><span class="pln">dev zlib</span><span class="pun">-</span><span class="pln">devel ncurses</span><span class="pun">-</span><span class="pln">devel </span><span class="pln">libssl</span><span class="pun">-</span><span class="pln">dev libmysqlclient</span><span class="pun">-</span><span class="pln">dev</span> |
Install MySQL Server
To install MySQL, run the following command from a terminal prompt:
1 |
<span class="cmd command">sudo apt-get install mysql-server</span> |
During the installation process you will be prompted to enter a password for the MySQL root user.
Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:
1 |
<span class="cmd command">sudo netstat -tap | grep mysql</span> |
When you run this command, you should see the following line or something similar:
1 |
tcp 0 0 localhost:mysql *:* LISTEN 2556/mysqld |
If the server is not running correctly, you can type the following command to start it:
1 |
<span class="cmd command">sudo service mysql restart</span> |
To install redis, please follow the instruction written here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis
Install nginx for websockets, traffic hosting and handling to be used in SkyHopper System.
1 |
<span class="cmd command">sudo apt-get install nginx</span> |
You will probably be prompted for your user's password. Enter it to confirm that you wish to complete the installation. The appropriate software will be downloaded to your server and then automatically installed.
We can make sure that our web server will restart automatically when the server is rebooted by typing:
1 |
<span class="cmd command">sudo update-rc.d nginx defaults</span> |
Then we need to remove the default variable of nginx to replace it with SkyHopper
1 |
<span class="pln">sudo rm </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="kwd">default</span> |
Then copy the reverse proxy to setup nginx. You might need to change some variables written as it needs to correspond to your skyhopper setup, for example the directory of your skyhopper files are located.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$ sudo tee /etc/nginx/conf.d/skyhopper.conf <span class="pl-s"><span class="pl-k"><<</span><span class="pl-k">EOF</span> >/dev/null</span> <span class="pl-s">server {</span> <span class="pl-s"> listen 80;</span> <span class="pl-s"> server_name skyhopper.local; #Setup Environment</span> <span class="pl-s"> ### Production only runs here ###</span> <span class="pl-s"> location ~ ^/(assets|fonts) {</span> <span class="pl-s"> root /home/ec2-user/skyhopper/public; # The location of skyhopper cloned directory</span> <span class="pl-s"> }</span> <span class="pl-s"> ### Only when running production environment ###</span> <span class="pl-s"> location / {</span> <span class="pl-s"> proxy_set_header X-Real-IP \$remote_addr;</span> <span class="pl-s"> proxy_set_header Host \$http_host;</span> <span class="pl-s"> proxy_pass http://127.0.0.1:3000;</span> <span class="pl-s"> }</span> <span class="pl-s"> location /ws {</span> <span class="pl-s"> proxy_http_version 1.1;</span> <span class="pl-s"> proxy_set_header Upgrade \$http_upgrade;</span> <span class="pl-s"> proxy_set_header Connection "upgrade";</span> <span class="pl-s"> proxy_set_header Host \$http_host;</span> <span class="pl-s"> proxy_pass http://127.0.0.1:3210;</span> <span class="pl-s"> }</span> <span class="pl-s">}</span> <span class="pl-s"><span class="pl-k">EOF</span></span> |
Downloading/Cloning SkyHopper from GitHub
1 2 |
$ <span class="pl-c1">cd</span> <span class="pl-k">~</span> <span class="pl-c">#the directory where you want to install SkyHopper</span> $ git clone https://github.com/skyarch-networks/skyhopper.git |
Up to this point it can be executed by Chef.
Creating MySQL user
1 |
$ mysql -uroot |
development
1 2 3 4 |
mysql<span class="pl-k">></span> CREATE USER <span class="pl-s"><span class="pl-pds">'</span>skyhopper_dev<span class="pl-pds">'</span></span>@<span class="pl-s"><span class="pl-pds">'</span>localhost<span class="pl-pds">'</span></span> IDENTIFIED BY <span class="pl-s"><span class="pl-pds">'your_dev_password</span><span class="pl-pds">'</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> GRANT CREATE, SHOW DATABASES ON <span class="pl-k">*</span>.<span class="pl-k">*</span> TO <span class="pl-s"><span class="pl-pds">'</span>skyhopper_dev<span class="pl-pds">'</span></span>@<span class="pl-s"><span class="pl-pds">'</span>localhost<span class="pl-pds">'</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON <span class="pl-s"><span class="pl-pds">`</span>SkyHopperDevelopment<span class="pl-pds">`</span></span>.<span class="pl-k">*</span> TO <span class="pl-s"><span class="pl-pds">'</span>skyhopper_dev<span class="pl-pds">'</span></span>@<span class="pl-s"><span class="pl-pds">'</span>localhost<span class="pl-pds">'</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> <span class="pl-c1">exit</span> |
production
1 2 3 4 5 |
mysql<span class="pl-k">></span> SET storage_engine=INNODB<span class="pl-k">;</span> mysql<span class="pl-k">></span> CREATE USER <span class="pl-s"><span class="pl-pds">'</span>skyhopper_prod<span class="pl-pds">'</span></span>@<span class="pl-s"><span class="pl-pds">'</span>localhost<span class="pl-pds">'</span></span> IDENTIFIED BY <span class="pl-s"><span class="pl-pds">'your_prod_password</span><span class="pl-pds">'</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> CREATE DATABASE IF NOT EXISTS <span class="pl-s"><span class="pl-pds">`</span>SkyHopperProduction<span class="pl-pds">`</span></span> DEFAULT CHARACTER SET <span class="pl-s"><span class="pl-pds">`</span>utf8<span class="pl-pds">`</span></span> COLLATE <span class="pl-s"><span class="pl-pds">`</span>utf8_unicode_ci<span class="pl-pds">`</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON <span class="pl-s"><span class="pl-pds">`</span>SkyHopperProduction<span class="pl-pds">`</span></span>.<span class="pl-k">*</span> TO <span class="pl-s"><span class="pl-pds">'</span>skyhopper_prod<span class="pl-pds">'</span></span>@<span class="pl-s"><span class="pl-pds">'</span>localhost<span class="pl-pds">'</span></span><span class="pl-k">;</span> mysql<span class="pl-k">></span> <span class="pl-c1">exit</span> |
SkyHopper Setup
1 |
$ <span class="pl-c1">cd</span> skyhopper |
bundle install
1 |
$ bundle install --path vendor/bundle |
bower install
1 |
$ bower install |
Compiling TypeScript
1 2 3 4 5 6 |
$ sudo npm i -g gulp $ <span class="pl-c1">cd</span> frontend/ $ npm i $ gulp tsd $ gulp ts $ <span class="pl-c1">cd</span> .. |
database.yml
1 |
$ cp config/database_default.yml config/database.yml |
development
1 2 3 4 5 6 7 8 |
<span class="pl-s"><span class="pl-ent">default:</span> <span class="pl-s">&default</span></span> <span class="pl-s"><span class="pl-ent">adapter:</span> <span class="pl-s">mysql2</span></span> <span class="pl-s"><span class="pl-ent">encoding:</span> <span class="pl-s">utf8</span></span> <span class="pl-c1"><span class="pl-ent">pool:</span> 5</span> <span class="pl-s"><span class="pl-ent">username:</span> <span class="pl-s">skyhopper_dev</span></span> <span class="pl-s"><span class="pl-ent">password:</span> <span class="pl-s"><span class="pl-pds">'your_dev_password</span><span class="pl-pds">'</span></span> </span><span class="pl-c">#development password that you set earlier socket: /var/run/mysqld/mysqld.sock </span> |
production
1 2 3 4 5 |
<span class="pl-s"><span class="pl-ent">production:</span></span> <span class="pl-s"><span class="pl-ent"><<:</span> <span class="pl-s">*default</span></span> <span class="pl-s"><span class="pl-ent">database:</span> <span class="pl-s">SkyHopperProduction</span></span> <span class="pl-s"><span class="pl-ent">username:</span> <span class="pl-s">skyhopper_prod</span></span> <span class="pl-s"><span class="pl-ent">password:</span> <span class="pl-s"><span class="pl-pds">'your_prod_password</span><span class="pl-pds">'</span></span> </span><span class="pl-c">#production password that you set earlier</span> |
Database Setup
Creating database using rake
1 |
$ bundle <span class="pl-c1">exec</span> rake db:create |
Creating tables using rake
1 2 3 4 |
<span class="pl-c"># development</span> $ bundle <span class="pl-c1">exec</span> rake db:migrate <span class="pl-c"># production</span> $ bundle <span class="pl-c1">exec</span> rake db:migrate RAILS_ENV=production |
creating initial data using rake
1 2 3 4 |
<span class="pl-c"># development</span> $ bundle <span class="pl-c1">exec</span> rake db:seed <span class="pl-c"># production</span> $ bundle <span class="pl-c1">exec</span> rake db:seed RAILS_ENV=production |
Start
Running Skyhopper
1 2 3 4 |
<span class="pl-c"># production</span> $ ./scripts/skyhopper_daemon.sh start <span class="pl-c"># usage start|stop|status</span> <span class="pl-c"># staring mode for daemon</span> |
1 2 3 |
<span class="pl-c"># for development</span> $ ./scripts/dev_server.sh <span class="pl-c"># to stop/exit, press: Ctrl + C</span> |
Initializing settings for SkyHopper
Perform the initial set up from the browser by accessing SkyHopper
Establishing the Chef Server keys
Copy the installation files under the project directory of SkyHopper tmp/chef
to ~/.chef
1 |
$ cp -r <span class="pl-k">~</span>/skyhopper/tmp/chef <span class="pl-k">~</span>/.chef |
Congratulations! You have successfully install skyhopper in your system. If you encountered any problems during installation please write comments below. Thank you!