init r45 install guide on ubuntu 18.04 lts

This commit is contained in:
EricTYL 2019-11-14 15:53:48 +08:00
commit d1bc9f5436
1 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,92 @@
# Ubuntu 18.04 LTS 安裝 R4.5 標準流程
## 前置作業
* Ubuntu 18.04 LTS 已安裝完畢並能遠端連線進入
* 當前帳號可以使用 sudo 指令
## 安裝 Nginx 1.14
```sh
$ sudo apt update
$ sudo apt install ngnix
$ ngnix -v # 確認版本為 1.14
$ sudo systemctl status nginx # 查看 nginx 是否啟動
$ sudo systemctl restart nginx # 安全重啟 nginx若已啟動則可跳過此步驟
$ cd /etc/nginx/
$ sudo mkdir orbit_sites/
$ sudo vim orbit_sites/xxx_ooo # 建立網站 nginx 設定檔xxx 為學校縮寫ooo 為系所、單位縮寫。內容參考附註 nginx 設定檔
```
```nginx
# 此為附註 nginx 設定檔
# upstream xxx_sock {
upstream orbit_sock {
# server unix:/path/to/your/r45/tmp/unicorn.sock;
server unix:/home/rulingcom/orbit_sites/orbit/tmp/unicorn.sock;
}
server {
listen 80;
# root /path/to/your/r45/public;
root /home/rulingcom/orbit_sites/orbit/public;
# server_name your.website.address;
server_name localhost;
client_max_body_size 500m;
location / {
try_files $uri $uri/index.html $uri.html @app;
}
location @app {
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 360;
# proxy_pass http://xxx_sock;
proxy_pass http://orbit_sock;
}
}
```
## 安裝 MongoDB 3.2.22
```sh
$ # 匯入 MongoDB 公鑰到套件管理系統
$ wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -
$ 建立 list file
$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
$ sudo apt-get update # 更新套件管理系統
$ # 下載並安裝 MongoDB 3.2.22
$ sudo apt-get install -y mongodb-org=3.2.22 mongodb-org-server=3.2.22 mongodb-org-shell=3.2.22 mongodb-org-mongos=3.2.22 mongodb-org-tools=3.2.22
$ mongo --version # 查看 MongoDB 版本
$ sudo systemctl status mongod # 查看 MongoDB 是否啟動
$ sudo systemctl restart mongod # 安全啟動 MongoDB若已啟動則可跳過此步驟
```
## 安裝 RVM (Ruby 版本和套件的管理程式)
```sh
$ sudo apt install gnupg2
$ gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ \curl -sSL https://get.rvm.io | bash -s stable
$ source /home/ge/.rvm/scripts/rvm
$ rvm install 2.1.2
$ rvm install 2.1.10
$ rvm --default use 2.1.10
```
## 安裝 R4.5
### 一、建立 ssh key pair
```sh
$ ssh-keygen # 設定 key pair name -> 設定密碼(不設定直接 enter) -> 確認密碼(不設定直接 enter)
$ cat ~/.ssh/your_key.pub # 將公鑰轉交給禾綸(注意:不是私鑰)
$ # 確認禾綸將公鑰加入 GitLab 後再接續下列指令與步驟二
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/your_private_key
```
### 二、安裝 R4.5 Web App
```sh
$ git clone git@gitlab.tp.rulingcom.com:saurabh/orbit4-5.git your_site_name
$ cd your_site_name
$ vim config/mongoid.yml # 所有 orbit_4_5 換成 your_site_name, :wq 存檔離開
$ vim Gemfile # 加井字號註解掉 gem 'sassc-rails', '~>1.3.0' 並拿掉此行 #gem 'sass-rails', '~> 4.0.2' 井字號取消註解
$ bundle install
$ RAILS_ENV=production bundle exec rake assets:precompile
$ bundle exec unicorn_rails -c config/unicorn.rb -D -E production
$ sudo service nginx restart
$ # Login the new create site with rulingcom account and choose “Admin Area” to complete the registration of this new created site.
```