登錄阿里雲後首先
sudo apt-get update
apt-get install git curl clang make nodejs openssl libssl-dev libreadline6-dev zlib1g-dev libyaml-dev libxml2-dev libxslt1-dev libpq-dev libmysqlclient-dev libsqlite3-dev libcurl4-openssl-dev unzip
———————————————
安裝rvm
$ curl -L https://get.rvm.io | bash -s stable
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
$ source ~/.bashrc
$ rvm -v
reboot重啓rvm groop分組權限
-----
# rvm如果安裝失敗參考命令
curl -sSL https://get.rvm.io | bash -s stable
#或者
curl -L https://rvm.io | bash -s stable
安裝RVM依賴等
$ rvm requirements
$ rvm pkg install readline
$ rvm pkg install openssl
$ rvm install 2.3.1
$ rvm use 2.3.1 --default
rvm gemset create 3color244
----------
安裝MySQL
$ sudo apt-get install mysql-server
# 加數據庫驅動
# mysql client is missing. You may need to 'apt-get install libmysqlclient-dev'
apt-get install libmysqlclient-dev
--------
在使用Ubuntu的時候發現不管是終端輸入中文還是終端顯示中文,都會出現中文顯示爲問號的問題。 .解決辦法如下:
sudo locale-gen zh_CN.UTF-8 即可完成中文字符集的添加,之後中文就顯示正常了。
出現上面問題的原因是rails生產環境沒有配置secret_key_base變量,解決方法:
$ cd project
$ bundle exec rake secret # rails 4.2.6還需要bundle exec,請根據rails版本自行匹配
跑起來項目:
git clone your project 項目拉下來。
這樣代碼就下載到服務器上了,然後安裝gem
$ cd project
$ bundle install
創建生產環境數據庫並執行遷移
$ RAILS_ENV=production rake db:create
$ RAILS_ENV=production rake db:migrate
否則最終網站頁面會顯示(之前heroku部署時也經常遇到)
We're sorry, but something went wrong
重新compile assets,這樣所有的圖片,CSS,scripts纔會加載
$ RAILS_ENV=production rake assets:precompile
版權聲明:本文由 數控等離子切割機 http://www.hycsk.com整理編輯!本文章來源於網絡,如有侵權,請聯繫雲棲社區,歡迎分享本文,轉載請保留出處!
---------
Step6: 安裝Passenger for Nginx (注意內存必須大於1g)
Nginx是HTTP服務器,運行nginx類似於本地開啓rails server,才能實現網站的訪問,首先安裝passenger:
$ gem install passenger
然後通過source編譯的方式安裝Nginx
$ rvmsudo passenger-install-nginx-module
Step6: 安裝Passenger for Nginx
rvmsudo passenger-install-nginx-module
一路回車即可,在這裏選擇1回車:
Automatically download and install Nginx?Nginx doesn't support loadable modules such as some other web servers do, so in order to install Nginx with Passenger support, it must be recompiled.Do you want this installer to download, compile and install Nginx for you?
1. Yes: download, compile and install Nginx for me. (recommended) The easiest way to get started. A stock Nginx 1.4.4 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice.
2. No: I want to customize my Nginx installation. (for advanced users) Choose this if you want to compile Nginx with more third party modules besides Passenger, or if you need to pass additional options to Nginx's 'configure' script. This installer will 1) ask you for the location of the Nginx source code, 2) run the 'configure' script according to your instructions, and 3) run 'make install'.
Whichever you choose, if you already have an existing Nginx configuration file, then it will be preserved.Enter your choice (1 or 2) or press Ctrl-C to abort:1[ENTER]
最後看到這句話即安裝成功
Nginx with Passenger support was successfully installed.
http {
...
passenger_root /usr/local/rvm/gems/ruby-2.3.1@3color244/gems/passenger-5.0.30;
passenger_ruby /usr/local/rvm/gems/ruby-2.3.1@3color244/wrappers/ruby;
...
}
啓動linux
ps auxw | grep nginx
sudo /opt/nginx/sbin/nginx
/opt/nginx/sbin/nginx -s reload
阿里雲裸機部署rails運用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
python腳本簡化jar操作命令
神牛003
2019-02-23 17:41:06
Nginx 安裝與配置規則入門
Lmagic16
2019-02-24 22:13:58
nginx+php執行請求的工作原理
xavier
2019-02-24 15:52:41
配置Nginx支持php,出現No input file specified錯誤的解決方法
lvqingpu
2019-02-24 13:15:35
深入 Nginx 之架構篇
jeffrey_up
2019-02-23 19:23:46
tcpdump查看Nginx長連接還是短連接
ouyangbro
2019-02-23 15:52:48
Nginx使用安裝(一)
flashhand
2019-02-23 13:58:28
nginx中gzip模塊
小紅帽子
2019-02-23 13:37:48
nginx+keepalived配置高可用HTTP羣集
小紅帽子
2019-02-23 13:37:48
Nginx服務之防盜鏈功能
兩袖春風
2019-02-23 13:28:22
寶塔面板 + Rancher + 阿里雲鏡像倉庫 + Docker + Kubernetes,添加集羣、部署 web 應用
燕小范
2019-02-23 13:20:14
nginx添加系統服務
braoshan
2019-02-23 13:15:21
Nginx簡易實用的php域名配置
wx5c6f5798d627c
2019-02-23 13:07:16
開始我的rails生活--1.安裝rails
psychebb
2019-02-23 14:02:24