Skip to content

Instantly share code, notes, and snippets.

@mehtaparitosh
Last active April 24, 2018 07:14
Show Gist options
  • Save mehtaparitosh/4cfb4e4ed05c46609058bca9aaad403f to your computer and use it in GitHub Desktop.
Save mehtaparitosh/4cfb4e4ed05c46609058bca9aaad403f to your computer and use it in GitHub Desktop.
1. Installing Ruby
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
use sudo wget https://.......... --no-check-certificate to download things that are disallowed
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs yarn
cd
sudo wget http://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.gz
tar -xzvf ruby-2.5.0.tar.gz
cd ruby-2.5.0/
./configure
make
sudo make install
ruby -v
2. Install Node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
3. Install Bundler
gem install bundler
4. Configuring Git
git config --global color.ui true
git config --global user.name "USERNAME"
git config --global user.email "[email protected]"
// Password:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
The next step is to take the newly generated SSH key and add it to your Github account. You want to copy and paste the output of the following command and paste it here: https://github.com/settings/ssh
cat ~/.ssh/id_rsa.pub
//Check
ssh -T [email protected]
5. Installing Rails
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
gem install rails -v 5.1.4
//rbenv rehash
rails -v
6. Setting Up MySQL
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'i***coapp'@'localhost' IDENTIFIED BY 'PASSWORD';
\q
mysql -u i***oapp -p
CREATE DATABASE i****coapp_production
7. Install Passenger packages
sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y nginx-extras passenger
8. Enable the Passenger Nginx module and restart Nginx
Edit /etc/nginx/nginx.conf and uncomment include /etc/nginx/passenger.conf;. For example, you may see this:
# include /etc/nginx/passenger.conf;
Remove the '#' characters, like this:
include /etc/nginx/passenger.conf;
sudo service nginx restart
9. Check Installation
After installation, please validate the install by running
sudo /usr/bin/passenger-config validate-install
sudo /usr/sbin/passenger-memory-stats
10. Pull Code From Git repository && Bundle Install
git clone https://github.com/mehtaparitosh/i****coapp.git
bundle install --deployment --without development test
11. Configure database.yml and secrets.yml
Add MySQL password to database.yml as well as chart.py file.
bundle exec rake secret
Add secret key to secrets.yml and devise in initializers
chmod 700 config db
chmod 600 config/database.yml config/secrets.yml
12. Compile Rails assets and run database migrations
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
13. Edit Nginx configuration file
We need to create an Nginx configuration file and setup a virtual host entry that points to your app. This virtual host entry tells Nginx (and Passenger) where your app is located.
sudo nano /etc/nginx/sites-enabled/myapp.conf
Replace myapp with your app's name.
Put this inside the file:
server {
listen 80;
server_name yourserver.com;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/myapp/code/public;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /path-to-ruby;
}
Replace yourserver.com with your server's host name, and replace /var/www/myapp/code with your application's code directory path. However, make sure that Nginx is configured to point to the public subdirectory inside it!
Replace /path-to-ruby with the Ruby command that you obtained in step 3.1.
When you are done, restart Nginx:
sudo service nginx restart
14. Deploying application updates
//inside the app
git pull
Add MySQL password to database.yml as well as chart.py file.
bundle exec rake secret
Add secret key to secrets.yml and devise in initializers
bundle install --deployment --without development test
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
passenger-config restart-app $(pwd)
ISSUES:
1- How to add new Users:
go to users/sign_up to create new users
- Change entry in users table in mysql to create admin user
2- Images not showing:
must be a problem with asset pipeline changing the names of the images
3- View page not working:
add 5 previous entries to 'entries' table from month 11-2107 to 3-2018
4- Download Button not working
run python python/chart.py and figure out what is wrong
-install pip
- python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
- sudo pip install mysql-connector
- sudo easy_install mysql-connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment