옛글/Ubuntu

우분투에 Ruby / Nginx / Rails / Certbot 설치하기

ShakeJ 2017. 2. 23. 12:42
반응형

우분투에 Ruby / Nginx / Rails 설치하기 


#Ruby 관련 라이브러리 설치

sudo -s 

sudo apt-get update

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


#Rbenv 설치하기

cd git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(rbenv init -)"' >> ~/.bash_profile git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile


vi ~/.gemrc

install: --no-rdoc --no-ri update: --no-rdoc --no-ri


rbenv install -v 2.5.0

rbenv global 2.5.0

ruby -v

echo "gem: --no-document" > ~/.gemrc


#Rails 설치하기

gem install bundler

gem install rails

rbenv rehash


sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get update

sudo apt-get install nodejs


#Mysql 설치하기

sudo apt-get install mysql-server mysql-client libmysqlclient-dev



#Setting Database


mysql -p

mysql> CREATE DATABASE [database_name] CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;


sudo /etc/init.d/mysql start


#Install nginx


sudo apt-get install nginx


#Install ElasticSearch


sudo add-apt-repository -y ppa:webupd8team/java

sudo apt-get update

sudo apt-get -y install oracle-java8-installer

java -version

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-2.2.0.deb

sudo dpkg -i elasticsearch-2.2.0.deb

service elasticsearch start


#Install Redis


sudo apt-get install build-essential tcl

cd /tmp

curl -O http://download.redis.io/redis-stable.tar.gz

tar xzvf redis-stable.tar.gz

cd redis-stable

make

sudo make install

cd utils

sudo ./install_server.sh

sudo service redis_6379 start


#Install Sendmail 


sudo apt-get install sendmail

sudo vim /etc/hosts


127.0.1.1 yourhost yourhost 

127.0.0.1 localhost


sudo sendmailconfig



#마지막 세팅


database.yml & secrets.yml 추가 후 수정하기 

mkdir current/shared/sockets 

mkdir current/shared/pids

nginx sites-enabled config 추가하기 


++ Cert bot 사용 시 16.04 기준 

https://certbot.eff.org/#ubuntuxenial-nginx


sudo apt-get install letsencrypt

letsencrypt certonly --standalone -d example.com



++ Rails 서버에서 console 이 실행안될 때 


bundle exec rake rails:update:bin


++ Rbenv user 에게도 사용하도록 


http://alexanderzagaynov.com/rbenv-shared-install-on-ubuntu-14-04/

sudo vim /etc/profile


export RBENV_ROOT=/usr/local/rbenv 

export PATH="$RBENV_ROOT/bin:$PATH" 

if which rbenv > /dev/null; then eval "$(rbenv init - --no-rehash)"; fi


반응형