centos部署ruby on rails-V2.3.3

1、安裝各種依賴的gem

? ??yum install make gcc openssl-devel zlib-devel gcc gcc-c++make autoconf readline-devel curl-devel expat-devel gettext-devel ncurese-develmysql-develhttpd-devel wget which

2、curl -O -Lhttps://cache.ruby-lang.org/pub/ruby/ruby-2.3.3.tar.gz? 下載

3格嘁、tar xf ruby-2.3.3.tar.gz? 解壓

4馍悟、cd ruby-2.3.3/

5识椰、./configure --prefix=/usr/local/ruby

6猴抹、make

7整陌、make install

8划纽、ruby -v

9脆侮、gem install rails-v = 5.1.6

10、rake secret RAILS_ENV=production? ? //生成production密碼

11勇劣、將上面生成的密碼放進(jìn)/etc/profile.d/st_rails_secret_key_env.sh中靖避,內(nèi)容如下

export SECRET_KEY_BASE='密碼'



12、puma.rb的設(shè)置:

# Puma can serve each request in a thread from an internal thread pool.

# The `threads` method setting takes two numbers: a minimum and maximum.

# Any libraries that use thread pools should be configured to match

# the maximum value specified for Puma. Default is set to 5 threads for minimum

# and maximum; this matches the default thread size of Active Record.

#

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }

threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.

#

port? ? ? ? ENV.fetch("PORT") { 3001 }

# Specifies the `environment` that Puma will run in.

#

environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the number of `workers` to boot in clustered mode.

# Workers are forked webserver processes. If using threads and workers together

# the concurrency of the application would be max `threads` * `workers`.

# Workers do not work on JRuby or Windows (both of which do not support

# processes).

#

# workers ENV.fetch("WEB_CONCURRENCY") { 2 }

# Use the `preload_app!` method when specifying a `workers` number.

# This directive tells Puma to first boot the application and load code

# before forking the application. This takes advantage of Copy On Write

# process behavior so workers use less memory. If you use this option

# you need to make sure to reconnect any threads in the `on_worker_boot`

# block.

#

# preload_app!

# If you are preloading your application and using Active Record, it's

# recommended that you close any connections to the database before workers

# are forked to prevent connection leakage.

#

# before_fork do

#? ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)

# end

# The code in the `on_worker_boot` will be called if you are using

# clustered mode by specifying a number of `workers`. After each worker

# process is booted, this block will be run. If you are using the `preload_app!`

# option, you will want to use this block to reconnect to any threads

# or connections that may have been created at application boot, as Ruby

# cannot share connections between processes.

#

# on_worker_boot do

#? ActiveRecord::Base.establish_connection if defined?(ActiveRecord)

# end

#

# Allow puma to be restarted by `rails restart` command.

plugin :tmp_restart

13比默、 nginx安裝

yum install nginx

配置文件在/etc/nginx/conf.d/

配置內(nèi)容如下:

upstream orange{

???????#server 127.0.0.1:3000;//development用筋蓖,就是測(cè)試用的

???????#keepalive 64;//development用,就是測(cè)試用的

???????server unix:/home/www/orange/tmp/sockets/puma.sock fail_timeout=0;//production用

}

server {

???????listen 8001;

???????server_name 網(wǎng)址退敦,不要http:https:;

???????location / {

??????????????? proxy_set_header Host$http_host;

??????????????? proxy_set_headerX-Forwarded_For $proxy_add_x_forwarded_for;

??????????????? proxy_redirect off;

??????????????? proxy_pass http://項(xiàng)目名;

??????????????? proxy_set_header Connection '';

?? ?????????????proxy_http_version 1.1;

??????????????? chunked_transfer_encoding off;

??????????????? proxy_buffering off;

??????????????? proxy_cache off;

???????}

???????location ~ \.(htm|html|shtml|gif|jpg|jpeg|png|ico|css|js|f|v|swf)$ {

?????????????? ?root 項(xiàng)目全路徑/public;

??????????????? access_log off;

??????????????? expires max;

???????}

???????location ~ ^/(frame/) {

??????????????? root 項(xiàng)目全路徑/public;

??????????????? access_log off;

??????????????? expires max;

???????}

???? ???error_page 500 502 503 504 /500.html;

???????client_max_body_size 4G;

???????keepalive_timeout 10;

}

nginx啟動(dòng):systemctl start nginx.service

nginx重啟:systemctl restart nginx.service

nginx狀態(tài):systemctl status nginx.service

如果一切進(jìn)展順利的話粘咖,現(xiàn)在你可以通過(guò)你的域名或IP來(lái)訪問(wèn)你的Web頁(yè)面來(lái)預(yù)覽一下Nginx的默認(rèn)頁(yè)面;

如果看到這個(gè)頁(yè)面,那么說(shuō)明你的CentOS 7 中 web服務(wù)器已經(jīng)正確安裝侈百。


開(kāi)機(jī)啟動(dòng)nginx: sudo systemctl enable nginx.service

網(wǎng)站文件存放默認(rèn)目錄

/usr/share/nginx/html

網(wǎng)站默認(rèn)站點(diǎn)配置

/etc/nginx/conf.d/default.conf

自定義Nginx站點(diǎn)配置文件存放目錄

/etc/nginx/conf.d/

Nginx全局配置

/etc/nginx/nginx.conf

Nginx啟動(dòng)

nginx -c nginx.conf


在這里你可以改變?cè)O(shè)置用戶運(yùn)行Nginx守護(hù)程序進(jìn)程一樣,和工作進(jìn)程的數(shù)量得到了Nginx正在運(yùn)行,等等瓮下。

14、 配置開(kāi)機(jī)啟動(dòng)puma:?

?路徑:/usr/lib/systemd/system/ 建立文件 ****.service 內(nèi)容如下:

? ? ? ? ? [Unit]

?Descriptionb = Puma HTTP Server

?After=network.target?

?? [Service]

?Type=simple?

?$Type=forking

?? User=root?

?? WorkingDirectory=項(xiàng)目路徑??

?? ExecStart=/bin/bash -lc 'bundle exec puma -e production -C 項(xiàng)目路徑/config/puma.rb' ?

?Restart=always

?RestartSec=30

?? [Install]

?WantedBy=multi-user.target?

? ? ? ?保存后:systemctl enable orange.service開(kāi)啟服務(wù)

?? ? ? 確保mariadb(數(shù)據(jù)庫(kù)),nginx,自定義腳本(puma)可以開(kāi)機(jī)啟動(dòng)钝域,即可讽坏! 查看開(kāi)機(jī)啟動(dòng)項(xiàng):systemctl list-unit-files ? ?

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市例证,隨后出現(xiàn)的幾起案子路呜,更是在濱河造成了極大的恐慌,老刑警劉巖织咧,帶你破解...
    沈念sama閱讀 211,123評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件胀葱,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡笙蒙,警方通過(guò)查閱死者的電腦和手機(jī)抵屿,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)捅位,“玉大人轧葛,你說(shuō)我怎么就攤上這事搂抒。” “怎么了尿扯?”我有些...
    開(kāi)封第一講書人閱讀 156,723評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵求晶,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我衷笋,道長(zhǎng)芳杏,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 56,357評(píng)論 1 283
  • 正文 為了忘掉前任右莱,我火速辦了婚禮,結(jié)果婚禮上档插,老公的妹妹穿的比我還像新娘慢蜓。我一直安慰自己,他們只是感情好郭膛,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,412評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布晨抡。 她就那樣靜靜地躺著,像睡著了一般则剃。 火紅的嫁衣襯著肌膚如雪耘柱。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 49,760評(píng)論 1 289
  • 那天棍现,我揣著相機(jī)與錄音调煎,去河邊找鬼。 笑死己肮,一個(gè)胖子當(dāng)著我的面吹牛士袄,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播谎僻,決...
    沈念sama閱讀 38,904評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼娄柳,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了艘绍?” 一聲冷哼從身側(cè)響起赤拒,我...
    開(kāi)封第一講書人閱讀 37,672評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎诱鞠,沒(méi)想到半個(gè)月后挎挖,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,118評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡航夺,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,456評(píng)論 2 325
  • 正文 我和宋清朗相戀三年肋乍,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片敷存。...
    茶點(diǎn)故事閱讀 38,599評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡墓造,死狀恐怖堪伍,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情觅闽,我是刑警寧澤帝雇,帶...
    沈念sama閱讀 34,264評(píng)論 4 328
  • 正文 年R本政府宣布,位于F島的核電站蛉拙,受9級(jí)特大地震影響尸闸,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜孕锄,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,857評(píng)論 3 312
  • 文/蒙蒙 一吮廉、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧畸肆,春花似錦宦芦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,731評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至大咱,卻和暖如春恬涧,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背碴巾。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 31,956評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工溯捆, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人厦瓢。 一個(gè)月前我還...
    沈念sama閱讀 46,286評(píng)論 2 360
  • 正文 我出身青樓现使,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親旷痕。 傳聞我的和親對(duì)象是個(gè)殘疾皇子碳锈,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,465評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容

  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie閱讀 2,800評(píng)論 0 3
  • This project was bootstrapped with Create React App. Belo...
    unspecx閱讀 5,139評(píng)論 0 2
  • 描述 Puma是一個(gè)簡(jiǎn)單,快速欺抗,線程式售碳,并且支持HTTP1.1高并發(fā)的Ruby/Rack服務(wù)器。在開(kāi)發(fā)環(huán)境和生產(chǎn)環(huán)...
    李小西033閱讀 9,583評(píng)論 6 4
  • 八大排序法【內(nèi)部排序】:插入排序绞呈、希爾排序贸人、選擇排序、冒泡排序佃声、歸并排序艺智、快速排序、堆排序圾亏、基數(shù)排序 【插入排序】...
    miyakee閱讀 316評(píng)論 0 0
  • 我受欺負(fù)你總是替我出頭。 我膽小你帶我橫行霸道夭问。 我自卑你教我旁若無(wú)人的大笑泽西。 你帶我逃課到集市上鄉(xiāng)村里湊各種熱鬧...
    七加閱讀 443評(píng)論 1 3