Created
September 26, 2014 05:51
-
-
Save fahadgudu/84454a19aad8a1ea65d5 to your computer and use it in GitHub Desktop.
Ruby on Rails Installation and EC2 Server setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EC2 installation for rails project | |
sudo apt-get update | |
sudo apt-get install build-essential libxml2 libxml2-dev libsqlite3-dev locate libssl-dev openssl autoconf | |
sudo apt-get install curl | |
\curl -L https://get.rvm.io | bash -s stable | |
source ~/.rvm/scripts/rvm | |
source ~/.profile | |
rvm requirements | |
sudo apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev | |
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config | |
sudo apt-get install pkgconfig | |
rvm install 2.0.0 | |
rvm use 2.0.0 --default | |
ruby -v | |
gem install rails -v 3.2.13 # if any version want to specify | |
sudo apt-get install | |
sudo apt-get install apache2 | |
sudo apt-get upgrade | |
sudo apt-get install libapache2-mod-php5 | |
sudo apt-get install libmysqlclient-dev | |
gem install mysql2 | |
sudo apt-get install libv8-dev | |
sudo a2enmod php5 | |
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql | |
sudo apt-get install phpmyadmin | |
sudo nano /etc/apache2/apache2.conf | |
sudo service apache2 restart | |
sudo adduser ubuntu www-data | |
sudo chown -R www-data:www-data /var/www | |
sudo chmod -R g+rw /var/www | |
sudo service apache2 restart | |
nano /var/www/index.html | |
mkdir project | |
cd project | |
git clone git@github.com:shamabbas/project.git | |
cd ~/.ssh/ | |
ssh-keygen | |
# add keys to github account | |
sudo chmod 777 -R project | |
cd project/cloned_project | |
nano config/database.yml | |
bundle install | |
gem install passenger | |
passenger-install-apache2-module | |
# gave dependencies error to install these libs first then try above command again... | |
sudo apt-get install libcurl4-openssl-dev | |
sudo apt-get install apache2-threaded-dev | |
sudo apt-get install libapr1-dev | |
sudo apt-get install libaprutil1-dev | |
passenger-install-apache2-module # ran again because of error | |
# Now apache2 module installed | |
sudo nano /etc/apache2/apache2.conf | |
# Add these lines at the bottom of file | |
# Include the virtual host configurations: | |
Include sites-enabled/ | |
Include /etc/phpmyadmin/apache.conf | |
LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.20/buildout/apache2/mod_passenger.so | |
PassengerRoot /home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.20 | |
PassengerDefaultRuby /home/ubuntu/.rvm/wrappers/ruby-2.0.0-p247/ruby | |
<VirtualHost *:80> | |
#ServerName ec2-54-210-189-000.us-west-2.compute.amazonaws.com | |
ServerName domain.com | |
ServerAlias www.domain.com | |
#ServerAlias domain.com | |
# !!! Be sure to point DocumentRoot to 'public'! | |
DocumentRoot /var/www/project/cloned_project/public | |
<Directory /var/www/project/cloned_project/public> | |
# This relaxes Apache security settings. | |
AllowOverride all | |
# MultiViews must be turned off. | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> | |
sudo /etc/init.d/apache2 restart | |
# Apache installed hit IP and see if IT WORKS! coming on page | |
cd /var/www/project/cloned_project | |
rake db:create RAILS_ENV=production && rake db:migrate RAILS_ENV=production && rake db:seed RAILS_ENV=production | |
# sometimes gives error for connectivity with mysql and errors says something about execjs | |
gem install execjs | |
sudo apt-get install nodejs | |
# Now it should work like charm! try rake db: commands and it should run! | |
# ServerAlias wasn't working saw a solution they said make this default enable using this command | |
sudo a2dissite default | |
sudo service apache2 reload | |
sudo nano /etc/apache2/sites-available/default | |
# added line | |
NameServer default | |
sudo service apache2 reload | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment