[RUBY] [EC2 / Vue / Rails] EC2 deployment procedure for Vue + Rails

table of contents

-** Ruby installation ** -** Node.js installation ** -** Vue.js installation ** -** Error && Action **

Ruby installation

◆ Install rbenv / ruby-build

$ git clone git://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ source ~/.bashrc
$ git clone git://github.com/rbenv/ruby-build.git /tmp/ruby-build
$ cd /tmp/ruby-build
$ sudo ./install.sh

◆ Ruby version specification

$ rbenv install -l
$ sudo yum -y install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel
$ rbenv install 2.7.1
$ rbenv rehash
$ rbenv global 2.7.1
$ ruby -v

◆ Install bundler / rails

$ rbenv rehash
$ gem install bundler
$ bundler -v
$ gem install rails -v 6.0.2.1
$ rails -v

Node.js installation

$ git clone https://github.com/creationix/nvm.git ~/.nvm
$ source ~/.nvm/nvm.sh
$ vim .bash_profile
###Postscript
if [ -f ~/.nvm/nvm.sh ]; then
        . ~/.nvm/nvm.sh
fi
$ nvm install 12.14.0
$ node --version
$ npm --version
$ npm install yarn -g
$ yarn --version

Vue.js installation

$ rails webpacker:install:vue
$ npm install vue-router
$ npm install -y vuex
$ npm install axios --save
$ npm install vee-validate --save
$ npm install sass-loader node-sass --save-dev
$ npm install --save-dev core-js@3
$ npm install --save vuex-persistedstate

Error && handling

◆ sassc error

//approach
$ yum update & yum install gcc gcc-c++ make

◆ sqlite3 error

$ wget https://www.sqlite.org/2019/sqlite-autoconf-3300100.tar.gz
$ tar xzvf sqlite-autoconf-3300100.tar.gz
$ cd sqlite-autoconf-3300100/
$ ./configure --prefix=/opt/sqlite/sqlite3
$ make
$ sudo yum install sqlite-devel
$ sudo make install
$ /opt/sqlite/sqlite3/bin/sqlite3 --version
$ gem install sqlite3 -- --with-sqlite3-include=/opt/sqlite/sqlite3/include --with-sqlite3-lib=/opt/sqlite/sqlite3/lib

◆ SQLite (3.7.17) is too old

//approach
$ wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm
$ wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm
$ sudo yum install sqlite-3.8.11-1.fc21.x86_64.rpm sqlite-devel-3.8.11-1.fc21.x86_64.rpm
$ yum list | grep sqlite

◆ mysql2 error

$ sudo yum install mysql-devel
$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
$ bundle install

◆ Development Tools error

approach
$ yum -y groupinstall "Development Tools"
$ yum -y install gcc-c++ glibc-headers openssl-devel readline libyaml-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel mysql-devel readline-devel

◆ ImageMagick error

approach
$ yum -y install ImageMagick ImageMagick-devel
//gcc downgrade
$ yum install gcc44
$ alternatives --set gcc /usr/bin/gcc44

References

-(Deployment ①) The most polite AWS commentary in the world. Until you bring your Rails app to AWS using EC2 -Install Ruby on EC2 (Amazon Linux2) 2020 -Building a Ruby environment on an EC2 server -Run Rails 6.0 with SQLite3 (> = 3.8) in CentOS environment -I get an error when I try to put mysql2 on Amazon Linux

Recommended Posts

[EC2 / Vue / Rails] EC2 deployment procedure for Vue + Rails
Rails Heroku deployment procedure
Launch Rails on EC2 (manual deployment)
For beginners! Automatic deployment with Rails6 + CircleCI + Capistrano + AWS (EC2)
Easy deployment with Capistrano + AWS (EC2) + Rails
[Rails] Procedure for linking databases with Ruby On Rails
Recipe for deploying Rails apps on AWS EC2
[For beginners] Procedure for creating a controller using rails
[Rails] Nginx, Puma environment deployment & server study [AWS EC2]
Launch Rails on EC2
Deploy RAILS on EC2
[Rails] Heroku deployment flow
Rails, RSpec installation procedure
[Circle CI] Procedure for automatic deployment when pushing to GitHub
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
I tried automatic deployment with CircleCI + Capistrano + AWS (EC2) + Rails
Building an environment for creating apps with Rails and Vue
docker-compose command list (for Rails)
[Vue Rails] "Hello Vue!" Displayed with Vue + Rails
Preparation for developing with Rails
(For beginners) [Rails] Install Devise
[Rails] EC site cart function
Procedure for publishing an application using AWS (7) Automatic deployment by Capistrano
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams