skip to Main Content

Can’t start server using Apache + Django

OS: MacOS Catalina
Apache: 2.4.43
Python: 3.8
Django: 3.0.7

Used by Apache from Brew.
mod_wsgi installed via pip.

The application is created through the standard command

django-admin startproject project_temp

The application starts when the command is called

python manage.py runserver

At start for mod_wsgi – everything is OK

mod_wsgi-express start-server

When I start Apache, the server is not accessible.
Checked at "localhost: 80".

Tell me, what do I need to do to start the server?

Httpd settings:

ServerRoot "/usr/local/opt/httpd"
ServerName localhost
Listen 80

LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule authn_file_module lib/httpd/modules/mod_authn_file.so
LoadModule authn_core_module lib/httpd/modules/mod_authn_core.so
LoadModule authz_host_module lib/httpd/modules/mod_authz_host.so
LoadModule authz_groupfile_module lib/httpd/modules/mod_authz_groupfile.so
LoadModule authz_user_module lib/httpd/modules/mod_authz_user.so
LoadModule authz_core_module lib/httpd/modules/mod_authz_core.so
LoadModule access_compat_module lib/httpd/modules/mod_access_compat.so
LoadModule auth_basic_module lib/httpd/modules/mod_auth_basic.so
LoadModule reqtimeout_module lib/httpd/modules/mod_reqtimeout.so
LoadModule filter_module lib/httpd/modules/mod_filter.so
LoadModule mime_module lib/httpd/modules/mod_mime.so
LoadModule log_config_module lib/httpd/modules/mod_log_config.so
LoadModule env_module lib/httpd/modules/mod_env.so
LoadModule headers_module lib/httpd/modules/mod_headers.so
LoadModule setenvif_module lib/httpd/modules/mod_setenvif.so
LoadModule version_module lib/httpd/modules/mod_version.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
LoadModule status_module lib/httpd/modules/mod_status.so
LoadModule autoindex_module lib/httpd/modules/mod_autoindex.so
LoadModule alias_module lib/httpd/modules/mod_alias.so
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule wsgi_module /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-darwin.so

<Directory />
    AllowOverride All
</Directory>

<Files ".ht*">
    Require all denied
</Files>

<IfModule log_config_module>
    LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
    LogFormat "%h %l %u %t "%r" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
    </IfModule>

    CustomLog "/usr/local/var/log/httpd/access_log" common
</IfModule>

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    TypesConfig /usr/local/etc/httpd/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

<IfModule proxy_html_module>
    Include /usr/local/etc/httpd/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

WSGIScriptAlias / /Users/r/Projects/project_temp/project_temp/wsgi.py
WSGIPythonHome /Library/Frameworks/Python.framework/Versions/3.8

<VirtualHost localhost:80>
    LogLevel warn
    ErrorLog /Users/r/Projects/project_temp/log/error.log
    CustomLog /Users/r/Projects/project_temp/log/access.log combined

    <Directory /Users/r/Projects/project_temp/project_temp>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
</VirtualHost>

2

Answers


  1. Chosen as BEST ANSWER

    Solution to the problem

    1. looked at statistics, who listens to ports - did not find httpd
    2. ran httpd using brew. Launched using apachectl - it worked

    There were other problems with django, but that's another question


  2. I don’t know much about your configuration, but I do have this line in my Linux / Apache / WSGI configuration:

    WSGIDaemonProcess constr processes=2 threads=15 display-name=%{GROUP} python-home=/www/constr/venv python-path=/www/constr
    WSGIProcessGroup constr
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search