使用Mod_WSGI将WS添加到以Daemon模式运行的我的Django应用程序

时间:2018-02-19 18:39:03

标签: python django apache2 mod-wsgi

我做了一些研究,找不到适合我的解决方案......

我当前的apache2.conf档案:

<VirtualHost xxx.xx.xxx.xxx:8080>

    ServerName website.com
    ServerAlias www.website.com
    ServerAdmin admin@website.com
    DocumentRoot /home/USER/web/website.com/djagno_project/app/
    ScriptAlias /cgi-bin/ /home/web/cgi-bin/
    Alias /vstats/ /home/USER/web/website.com/stats/
    Alias /error/ /home/USER/web/website.com/document_errors/
    #SuexecUserGroup USER USER
    CustomLog /var/log/apache2/domains/website.com.bytes bytes
    CustomLog /var/log/apache2/domains/website.com.log combined
    ErrorLog /var/log/apache2/domains/website.com.error.log
    <Directory /home/USER/web/website.com/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
        php_admin_value open_basedir /home/USER/web/website.com/django_project/app:/home/USER/tmp
        php_admin_value upload_tmp_dir /home/USER/tmp
        php_admin_value session.save_path /home/USER/tmp
    </Directory>
    <Directory /home/USER/web/website.com/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid USER USER
        RGroups www-data
    </IfModule>

    <IfModule itk.c>
        AssignUserID USER USER
    </IfModule>

    IncludeOptional /home/USER/conf/web/apache2.website.com.conf*

    Alias /static /home/USER/web/website.com/django_project/app/static
    <Directory /home/USER/web/website.com/django_project/app/static>
        Require all granted
    </Directory>

    <Directory /home/USER/web/website.com/django_project/project>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    <Directory /home/USER/web/website.com/django_project/app/>
        AllowOverride All
        Options +Includes
    </Directory>

    LoadModule wsgi_module "/usr/local/lib/python2.7/dist-packages/mod_wsgi/server/mod_wsgi-py27.so"

    WSGIScriptAlias / /home/USER/web/website.com/django_project/project/wsgi.py
    WSGIDaemonProcess www.website.com socket-user=USER group=USER processes=2 threads=25
    WSGIProcessGroup www.website.com
    WSGIApplicationGroup USER

    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

SSLEngine on
    SSLCertificateFile /home/USER/conf/web/ssl.website.com.crt
    SSLCertificateKeyFile /home/USER/conf/web/ssl.website.com.key
    SSLCACertificateFile /home/USER/conf/web/ssl.website.com.crt

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^website\.com
    RewriteRule ^(.*)$ https://www.website.com$1 [R=permanent,L]

    RewriteCond %{HTTP_HOST} ^www\.website\.com
    RewriteRule ^(.*)$ https://www.website.com$1 [R=permanent,L]
</VirtualHost>

WSGIPythonHome "/usr/local/.virtualenvs/PROJECT"

在我开始使用SSL

之前,一切正常

在我添加SSL之前,我的静态文件正在正常加载,当我在本地主机上开发我的网站时,一切正常。我的研究让我加入了SSLEngine代码以及RewriteCond代码(我发现这些代码非常有助于阻止人们从{{{}移除{&#39; 1}}一旦网站加载了。

0 个答案:

没有答案