質問編集履歴

3

エラー発生の状況について補足説明

2022/09/09 04:14

投稿

arron
arron

スコア34

test CHANGED
File without changes
test CHANGED
@@ -98,6 +98,9 @@
98
98
  #ブラウザでDjangoプロジェクトの確認
99
99
  'VPSのIP':8000/'projectのurl'
100
100
 
101
+ ※この段階で上記の"ブラウザに表示されるエラーメッセージ"が出てきます。
102
+  Udemyの講座でベースとしているwebサイトでいうとStep6の段階で先に進めなくなっています。
103
+
101
104
  ```
102
105
 
103
106
  ### 試したこと

2

改行修正

2022/09/08 12:17

投稿

arron
arron

スコア34

test CHANGED
File without changes
test CHANGED
@@ -46,8 +46,10 @@
46
46
  ### 該当のソースコード
47
47
 
48
48
  ```ubuntu
49
+ ※基本的にUdemyの講座でベースとしているwebサイトの通りに入力しています。
49
- ※基本的にUdemyの講座でベースとしている"How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04"の通りに入力しています。
50
+ "How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04"
50
51
  https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
52
+
51
53
  #pip、PostgreSQL、Nginxのインストール
52
54
  sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx curl
53
55
 

1

エラーコードと該当のソースコードを追記

2022/09/08 12:12

投稿

arron
arron

スコア34

test CHANGED
File without changes
test CHANGED
@@ -3,10 +3,6 @@
3
3
  ローカルで作ったDjangoのプロジェクトをVPSサーバーに保存したあと、gunicornとnginxを使ってVPSサーバーからDjangoのプロジェクトが起動しようとしていますが、立ち上がりません。
4
4
  エラーメッセージに転記したターミナルのコメントのを見ると、どうもgunicornがワークしていないようです。
5
5
  user名やパスワードはgunicornとDjangoのsettings.pyで同じものを指定しています。
6
-
7
- ひとつ気になっているのは、エラーメッセージの中の、
8
- Process: 202174 ExecStart=/home/ryota/todoproject/todoenv/bin/gunicorn…
9
- というpathに、Udemyの講師の方のお名前が入っていることです。もしかしたらuser名が講師の方の設定になっているのかなと思いました。
10
6
 
11
7
  ### 実現したいこと
12
8
 
@@ -16,7 +12,18 @@
16
12
  ### 発生している問題・エラーメッセージ
17
13
 
18
14
  ```
15
+ #ブラウザに表示されるエラーメッセージです。
16
+
17
+ ERROR
18
+ The requested URL could not be retrieved
19
+ The following error was encountered while trying to retrieve the URL: http://"VPSサーバーのアドレス"/"プロジェクトのpath"/
20
+ Connection to "VPSサーバーのアドレス" failed.
21
+ The system returned: (110) Connection timed out
22
+ The remote host or network may be down. Please try the request again.
23
+ Your cache administrator is root.
24
+
25
+
19
- gunicornのステータスメッセージです。
26
+ #gunicornのステータスメッセージです。
20
27
 
21
28
  (todoenv) root@ik1-413-38954:~/todoproject# sudo systemctl status gunicorn
22
29
  × gunicorn.service - gunicorn daemon
@@ -39,7 +46,56 @@
39
46
  ### 該当のソースコード
40
47
 
41
48
  ```ubuntu
49
+ ※基本的にUdemyの講座でベースとしている"How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04"の通りに入力しています。
50
+ https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
51
+ #pip、PostgreSQL、Nginxのインストール
52
+ sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx curl
53
+
42
- ース
54
+ #デタベーブルの作成
55
+ sudo -u postgres psql
56
+ CREATE DATABASE myproject;
57
+ CREATE USER myprojectuser WITH PASSWORD 'password';
58
+ ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
59
+ ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
60
+ ALTER ROLE myprojectuser SET timezone TO 'UTC';
61
+ GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
62
+ \q
63
+
64
+ #リポジトリのclone
65
+ #仮想環境の構築
66
+
67
+ #Djangoとgnicornのインストール
68
+ pip install django gunicorn psycopg2-binary
69
+
70
+ #settings.pyの設定
71
+ vim ~/todoproject/todoproject/settings.py
72
+ ALLOWED_HOSTS = ['VPSのIP', ‘localhost’’]
73
+ DATABASES = {
74
+ 'default': {
75
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
76
+ 'NAME': 'myproject',
77
+ 'USER': 'myprojectuser',
78
+ 'PASSWORD': 'password',
79
+ 'HOST': 'localhost',
80
+ 'PORT': '',
81
+ }
82
+ }
83
+ STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
84
+ :wq
85
+
86
+ #migration等のコマンドの実行
87
+ manage.py makemigrations
88
+ manege.py migrate
89
+ manage.py collectstatic
90
+ manage.py createsuperuser
91
+
92
+ #gunicornの起動確認
93
+ sudo ufw allow 8000
94
+ gunicorn --bind 0.0.0.0:8000 todoproject.wsgi
95
+
96
+ #ブラウザでDjangoプロジェクトの確認
97
+ 'VPSのIP':8000/'projectのurl'
98
+
43
99
  ```
44
100
 
45
101
  ### 試したこと