質問するログイン新規登録

質問編集履歴

1

エラーログの追記

2021/09/30 04:27

投稿

pyamathon
pyamathon

スコア14

title CHANGED
File without changes
body CHANGED
@@ -6,43 +6,9 @@
6
6
  ### 発生している問題・エラーメッセージ
7
7
 
8
8
  その前にcgiの準備ができているか確認しようと公開されているソースを実行しましたが、
9
- 遷移後のページでソースが表示されてしまう。
9
+ ~~遷移後のページでソースが表示されてしまう。~~
10
+ (追記)ソースが表示されることはなくなったが500 Internal Server Errorが出る。
10
11
 
11
- ```
12
- #!/usr/bin/env python
13
- # -*- coding: utf-8 -*-
14
- import cgi
15
- form = cgi.FieldStorage() # cgi繧ェ繝悶ず繧ァ繧ッ繝井ス懈�
16
- v1 = form.getfirst('value1') # name縺計alue1縺ョ蛟、繧貞叙蠕�
17
- v2 = form.getfirst('value2') # name縺計alue2縺ョ蛟、繧貞叙蠕�
18
- #蜈・蜉帛€、縺梧焚蟄励↑繧峨◎縺ョ遨阪r霑斐☆髢「謨ー
19
- def times(a, b):
20
- try:
21
- a=int(a)
22
- b=int(b)
23
- return str(a*b)
24
- except ValueError:
25
- return('謨ー蛟、縺倥c縺ェ縺��縺ァ險育ョ励〒縺阪∪縺帙s(>_<)')
26
-
27
- # 繝悶Λ繧ヲ繧カ縺ォ謌サ縺僣TML縺ョ繝��繧ソ
28
- print("Content-Type: text/html")
29
- print()
30
- htmlText = '''
31
- <!DOCTYPE html>
32
- <html>
33
- <head><meta charset="shift-jis" /></head>
34
- <body bgcolor="lightyellow">
35
- <h1>縺薙s縺ォ縺。縺ッ</h1>
36
- <p>蜈・蜉帛€、縺ョ遨阪�&nbsp; %s<br/></p>
37
- <hr/>
38
- <a href="../form1.html">謌サ繧�</a>縲€
39
- </body>
40
- </html>
41
- '''%(times(v1,v2)) # 蜈・蜉帛€、縺ョ遨阪r%s縺ョ邂�園縺ォ蝓九a繧�
42
- print( htmlText.encode("cp932", 'ignore').decode('cp932') )
43
- ```
44
-
45
-
46
12
  以下url
47
13
  https://qiita.com/TSKY/items/b041de0572e6586c889c
48
14
 
@@ -106,6 +72,26 @@
106
72
 
107
73
  正しく配置はしているのですが、サーバーにアップロードしている記事が少なくどうしていいかわからない状態です。
108
74
 
109
- ### 補足情報(FW/ツールのバージョンなど)
75
+ ### 追記
76
+ 拡張子を.py→.cgiに変更しました。
77
+ ご指摘いただいた
78
+ (#!/usr/bin/env python)
79
+
80
+ (#!/usr/local/bin/python)
81
+ に変更しました。
82
+ 現在
83
+ .www
84
+ -form1.html
85
+ -formtest1.cgi
86
+ -.htaccess
87
+ が同じディレクトリに保存してあり、パーミッションも755に変更してありますが、
88
+ 500 Internal Server Error が出ています。
89
+ エラーログは以下の通りです。
90
+ ```
91
+ [Thu Sep 30 12:55:14.374649 2021] [cgi:error] [pid 99658] [client 118.***.185.***:0] AH01215: Traceback (most recent call last):: /home/***/www/formtest1.cgi, referer: https://***.ne.jp/form1.html
92
+ [Thu Sep 30 12:55:14.374745 2021] [cgi:error] [pid 99658] [client 118.***.185.***:0] AH01215: File "formtest1.cgi", line 31, in <module>: /home/***/www/formtest1.cgi, referer: https://***.ne.jp/form1.html
93
+ [Thu Sep 30 12:55:14.374799 2021] [cgi:error] [pid 99658] [client 118.***.185.***:0] AH01215: print( htmlText.encode("cp932", 'ignore').decode('cp932') ): /home/***/www/formtest1.cgi, referer: https://***.ne.jp/form1.html
94
+ [Thu Sep 30 12:55:14.374899 2021] [cgi:error] [pid 99658] [client 118.***.185.***:0] AH01215: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 107: ordinal not in range(128): /home/***/www/formtest1.cgi, referer: https:/***.ne.jp/form1.html
95
+ [Thu Sep 30 12:55:14.374924 2021] [cgi:error] [pid 99658] [client 118.***.185.***:0] malformed header from script 'formtest1.cgi': Bad header: (), referer: https://***.ne.jp/form1.html
110
96
 
111
- ここにより詳細な情報を記載してください。
97
+ ```