Skip to content

Instantly share code, notes, and snippets.

@beansme
Forked from jtadeulopes/server.md
Created December 14, 2015 14:50
Show Gist options
  • Save beansme/83fc48920fa89519cfbd to your computer and use it in GitHub Desktop.
Save beansme/83fc48920fa89519cfbd to your computer and use it in GitHub Desktop.

Revisions

  1. @jtadeulopes jtadeulopes revised this gist Sep 11, 2015. 1 changed file with 38 additions and 28 deletions.
    66 changes: 38 additions & 28 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -36,25 +36,23 @@ ubuntu ALL=NOPASSWD: ALL
    Edit `/etc/profile`

    ```
    export PATH=/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    export PATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    export RAILS_ENV=production
    export GEM_HOME=/opt/ruby/gems
    export LC_ALL=en_US.UTF-8
    ```

    Edit `/etc/environment`

    ```
    PATH=/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    PATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    RAILS_ENV=production
    GEM_HOME=/opt/ruby/gems
    LC_ALL=en_US.UTF-8
    ```

    Edit `/etc/sudoers`

    ```
    Defaults secure_path="/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    Defaults secure_path="/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    ```

    ## Some libraries for Mysql, ImageMagick, Node, etc
    @@ -67,7 +65,11 @@ sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagi

    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    ```

    Compiled:

    ```
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.4.tar.gz
    tar xvfz ruby-2.1.4.tar.gz
    cd ruby-2.1.4/
    @@ -77,30 +79,20 @@ sudo make install
    sudo gem install bundler
    ```

    ## GIT
    Package:

    ```
    sudo apt-get build-dep git-core
    wget https://git-core.googlecode.com/files/git-1.8.5.4.tar.gz
    tar xvfz git-1.8.5.4.tar.gz
    cd git-1.8.5.4/
    ./configure
    make
    sudo make install
    wget -q -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add -
    echo 'deb [arch=amd64] http://apt.hellobits.com/ trusty main' | sudo tee /etc/apt/sources.list.d/hellobits.list
    sudo apt-get update
    sudo apt-get install ruby-2.2
    sudo gem install bundler
    ```

    ## OpenSSL
    ## GIT

    ```
    cd /opt
    wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
    tar xvfz openssl-1.0.1j.tar.gz
    sudo mv openssl-1.0.1j openssl
    cd openssl/
    ./config
    make
    sudo make install
    sudo apt-get install git
    ```

    ## VIM
    @@ -128,12 +120,25 @@ set shiftwidth=4
    set expandtab
    ```

    ## OpenSSL

    ```
    cd /opt
    sudo wget http://www.openssl.org/source/openssl-1.0.1p.tar.gz
    sudo tar xvfz openssl-1.0.1p.tar.gz
    sudo mv openssl-1.0.1p openssl
    cd openssl/
    sudo ./config
    sudo make
    sudo make install
    ```

    ## Nginx

    ```
    wget http://nginx.org/download/nginx-1.7.6.tar.gz
    tar xvfz nginx-1.7.6.tar.gz
    cd nginx-1.7.6/
    wget http://nginx.org/download/nginx-1.9.4.tar.gz
    tar xvfz nginx-1.9.4.tar.gz
    cd nginx-1.9.4/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/opt/openssl
    sudo make
    sudo make install
    @@ -178,11 +183,16 @@ sudo adduser deploy
    ### SSH keys

    ```
    su deploy
    sudo -iu deploy
    ssh-keygen -t rsa
    ```

    See https://help.github.com/articles/generating-ssh-keys#platform-linux
    ### Add authorized keys

    ```
    cd
    vim .ssh/authorized_keys
    ```

    ### Create folder to deploy the app

  2. @jtadeulopes jtadeulopes revised this gist Nov 5, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -131,11 +131,11 @@ set expandtab
    ## Nginx

    ```
    wget http://nginx.org/download/nginx-1.5.10.tar.gz
    tar xvfz nginx-1.5.10.tar.gz
    cd nginx-1.5.10/
    wget http://nginx.org/download/nginx-1.7.6.tar.gz
    tar xvfz nginx-1.7.6.tar.gz
    cd nginx-1.7.6/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/opt/openssl
    make
    sudo make
    sudo make install
    ```

  3. @jtadeulopes jtadeulopes revised this gist Nov 5, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -68,9 +68,9 @@ sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagi
    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
    tar xvfz ruby-2.1.2.tar.gz
    cd ruby-2.1.2/
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.4.tar.gz
    tar xvfz ruby-2.1.4.tar.gz
    cd ruby-2.1.4/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
    @@ -94,9 +94,9 @@ sudo make install

    ```
    cd /opt
    wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
    tar xvfz openssl-1.0.1g.tar.gz
    sudo mv openssl-1.0.1g openssl
    wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
    tar xvfz openssl-1.0.1j.tar.gz
    sudo mv openssl-1.0.1j openssl
    cd openssl/
    ./config
    make
  4. @jtadeulopes jtadeulopes revised this gist Jul 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -218,7 +218,7 @@ sudo (start|restart|stop) project

    ```
    cd my/project/path/config
    wget https://gist.github.com/jtadeulopes/7265503/raw/25ce868f791fd0f79b7f4fe4be81fd4b31f46b69/puma.rb
    Download the file https://gist.github.com/jtadeulopes/7265503
    ```

    ## Monit
  5. @jtadeulopes jtadeulopes revised this gist Jul 10, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -244,6 +244,7 @@ Restart monit

    ```
    sudo /etc/init.d/monit restart
    ```

    ## Bower

  6. @jtadeulopes jtadeulopes revised this gist Jul 10, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -243,4 +243,11 @@ set daemon 60
    Restart monit

    ```
    sudo /etc/init.d/monit restart
    sudo /etc/init.d/monit restart
    ## Bower
    ```
    sudo ln -s /usr/bin/nodejs /usr/bin/node
    sudo npm install -g bower
    ```
  7. @jtadeulopes jtadeulopes revised this gist Jul 9, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,7 @@ cd ruby-2.1.2/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
    sudo gem install bundle
    sudo gem install bundler
    ```

    ## GIT
  8. @jtadeulopes jtadeulopes revised this gist Jul 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -179,7 +179,7 @@ sudo adduser deploy

    ```
    su deploy
    ssh-keygen -T rsa
    ssh-keygen -t rsa
    ```

    See https://help.github.com/articles/generating-ssh-keys#platform-linux
  9. @jtadeulopes jtadeulopes revised this gist Jul 8, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -74,6 +74,7 @@ cd ruby-2.1.2/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
    sudo gem install bundle
    ```

    ## GIT
    @@ -176,6 +177,11 @@ sudo adduser deploy

    ### SSH keys

    ```
    su deploy
    ssh-keygen -T rsa
    ```

    See https://help.github.com/articles/generating-ssh-keys#platform-linux

    ### Create folder to deploy the app
  10. @jtadeulopes jtadeulopes revised this gist Jun 20, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ Defaults secure_path="/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/loca
    ## Some libraries for Mysql, ImageMagick, Node, etc

    ```
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagick
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagick libpq-dev
    ```

    ## Ruby
  11. @jtadeulopes jtadeulopes revised this gist May 23, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -68,9 +68,9 @@ sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagi
    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
    tar xvfz ruby-2.1.0.tar.gz
    cd ruby-2.1.0/
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
    tar xvfz ruby-2.1.2.tar.gz
    cd ruby-2.1.2/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
  12. @jtadeulopes jtadeulopes revised this gist May 6, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -92,9 +92,11 @@ sudo make install
    ## OpenSSL

    ```
    wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
    tar xvfz openssl-1.0.1f.tar.gz
    cd openssl-1.0.1f/
    cd /opt
    wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
    tar xvfz openssl-1.0.1g.tar.gz
    sudo mv openssl-1.0.1g openssl
    cd openssl/
    ./config
    make
    sudo make install
    @@ -131,7 +133,7 @@ set expandtab
    wget http://nginx.org/download/nginx-1.5.10.tar.gz
    tar xvfz nginx-1.5.10.tar.gz
    cd nginx-1.5.10/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/home/ubuntu/src/openssl-1.0.1f/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/opt/openssl
    make
    sudo make install
    ```
  13. @jtadeulopes jtadeulopes revised this gist Mar 12, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ Defaults secure_path="/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/loca
    ## Some libraries for Mysql, ImageMagick, Node, etc

    ```
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm imagemagick
    ```

    ## Ruby
  14. @jtadeulopes jtadeulopes revised this gist Feb 24, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ Defaults secure_path="/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/loca
    ## Some libraries for Mysql, ImageMagick, Node, etc

    ```
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs npm
    ```

    ## Ruby
  15. @jtadeulopes jtadeulopes revised this gist Feb 24, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -148,6 +148,7 @@ sudo mkdir /var/log/nginx
    sudo mkdir sites-enabled
    cd sites-enabled
    Download the file https://gist.github.com/jtadeulopes/7237731
    Or with SSL support https://gist.github.com/jtadeulopes/9189120
    ```

    ### Upstart script
  16. @jtadeulopes jtadeulopes revised this gist Feb 13, 2014. 1 changed file with 22 additions and 15 deletions.
    37 changes: 22 additions & 15 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -68,9 +68,9 @@ sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs
    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz
    tar xvfz ruby-2.0.0-p247.tar.gz
    cd ruby-2.0.0-p247/
    wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz
    tar xvfz ruby-2.1.0.tar.gz
    cd ruby-2.1.0/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
    @@ -81,9 +81,9 @@ sudo make install
    ```
    sudo apt-get build-dep git-core
    wget https://git-core.googlecode.com/files/git-1.8.4.2.tar.gz
    tar xvfz git-1.8.4.2.tar.gz
    cd git-1.8.4.2/
    wget https://git-core.googlecode.com/files/git-1.8.5.4.tar.gz
    tar xvfz git-1.8.5.4.tar.gz
    cd git-1.8.5.4/
    ./configure
    make
    sudo make install
    @@ -92,9 +92,9 @@ sudo make install
    ## OpenSSL

    ```
    wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
    tar xvfz openssl-1.0.1e.tar.gz
    cd openssl-1.0.1e/
    wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
    tar xvfz openssl-1.0.1f.tar.gz
    cd openssl-1.0.1f/
    ./config
    make
    sudo make install
    @@ -104,7 +104,14 @@ sudo make install

    ### Syntax highlighting for Nginx in VIM

    See http://zduck.com/2012/syntax-highlighting-for-nginx-in-vim
    ```
    sudo mkdir /etc/vim/syntax
    sudo curl http://www.vim.org/scripts/download_script.php?src_id=14376 -o /etc/vim/syntax/nginx.vim
    cd /etc/vim
    Download de the file https://gist.github.com/jtadeulopes/8978872
    ```

    For more detail, see http://zduck.com/2012/syntax-highlighting-for-nginx-in-vim

    ### Global settings

    @@ -121,10 +128,10 @@ set expandtab
    ## Nginx

    ```
    wget http://nginx.org/download/nginx-1.5.7.tar.gz
    tar xvfz nginx-1.5.7.tar.gz
    cd nginx-1.5.7/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/home/ubuntu/src/openssl-1.0.1e/
    wget http://nginx.org/download/nginx-1.5.10.tar.gz
    tar xvfz nginx-1.5.10.tar.gz
    cd nginx-1.5.10/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/home/ubuntu/src/openssl-1.0.1f/
    make
    sudo make install
    ```
    @@ -227,4 +234,4 @@ set daemon 60
    Restart monit

    ```
    sudo /etc/init.d/monit restart
    sudo /etc/init.d/monit restart
  17. @jtadeulopes jtadeulopes revised this gist Dec 11, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -218,7 +218,7 @@ cd /etc/monit/conf.d
    Download the file https://gist.github.com/jtadeulopes/7270279
    ```

    Edit `/etc/monitrc`
    Edit `/etc/monit/monitrc`

    ```
    set daemon 60
  18. @jtadeulopes jtadeulopes revised this gist Dec 11, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -158,16 +158,16 @@ sudo (start|restart|stop) nginx

    ## Deploy

    ### SSH keys

    See https://help.github.com/articles/generating-ssh-keys#platform-linux

    ### Add user

    ```
    sudo adduser deploy
    ```

    ### SSH keys

    See https://help.github.com/articles/generating-ssh-keys#platform-linux

    ### Create folder to deploy the app

    ```
  19. @jtadeulopes jtadeulopes revised this gist Dec 11, 2013. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -134,18 +134,20 @@ sudo make install
    ```
    cd /opt/nginx/conf
    sudo rm nginx.conf
    sudo wget https://gist.github.com/jtadeulopes/7237669/raw/0e009788386cc42c6919892f508feb2b72ea991d/nginx.conf
    Download the file https://gist.github.com/jtadeulopes/7237669
    sudo mkdir /var/log/nginx
    sudo mkdir sites-enabled
    cd sites-enabled
    sudo wget https://gist.github.com/jtadeulopes/7237731/raw/65ffd7a834c24f389ac06b96bd8492d80cc60259/localhost.conf
    Download the file https://gist.github.com/jtadeulopes/7237731
    ```

    ### Upstart script

    ```
    cd /etc/init
    sudo wget https://gist.github.com/jtadeulopes/7237115/raw/594f0904b8e52c7001430727b6925d6298258432/nginx.conf
    Download the file https://gist.github.com/jtadeulopes/7237115
    ```

    Now, you can run:
  20. @jtadeulopes jtadeulopes revised this gist Dec 11, 2013. 1 changed file with 18 additions and 5 deletions.
    23 changes: 18 additions & 5 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,20 @@ sudo ntpdate ntp.ubuntu.com
    date
    ```

    ### Create new user

    ```
    sudo adduser ubuntu
    sudo adduser ubuntu sudo
    ```

    Edit `/etc/sudoers`

    ```
    %sudo ALL=(ALL:ALL) ALL
    ubuntu ALL=NOPASSWD: ALL
    ```

    ## Environment variables

    Edit `/etc/profile`
    @@ -54,7 +68,7 @@ sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs
    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
    wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz
    tar xvfz ruby-2.0.0-p247.tar.gz
    cd ruby-2.0.0-p247/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    @@ -107,9 +121,9 @@ set expandtab
    ## Nginx

    ```
    wget http://nginx.org/download/nginx-1.4.1.tar.gz
    tar xvfz nginx-1.4.1.tar.gz
    cd nginx-1.4.1/
    wget http://nginx.org/download/nginx-1.5.7.tar.gz
    tar xvfz nginx-1.5.7.tar.gz
    cd nginx-1.5.7/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/home/ubuntu/src/openssl-1.0.1e/
    make
    sudo make install
    @@ -212,4 +226,3 @@ Restart monit

    ```
    sudo /etc/init.d/monit restart
    ```
  21. @jtadeulopes jtadeulopes revised this gist Nov 28, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -198,7 +198,6 @@ sudo apt-get install monit
    **For each project, you must create the monit confg file**

    ```
    sudo apt-get install monit
    cd /etc/monit/conf.d
    Download the file https://gist.github.com/jtadeulopes/7270279
    ```
  22. @jtadeulopes jtadeulopes revised this gist Nov 28, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -173,8 +173,8 @@ https://gist.github.com/jtadeulopes/7249921

    ```
    cd /etc/init
    ```
    Download the file https://gist.github.com/jtadeulopes/7254953
    ```

    With the upstart for each project, you can run:

    @@ -191,15 +191,17 @@ wget https://gist.github.com/jtadeulopes/7265503/raw/25ce868f791fd0f79b7f4fe4be8

    ## Monit

    ```
    sudo apt-get install monit
    ```

    **For each project, you must create the monit confg file**

    ```
    sudo apt-get install monit
    cd /etc/monit/conf.d
    ```

    Download the file https://gist.github.com/jtadeulopes/7270279
    ```

    Edit `/etc/monitrc`

  23. @jtadeulopes jtadeulopes revised this gist Nov 28, 2013. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,7 @@ https://gist.github.com/jtadeulopes/7249921
    ```
    cd /etc/init
    ```
    Download the gist https://gist.github.com/jtadeulopes/7254953#file-project-conf
    Download the file https://gist.github.com/jtadeulopes/7254953

    With the upstart for each project, you can run:

    @@ -191,13 +191,16 @@ wget https://gist.github.com/jtadeulopes/7265503/raw/25ce868f791fd0f79b7f4fe4be8

    ## Monit

    **For each project, you must create the monit confg file**

    ```
    sudo apt-get install monit
    cd /etc/monit/conf.d
    wget https://gist.github.com/jtadeulopes/7270279/raw/61f438b221250b5a38dda7d947af03040442349a/project.conf
    ```

    Download the file https://gist.github.com/jtadeulopes/7270279

    Edit `/etc/monitrc`

    ```
    @@ -208,4 +211,4 @@ Restart monit

    ```
    sudo /etc/init.d/monit restart
    ```
    ```
  24. @jtadeulopes jtadeulopes revised this gist Nov 28, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -173,8 +173,8 @@ https://gist.github.com/jtadeulopes/7249921

    ```
    cd /etc/init
    Download the gist https://gist.github.com/jtadeulopes/7254953#file-project-conf
    ```
    Download the gist https://gist.github.com/jtadeulopes/7254953#file-project-conf

    With the upstart for each project, you can run:

  25. @jtadeulopes jtadeulopes revised this gist Nov 28, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion server.md
    Original file line number Diff line number Diff line change
    @@ -173,7 +173,7 @@ https://gist.github.com/jtadeulopes/7249921

    ```
    cd /etc/init
    sudo wget https://gist.github.com/jtadeulopes/7254953/raw/aa5a32b3713538dd84067e8ca633c5d78e75b3e4/project.conf
    Download the gist https://gist.github.com/jtadeulopes/7254953#file-project-conf
    ```

    With the upstart for each project, you can run:
  26. @jtadeulopes jtadeulopes created this gist Nov 1, 2013.
    211 changes: 211 additions & 0 deletions server.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,211 @@
    ## Update and upgrade the system

    ```
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade
    sudo apt-get autoremove
    sudo reboot
    ```

    ## Configure timezone

    ```
    sudo dpkg-reconfigure tzdata
    sudo apt-get install ntp
    sudo ntpdate ntp.ubuntu.com
    date
    ```

    ## Environment variables

    Edit `/etc/profile`

    ```
    export PATH=/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    export RAILS_ENV=production
    export GEM_HOME=/opt/ruby/gems
    export LC_ALL=en_US.UTF-8
    ```

    Edit `/etc/environment`

    ```
    PATH=/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    RAILS_ENV=production
    GEM_HOME=/opt/ruby/gems
    LC_ALL=en_US.UTF-8
    ```

    Edit `/etc/sudoers`

    ```
    Defaults secure_path="/opt/ruby/bin:/opt/nginx/sbin:/opt/ruby/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    ```

    ## Some libraries for Mysql, ImageMagick, Node, etc

    ```
    sudo apt-get install libmagickwand-dev libmysqlclient15-dev nodejs
    ```

    ## Ruby

    ```
    sudo apt-get install libyaml-dev libssl-dev libreadline-dev libxml2-dev libxslt1-dev libffi-dev build-essential
    wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
    tar xvfz ruby-2.0.0-p247.tar.gz
    cd ruby-2.0.0-p247/
    ./configure --prefix=/opt/ruby --disable-install-rdoc
    make
    sudo make install
    ```

    ## GIT

    ```
    sudo apt-get build-dep git-core
    wget https://git-core.googlecode.com/files/git-1.8.4.2.tar.gz
    tar xvfz git-1.8.4.2.tar.gz
    cd git-1.8.4.2/
    ./configure
    make
    sudo make install
    ```

    ## OpenSSL

    ```
    wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
    tar xvfz openssl-1.0.1e.tar.gz
    cd openssl-1.0.1e/
    ./config
    make
    sudo make install
    ```

    ## VIM

    ### Syntax highlighting for Nginx in VIM

    See http://zduck.com/2012/syntax-highlighting-for-nginx-in-vim

    ### Global settings

    Edit `/etc/vim/vimrc` and add the lines below

    ```
    set number
    set smartindent
    set tabstop=4
    set shiftwidth=4
    set expandtab
    ```

    ## Nginx

    ```
    wget http://nginx.org/download/nginx-1.4.1.tar.gz
    tar xvfz nginx-1.4.1.tar.gz
    cd nginx-1.4.1/
    ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/home/ubuntu/src/openssl-1.0.1e/
    make
    sudo make install
    ```

    ### Nginx settings

    ```
    cd /opt/nginx/conf
    sudo rm nginx.conf
    sudo wget https://gist.github.com/jtadeulopes/7237669/raw/0e009788386cc42c6919892f508feb2b72ea991d/nginx.conf
    sudo mkdir sites-enabled
    cd sites-enabled
    sudo wget https://gist.github.com/jtadeulopes/7237731/raw/65ffd7a834c24f389ac06b96bd8492d80cc60259/localhost.conf
    ```

    ### Upstart script

    ```
    cd /etc/init
    sudo wget https://gist.github.com/jtadeulopes/7237115/raw/594f0904b8e52c7001430727b6925d6298258432/nginx.conf
    ```

    Now, you can run:

    ```
    sudo (start|restart|stop) nginx
    ```

    ## Deploy

    ### SSH keys

    See https://help.github.com/articles/generating-ssh-keys#platform-linux

    ### Add user

    ```
    sudo adduser deploy
    ```

    ### Create folder to deploy the app

    ```
    sudo mkdir /var/www
    sudo chown deploy:deploy -c -R /var/www
    ```

    ### Capistrano

    `Capfile`
    https://gist.github.com/jtadeulopes/7249948

    `deploy.rb`
    https://gist.github.com/jtadeulopes/7249921

    ### Puma Upstart script

    **For each project, you must create the puma upstart file**

    ```
    cd /etc/init
    sudo wget https://gist.github.com/jtadeulopes/7254953/raw/aa5a32b3713538dd84067e8ca633c5d78e75b3e4/project.conf
    ```

    With the upstart for each project, you can run:

    ```
    sudo (start|restart|stop) project
    ```

    ### Puma config

    ```
    cd my/project/path/config
    wget https://gist.github.com/jtadeulopes/7265503/raw/25ce868f791fd0f79b7f4fe4be81fd4b31f46b69/puma.rb
    ```

    ## Monit

    ```
    sudo apt-get install monit
    cd /etc/monit/conf.d
    wget https://gist.github.com/jtadeulopes/7270279/raw/61f438b221250b5a38dda7d947af03040442349a/project.conf
    ```

    Edit `/etc/monitrc`

    ```
    set daemon 60
    ```

    Restart monit

    ```
    sudo /etc/init.d/monit restart
    ```