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

Q&A

0回答

847閲覧

Apache don't work after setting the mod_wsgi

ASAPBYAF

総合スコア2

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Webサーバー

Webサーバーとは、HTTPリクエストに応じて、クライアントに情報を提供するシステムです。

0グッド

0クリップ

投稿2021/09/16 08:09

編集2021/09/16 08:11

0

0

#I want to connect Apache with mod_wsgi and create the server which serves the reuslt of python files. I don't use any flameworks.
I use apache=ver.2.4.48 and mod_wsgi=ver.4.9.0.

#Firtst, I confirm that Apache serves the HTMLfiles without mod_wsgi.
Concreatly, when curl localhost:80 or curl localhost:81 is input, I can see the output of the HTMLfile I make.

#Then, I want to connect Apache with mod_wsgi.
mod_wsgi is installed in the virtual environment of conda.The conda environment is constructed with anaconda installed from the resorce cord.

#In this environment, four settings are done as below.
###(1)Setting of WSGIScriptAlias(/usr/local/apache2/conf/extra/httpd-vhosts.conf)

Listen 81 <VirtualHost *:81> ServerName wsgiapp.example.com DocumentRoot "/usr/local/vhosts" <Directory "/usr/local/vhosts"> AllowOverride All Require all granted </Directory> Alias /vhalias "/usr/local/vhalias" <Directory "/usr/local/vhalias"> AllowOverride All Require all granted </Directory> WSGIScriptAlias /myapp "/usr/local/www/myapp.wsgi" <Directory "/usr/local/www"> AllowOverride All Require all granted </Directory> </VirtualHost>

###(2)Setting of Load module(/usr/local/apache2/conf/httpd.conf)

LoadModule wsgi_module /home/vagrant/anaconda3/envs/gaia/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so

This directory is checked by mod_wsgi-express module-config.
###(3)Uncomment Include conf/extra/httpd-vhosts.conf(/usr/local/apache2/conf/httpd.conf)

# Virtual hosts Include conf/extra/httpd-vhosts.conf

###(4)Setting of myapp.wsgi(/usr/local/www/myapp.wsgi)

def application(environ, start_response): status = '200 OK' output = b'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]

#After I set as above and restart the apache, apache don't react against curl localhost:80,curl localhost:81,curl and localhost:81/myapp. Errors don't even happen.

I confirm that Apache is running by using the command like systemctl status apache2.
The below is the status.

apache2.service - Apache httpd daemon Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled) Active: active (running) since 木 2021-09-16 16:15:24 JST; 4s ago Process: 27620 ExecStart=/usr/local/apache2/bin/apachectl -k start (code=exited, status=0/SUCCESS) Main PID: 27623 (httpd) Tasks: 5 CGroup: /system.slice/apache2.service └─27623 /usr/local/apache2/bin/httpd -k start

And I try some other ways of settiing as below.
(1)On httpd-vhosts.conf, Set Both Load module and WSGIScriptAlias
(2)On Both httpd.conf and httpd-vhosts.conf, Set Load module. On httpd-vhosts.conf, set WSGIScriptAlias
In both case, Apache don't reply.

#Can you tell me the right way of setting of mod_wsgi? Thank you in advance.

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.29%

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

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

質問する

関連した質問