質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

lighttpd

lighttpdは軽量で高性能なwebサーバーです。高速性が求められる環境に適応しています。

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

2689閲覧

lighttpd 立ち上げが出来ていたものができなくなった

rumippu

総合スコア26

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

lighttpd

lighttpdは軽量で高性能なwebサーバーです。高速性が求められる環境に適応しています。

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/06/26 13:39

編集2020/06/27 04:22

lighttpdより、fcgiを使用したpythonにアクセスしようと思っています。
参考URL1:
http://make.bcde.jp/raspberry-pi/%E3%83%96%E3%83%A9%E3%82%A6%E3%82%B6%E3%81%8B%E3%82%89gpio%E3%82%92%E6%93%8D%E4%BD%9C/

この参考URL1の動作まではうまく行っておりました。次に、fcgiを使用した(具体的にはgoogle chartとMySQLの連携)
アプリケーションの起動につまずき、色々と英語圏のソースの罠までハマっています。
最後に、下記URL

参考URL2:
https://github.com/SSilence/selfoss/wiki/Installing-on-Raspberry-Pi-with-lighttpd

こちらの「sudo /usr/sbin/lighttpd-enable-mod fastcgi fastcgi-php」
を試したところ、ついにはlighttpdの起動自体ができなくなりました。

Duplicate config variable in conditional 0 global: server.modules
2020-06-26 22:34:40: (configfile.c.957) source: /etc/lighttpd/lighttpd.conf line: 39 pos: 21 parser failed somehow near here: (EOL)

Duplicate config variableと書かれている通り、fcgiサーバー絡みの設定が重複しているように思えるのですが、
この戻し方をどなたかご存知でしょうか。

以上、よろしくお願いいたします。

追記:

ありがとうございます。
私の環境でターミナル出力結果を記載いたします。

pi@raspberrypi:/var/www $ ps aux | grep lighttpd pi 23715 0.0 0.2 3776 1916 pts/1 S+ 13:14 0:00 grep --color=auto lighttpd

多分正常に起動していないようです。

pi@raspberrypi:/var/www $ lighttpd -t -f /etc/lighttpd/lighttpd.conf Duplicate config variable in conditional 0 global: fastcgi.server 2020-06-27 13:15:26: (configfile.c.957) source: /etc/lighttpd/lighttpd.conf line: 48 pos: 1 parser failed somehow near here: (EOL)
server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_fastcgi", # "mod_rewrite", ) server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ) compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) # default listening port for IPv6 falls back to the IPv4 port include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" fastcgi.server = ( "doStuff.py" => ( "doStuff" => ( "socket" => "/tmp/fastcgi.python.socket", "bin-path" => "/var/www/doStuff.py", "check-local" => "disable", "max-procs" => 1) ), "test.py" => ( "test" => ( "socket" => "/tmp/test.python.socket", "bin-path" => "/var/www/test.py", "check-local" => "disable", "max-procs" => 1) ) )

上記には問題なく、おそらくfastcgiがうまく接続できていない(?)ためのエラーのため、
最終行をエラーとして返していたのだと思います。
昨日まではtest.pyもdoStuff.py(index2.htmlよりdoStuff.py経由でGPIOを操作)も
サーバーから操作可能でした。

pi@raspberrypi:/var/www $ sudo lsof -iTCP -nP COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 576 root 3u IPv4 9430 0t0 TCP *:22 (LISTEN) sshd 576 root 4u IPv6 9432 0t0 TCP *:22 (LISTEN) mysqld 1043 mysql 10u IPv4 9561 0t0 TCP 127.0.0.1:3306 (LISTEN) smbd 1339 root 35u IPv6 10680 0t0 TCP *:445 (LISTEN) smbd 1339 root 36u IPv6 10681 0t0 TCP *:139 (LISTEN) smbd 1339 root 37u IPv4 10682 0t0 TCP *:445 (LISTEN) smbd 1339 root 38u IPv4 10683 0t0 TCP *:139 (LISTEN) Xtightvnc 1597 pi 0u IPv4 9982 0t0 TCP *:6001 (LISTEN) Xtightvnc 1597 pi 3u IPv4 9984 0t0 TCP *:5901 (LISTEN) Xtightvnc 1597 pi 4u IPv4 9985 0t0 TCP 192.168.0.20:5901->192.168.0.10:49192 (ESTABLISHED) sshd 23327 root 3u IPv4 77161 0t0 TCP 192.168.0.20:22->192.168.0.10:52192 (ESTABLISHED) sshd 23337 pi 3u IPv4 77161 0t0 TCP 192.168.0.20:22->192.168.0.10:52192 (ESTABLISHED)

lighttpdは立ち上がっておりません。。

pi@raspberrypi:/var/www $ ls -l /etc/lighttpd/conf-enabled 合計 0 lrwxrwxrwx 1 root root 33 6月 26 21:56 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf lrwxrwxrwx 1 root root 37 6月 26 21:56 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf lrwxrwxrwx 1 root root 42 1月 1 1970 90-javascript-alias.conf -> ../conf-available/90-javascript-alias.conf
pi@raspberrypi:/var/www $ tree . ├── CreateJsonFromMySql.php ├── chart_temp.py.save ├── chart_temp2.py ├── chart_temp_tmp.py ├── doStuff.py ├── doStufftest.py ├── hello.html ├── html │   ├── index.lighttpd.html │   └── index.nginx-debian.html ├── index2.html ├── phptest.html ├── template.html ├── test.java ├── test.py └── test2.html

ちなみにとりあえずchmod 755で全てのファイルに権限は付与しています。

上記で原因が分かりますでしょうか・・・?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yymmt

2020/06/27 00:37

現在のlighttpd.confを貼り付けて貰えますか?エラーからすると39行目に問題があるようですので。
yymmt

2020/06/27 06:07

貼り付けて頂いたlighttpd.confの文法チェックをしてみたところ $ lighttpd -t -f /etc/lighttpd/lighttpd.conf Syntax OK となりました。何がダメなんでしょう・・・。
guest

回答1

0

ベストアンサー

かなり嵌っているようですので、トラブルシューティングを行う方法を示します。

lighttpdの起動確認

lighttpdが起動しているかどうかはpsコマンドを使います。

terminal

1$ ps aux | grep lighttpd 2www-data 2341 0.0 0.4 52248 4436 ? Ss 00:45 0:00 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf

正常に起動している場合、/usr/sbin/lighttpdの行が確認できます。

TCPポートの確認

二重起動等でポートが塞がっていて起動できないと感じた場合lsofコマンドを使います。標準では含まれないためapt-getでインストールして下さい。

terminal

1$ sudo apt-get install lsof

例えばTCPポートの一覧を表示する場合は以下の通りです。

terminal

1$ sudo lsof -iTCP -nP 2COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 3sshd 1214 root 3u IPv4 16307 0t0 TCP *:22 (LISTEN) 4... 5lighttpd 2341 www-data 4u IPv4 23783 0t0 TCP *:80 (LISTEN)

lighttpdがTCPの80番ポートで動作しているのが分かります。

lighttpdの設定確認について

該当するウェブサイトと同様の手順を踏んで、正常に動作しました。
/etc/lighttpd/lighttpd.conf

conf

1server.modules = ( 2 "mod_access", 3 "mod_alias", 4 "mod_compress", 5 "mod_redirect", 6 "mod_fastcgi", 7# "mod_rewrite", 8) 9 10server.document-root = "/var/www/html" 11server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) 12server.errorlog = "/var/log/lighttpd/error.log" 13server.pid-file = "/var/run/lighttpd.pid" 14server.username = "www-data" 15server.groupname = "www-data" 16server.port = 80 17 18 19index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) 20url.access-deny = ( "~", ".inc" ) 21static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) 22 23compress.cache-dir = "/var/cache/lighttpd/compress/" 24compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) 25 26# default listening port for IPv6 falls back to the IPv4 port 27## Use ipv6 if available 28#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port 29include_shell "/usr/share/lighttpd/create-mime.assign.pl" 30include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 31# 32fastcgi.server = ( 33 "doStuff.py" => ( 34 "doStuff" => ( 35 "socket" => "/tmp/fastcgi.python.socket", 36 "bin-path" => "/var/www/doStuff.py", 37 "check-local" => "disable", 38 "max-procs" => 1) 39 ), 40 41 "test.py" => ( 42 "test" => ( 43 "socket" => "/tmp/test.python.socket", 44 "bin-path" => "/var/www/test.py", 45 "check-local" => "disable", 46 "max-procs" => 1) 47 ) 48)

有効にしているモジュールはfastcgiのみです。

terminal

1# ls -l /etc/lighttpd/conf-enabled 2total 0 3lrwxrwxrwx 1 root root 33 Jun 27 01:05 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf

また最終的なディレクトリ構成は次の通りです。

terminal

1/var/www/ 2├── doStuff.py 3├── html 4│   ├── index2.html 5│   └── index.lighttpd.html 6└── test.py

コンテンツ周辺に関して

.pyの所有者およびパーミッションは次の通りです。

terminal

1# ls -l /var/www/*.py 2-rwxr-xr-x 1 root root 411 Jun 27 00:47 doStuff.py 3-rwxr-xr-x 1 root root 249 Jun 27 00:32 test.py

/usr/bin/pythonCGIはシンボリックリンク(ln -s /usr/bin/python2.7 /usr/bin/pythonCGIで作成)にしています。

terminal

1ls -l /usr/bin/pythonCGI 2lrwxrwxrwx 1 root root 18 Jun 27 01:07 /usr/bin/pythonCGI -> /usr/bin/python2.7

test.py

python

1#!/usr/bin/pythonCGI 2def myapp(environ, start_response): 3 start_response('200 OK', [('Content-Type', 'text/plain')]) 4 return ['Hello World!\n'] 5 6if __name__ == '__main__': 7 from flup.server.fcgi import WSGIServer 8 WSGIServer(myapp).run()

doStuff.py

python

1#!/usr/bin/pythonCGI 2import RPi.GPIO as GPIO 3from flup.server.fcgi import WSGIServer 4import sys, urlparse 5 6GPIO.setmode(GPIO.BOARD) 7GPIO.setup(11, GPIO.OUT) 8 9def app(environ, start_response): 10 start_response("200 OK", [("Content-Type", "text/html")]) 11 i = urlparse.parse_qs(environ["QUERY_STRING"]) 12 yield (' ') # flup expects a string to be returned from this function 13 14WSGIServer(app).run()

投稿2020/06/27 01:10

編集2020/06/27 01:12
yymmt

総合スコア1615

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問