기본 콘텐츠로 건너뛰기

CentOS 6.7 + Mysql 5.6 + rbenv ruby rails + nginx ( + rubymine + vagrant chef )

설치 하다가 빡쳐서 정리함.

내용은 주로 digitalocean + qiita 등에 있는걸로 정리하였음.





일단 내가 사용할 서버에 CentOS 7 USB 가 정상적으로 인스톨 되지 않는 문제로 내키지 않았지만 CentOS 6.7 을 설치함.

그런데 이게 Mysql 5.1 이 yum repo 에 있어서 버전을 올릴 필요가 있었음.




1. setup CentOS

$ su

$ /usr/sbin/visudo
 
# User privilege specification
root    ALL=(ALL)       ALL
# add user id
demo    ALL=(ALL)       ALL 
 

$ yum install ibus ibus-hangul ibus-anthy
 
 
$ rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

$ rpm -Uvh http://mirror.premi.st/epel/6/i386/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 
 




 
 
2. install MYSQL
 

$ rpm -qa | grep mysql
 
$ sudo yum remove mysql*
 
$ sudo yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
$ sudo yum install mysql-client mysql-server
 
$ rpm -qa | grep mysql 
mysql-community-release-el6-5.noarch
mysql-community-server-5.6.20-4.el6.x86_64
mysql-community-common-5.6.20-4.el6.x86_64
mysql-community-client-5.6.20-4.el6.x86_64
mysql-community-libs-5.6.20-4.el6.x86_64
 


$ mysql -version 
 
$ sudo /etc/init.d/mysqld start
$ sudo mysql -uroot -p
 
password change 
 
mysql> set password = password('New Pass'); 
mysql> exit
 
$ sudo chkconfig mysqld on
 
$ sudo chkconfig | grep mysql
 
 
 

3. install rbenv 

$ sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
 
$ 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
$ exec $SHELL

$ 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
$ exec $SHELL -l
 


4. install ryby

$ rbenv install -v 2.2.0
$ rbenv global 2.2.0
 
$ ruby -v
 
$ echo "gem: --no-document" > ~/.gemrc
 
$ gem install bundler
 
 

5. isntall Rails
 
$ gem install rails -v 4.2.0
$ rbenv rehash
$ rails -v
 
 

6. isntall Javascript Runtime
 
$ sudo yum -y install epel-release
 
$ sudo yum install nodejs
 



7. create test application
 
$ cd /srv
$ mkdir www
 
$ sudo chown demo:demo -R www/
 
$ cd /srv/www
 
$ rails new testapp 

$ cd testapp

$ rake db:create
 
$ rails s
 
 
 
- end -
 
 
 
http://localhost:3000


 
install nginx
 
default nginx 1.0.... upgrade 1.8.
{
    $ sudo rm /var/run/nginx.pid
} 
 
$ sudo vim /etc/yum.repos.d/nginx.repo 

 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
 
$ yum --enablerepo=nginx install nginx

{
    $ sudo /etc/init.d/nginx restart 
} 
 
install unicorn 
$ gem install unicorn
 

# Create a sample resource
$ rails generate scaffold Task title:string note:text

# Create a sample database
$ RAILS_ENV=development rake db:migrate
$ RAILS_ENV=production  rake db:migrate

# Create a directory to hold the PID files
$ mkdir pids    
 

Configuring Server 
 
$ vim config/unicorn.rb 
 
 
# Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/srv/www/testapp"

# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/srv/www/testapp/pids/unicorn.pid"

# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/srv/www/testapp/log/unicorn.log"
stdout_path "/srv/www/testapp/log/unicorn.log"

# Unicorn socket
listen "/tmp/unicorn.testapp.sock"

# Number of processes
# worker_processes 4
worker_processes 2

# Time-out
timeout 30 
 
 
$ vim /etc/nginx/conf.d/default.conf 


upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/tmp/unicorn.testapp.sock fail_timeout=0;
}

server {


    listen 80;
    server_name localhost;

    # Application root, as defined previously
    root /srv/www/testapp/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
} 
 
 
$ unicorn_rails -c config/unicorn.rb -D 
 
$ sudo service nginx restart 



아직 정리 전인데 사용 가능한 "rubymine + vagrant"
  

http://qiita.com/Avene/items/3f5bedbb48bbd18fc1c4

댓글

이 블로그의 인기 게시물

mac os + perl catalyst

맥 엘... 머를 사용하고 있다. 펄은 최신버전이 설치 되어 있다. cpan 모듈부터 설치한다. $ cpan App::cpanminus 바로 스마트시디 설치한다. $ https://github.com/cxreg/smartcd 그런데 zsh 쓰고 있어서 source 하면 터미널이 튕겨 버린다. 이렇게 하면 됨. $ source $HOME/.smartcd/lib/core/smartcd ( https://github.com/cxreg/smartcd/issues/25) 깃에 연동해야 하니까 ssh 키도 만든다. $ ssh-keygen 그런데 문제가 생기기는 한다... ivalid version format (version required) at /perl5/lib/perl5/Module/Runtime.pm line 386. BEGIN failed--compilation aborted at /perl5/lib/perl5/Catalyst/ScriptRunner.pm line 2. Compilation failed in require at Web/script/web_server.pl line 7. BEGIN failed--compilation aborted at Web/script/web_server.pl line 7. 뭐 대충 이런건데..... Moose 업데이트 하면 된다. cpanm Moose 이 때 PATH 경로안에  Moose 가 포함 되어 있어야 한다. 그냥 cpan 설치 할 때 moose도 포함 시켜서 한번에 인스톨하면 편함. 이제 맥에 포스트그래스만 설치하면 되는데...

전자정부 이클립스 스프링 부트

  1. 전자정부 이클립스 IDE 다운로드 2. 압축 해제후 실행.  Template Project 만들기. (아직은 Single 뿐이다.)

중 상급자가되기위한 JavaScript 【지식 편]

qiita : http://qiita.com/KENJU/items/c7fad62a12cc2809b507?utm_source=Qiita%E3%83%8B%E3%83%A5%E3%83%BC%E3%82%B9&utm_campaign=a25a5e9683-Qiita_newsletter_166_07_22_2015&utm_medium=email&utm_term=0_e44feaa081-a25a5e9683-32972029 그대로 복붙 해도 상관 없지만 나도 좀 보면서 정리 해야 되니까 조금씩 정리. 1. Basic Tips Index 1-1. 글로벌 변수를 남용하지 않는다. 1-2. for 루프 1-3. 암시 적 변환을 피하기 1-1. 글로벌 변수를 남용하지 않는다. , 타사 플러그인을 읽을 때 변수의 충돌 팀 구성원이 작성한 코드와 이름 충돌 옛날 쓴 자신의 코드에서 사용한 변수와 충돌 대책 : var JavaScript 는 var  없이 정의된 변수는 전역 변수로 스켄된다. function speakOut () { // global variable global = "Hello from global" ; // local variable var local = "Hello from local" ; console . log ( global ); console . log ( local ); } speakOut (); console . log ( global ); console . log ( local ); 대책 : 네임 스페이스를 사용 // Object for name space var myApp = {}; myApp . name = "My First JavaScript App" ; 대책 : 클로저를 이용. ( function (){ maybe_global = "...