#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.
あなたの回答
tips
プレビュー