質問編集履歴

3

余分な内容の削除

2020/02/03 14:31

投稿

mi-tomo
mi-tomo

スコア6

test CHANGED
File without changes
test CHANGED
@@ -174,9 +174,9 @@
174
174
 
175
175
  listen 80 ;
176
176
 
177
- server_name car-ko-bo.com;
177
+ server_name ドメイン.com;
178
-
178
+
179
- root /home/ubuntu/car-ko-bo.com;
179
+ root /home/ubuntu/ドメイン.com;
180
180
 
181
181
  }
182
182
 
@@ -208,102 +208,58 @@
208
208
 
209
209
 
210
210
 
211
- ご連絡いただきありがとうございます
212
-
213
- >pumaとかUnicornとか使っていすか、そのsetteifileを
214
-
215
-
216
-
217
- config>unicorn.rb の中身です 全く的外れな場所だったら申し訳ありません
218
-
219
- ```
220
-
221
- app_path = File.expand_path('../../../', __FILE__)
222
-
223
-
224
-
225
- worker_processes 5
226
-
227
-
228
-
229
- working_directory "#{app_path}/current"
230
-
231
-
232
-
233
- listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
234
-
235
- pid "#{app_path}/shared/tmp/pids/unicorn.pid"
236
-
237
- stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
238
-
239
- stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
240
-
241
-
242
-
243
- timeout 60
244
-
245
-
246
-
247
- preload_app true
248
-
249
- GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
250
-
251
-
252
-
253
- check_client_connection false
254
-
255
-
256
-
257
- run_once = true
258
-
259
-
260
-
261
- before_fork do |server, worker|
262
-
263
- defined?(ActiveRecord::Base) &&
264
-
265
- ActiveRecord::Base.connection.disconnect!
266
-
267
-
268
-
269
- if run_once
270
-
271
- run_once = false # prevent from firing again
272
-
273
- end
274
-
275
-
276
-
277
- old_pid = "#{server.config[:pid]}.oldbin"
278
-
279
- if File.exist?(old_pid) && server.pid != old_pid
280
-
281
- begin
282
-
283
- sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
284
-
285
- Process.kill(sig, File.read(old_pid).to_i)
286
-
287
- rescue Errno::ENOENT, Errno::ESRCH => e
288
-
289
- logger.error e
290
-
291
- end
292
-
293
- end
294
-
295
- end
296
-
297
-
298
-
299
- after_fork do |_server, _worker|
300
-
301
- defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
302
-
303
- end
304
-
305
- ```
306
-
307
- です正しいファイルでない時はその参照方法も教えて頂けないでしょうか
308
-
309
- お手数をおかけしてすみませんがよろしくお願いします
211
+ 追記
212
+
213
+ ご提案いただいた/etc/nginx/conf.d/ドメイン名.conf で作り直しした
214
+
215
+ /etc/nginx/conf.d/ドメイン名.confの内容
216
+
217
+ ```
218
+
219
+ server {
220
+
221
+ listen 80;
222
+
223
+ server_name ドメイン.com;
224
+
225
+ root /var/www/アプリ名/current/public;
226
+
227
+ location ^~ /assets/ {
228
+
229
+ gzip_static on;
230
+
231
+ expires max;
232
+
233
+ add_header Cache-Control public;
234
+
235
+ root /var/www/アプリ名/current/public;
236
+
237
+ }
238
+
239
+ try_files $uri/index.html $uri @unicorn;
240
+
241
+ location @unicorn {
242
+
243
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
244
+
245
+ proxy_set_header Host $http_host;
246
+
247
+ proxy_redirect off;
248
+
249
+ proxy_pass http://app_server;
250
+
251
+ }
252
+
253
+ error_page 500 502 503 504 /500.html;
254
+
255
+ }
256
+
257
+ ```
258
+
259
+ この内容で確認したところ確認できました!
260
+
261
+ 本当に親切にアドバイスして頂きありがとうございました
262
+
263
+
264
+
265
+ 本当に助かりました

2

ファイル内容の追加

2020/02/03 14:31

投稿

mi-tomo
mi-tomo

スコア6

test CHANGED
File without changes
test CHANGED
@@ -205,3 +205,105 @@
205
205
 
206
206
 
207
207
  よろしくお願いします
208
+
209
+
210
+
211
+ ご連絡いただきありがとうございます
212
+
213
+ >pumaとかUnicornとか使っていますか、そのsetteifileを
214
+
215
+
216
+
217
+ config>unicorn.rb の中身です 全く的外れな場所だったら申し訳ありません
218
+
219
+ ```
220
+
221
+ app_path = File.expand_path('../../../', __FILE__)
222
+
223
+
224
+
225
+ worker_processes 5
226
+
227
+
228
+
229
+ working_directory "#{app_path}/current"
230
+
231
+
232
+
233
+ listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
234
+
235
+ pid "#{app_path}/shared/tmp/pids/unicorn.pid"
236
+
237
+ stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
238
+
239
+ stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
240
+
241
+
242
+
243
+ timeout 60
244
+
245
+
246
+
247
+ preload_app true
248
+
249
+ GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
250
+
251
+
252
+
253
+ check_client_connection false
254
+
255
+
256
+
257
+ run_once = true
258
+
259
+
260
+
261
+ before_fork do |server, worker|
262
+
263
+ defined?(ActiveRecord::Base) &&
264
+
265
+ ActiveRecord::Base.connection.disconnect!
266
+
267
+
268
+
269
+ if run_once
270
+
271
+ run_once = false # prevent from firing again
272
+
273
+ end
274
+
275
+
276
+
277
+ old_pid = "#{server.config[:pid]}.oldbin"
278
+
279
+ if File.exist?(old_pid) && server.pid != old_pid
280
+
281
+ begin
282
+
283
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
284
+
285
+ Process.kill(sig, File.read(old_pid).to_i)
286
+
287
+ rescue Errno::ENOENT, Errno::ESRCH => e
288
+
289
+ logger.error e
290
+
291
+ end
292
+
293
+ end
294
+
295
+ end
296
+
297
+
298
+
299
+ after_fork do |_server, _worker|
300
+
301
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
302
+
303
+ end
304
+
305
+ ```
306
+
307
+ です正しいファイルでない時はその参照方法も教えて頂けないでしょうか
308
+
309
+ お手数をおかけしてすみませんがよろしくお願いします

1

コードを写真で貼ってあったのを修正しました

2020/01/30 13:05

投稿

mi-tomo
mi-tomo

スコア6

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ①以下のサイトを参考にAWSの Route 53 でDNS設定を行いました(Nginx バーチャルホストの設定はよくわからなかったので行わなかった)
22
22
 
23
- https://qiita.com/HitomiHoshisaki/items/7d7345eb67390f16fed4
23
+ [https://qiita.com/HitomiHoshisaki/items/7d7345eb67390f16fed4](https://qiita.com/HitomiHoshisaki/items/7d7345eb67390f16fed4)
24
24
 
25
25
 
26
26
 
@@ -30,18 +30,20 @@
30
30
 
31
31
  以下の記事と全く同じ現象になってしまったのでNginx バーチャルホストの設定が必要と認識
32
32
 
33
- https://teratail.com/questions/52240
33
+ [https://teratail.com/questions/52240](https://teratail.com/questions/52240)
34
34
 
35
35
 
36
36
 
37
37
  ③Nginxにバーチャルホストの設定がよくわからなかったため以下の記事を参考に
38
38
 
39
- http://t-tsuyoshi.hatenablog.com/entry/2017/08/05/185708
39
+ [http://t-tsuyoshi.hatenablog.com/entry/2017/08/05/185708](http://t-tsuyoshi.hatenablog.com/entry/2017/08/05/185708)
40
40
 
41
41
  設定
42
42
 
43
43
  ```
44
44
 
45
+ $ sudo /etc/init.d/nginx configtest
46
+
45
47
  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
46
48
 
47
49
  nginx: configuration file /etc/nginx/nginx.conf test is successful
@@ -58,13 +60,127 @@
58
60
 
59
61
  $ sudo vim /etc/nginx/nginx.conf
60
62
 
63
+ では
64
+
65
+ ```
66
+
67
+ user nginx;
68
+
69
+ worker_processes auto;
70
+
71
+ error_log /var/log/nginx/error.log;
72
+
73
+ pid /var/run/nginx.pid;
74
+
75
+
76
+
77
+ include /usr/share/nginx/modules/*.conf;
78
+
79
+
80
+
81
+ events {
82
+
83
+ worker_connections 1024;
84
+
85
+ }
86
+
87
+
88
+
89
+ http {
90
+
91
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
92
+
93
+ '$status $body_bytes_sent "$http_referer" '
94
+
95
+ '"$http_user_agent" "$http_x_forwarded_for"';
96
+
97
+
98
+
99
+ access_log /var/log/nginx/access.log main;
100
+
101
+
102
+
103
+ sendfile on;
104
+
105
+ tcp_nopush on;
106
+
107
+ tcp_nodelay on;
108
+
109
+ keepalive_timeout 65;
110
+
111
+ types_hash_max_size 2048;
112
+
113
+
114
+
115
+ include /etc/nginx/mime.types;
116
+
117
+ default_type application/octet-stream;
118
+
119
+
120
+
121
+
122
+
123
+ include /etc/nginx/sites-enabled/*;
124
+
61
- では![イメージ説明](fc842d871b46939e4cfcad4631ad5e52.png)
125
+ include /etc/nginx/conf.d/*.conf;
126
+
127
+
128
+
129
+ index index.html index.htm;
130
+
131
+
132
+
133
+ server {
134
+
135
+ listen 80 default_server;
136
+
137
+ listen [::]:80 default_server;
138
+
139
+ server_name localhost;
140
+
141
+ root /usr/share/nginx/html;
142
+
143
+
144
+
145
+ include /etc/nginx/default.d/*.conf;
146
+
147
+
148
+
149
+ location / {
150
+
151
+ }
152
+
153
+
154
+
155
+ error_page 404 /404.html;
156
+
157
+ location = /40x.html {
158
+
159
+ }
160
+
161
+ }
162
+
163
+ }
164
+
165
+ ```
62
166
 
63
167
  上のような内容になっており
64
168
 
65
169
  $ sudo vim /etc/nginx/sites-available/car-ko-bo.comでは
66
170
 
171
+ ```
172
+
173
+ server {
174
+
175
+ listen 80 ;
176
+
177
+ server_name car-ko-bo.com;
178
+
67
- ![イメージ説明](42368a819673b84e5cc9eda649e3d6e2.png)
179
+ root /home/ubuntu/car-ko-bo.com;
180
+
181
+ }
182
+
183
+ ```
68
184
 
69
185
  のように記述してあります
70
186