Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在虚拟机上设置django_Python_Django_Apache - Fatal编程技术网

Python 在虚拟机上设置django

Python 在虚拟机上设置django,python,django,apache,Python,Django,Apache,我有一个运行peppermint os 2(基本上是ubuntu)的虚拟机 我一直在尝试遵循以下教程: 到目前为止,一切都如教程所述。我的Apache httpd.conf文件如下所示: ServerName localhost MaxRequestsPerChild 1 SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODUL

我有一个运行peppermint os 2(基本上是ubuntu)的虚拟机

我一直在尝试遵循以下教程:

到目前为止,一切都如教程所述。我的Apache httpd.conf文件如下所示:

ServerName localhost

MaxRequestsPerChild 1

    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE myproject.settings
    PythonPath "['/home/<my_user_name>/django_projects'] + sys.path"

    SetHandler None

    SetHandler None

    SetHandler None

    SetHandler None
cd /etc/apache2/mod_available
cp mod_wsgi.* ../mod_enable
sudo service apache2 restart
ServerName本地主机
MaxRequestsPerChild 1
SetHandler python程序
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_设置_模块myproject.SETTINGS
PythonPath“['/home//django_projects']+sys.path”
SetHandler无
SetHandler无
SetHandler无
SetHandler无
每当我尝试进入“localhost/”时,它都会显示/var/www/文件夹(index.html文件,上面写着“it works!”),而不是应该出现的django起始页。my/var/www的内容是“管理媒体”和“媒体”

我需要做什么? 谢谢。

试试或者,它更容易配置,更健壮,速度更快

你也可以在

当您使用ubuntu时,mod_wsgi的安装非常简单:

sudo apt-get install libapache2-mod-wsgi
如果未启用mod wsgi,请执行以下操作:

ServerName localhost

MaxRequestsPerChild 1

    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE myproject.settings
    PythonPath "['/home/<my_user_name>/django_projects'] + sys.path"

    SetHandler None

    SetHandler None

    SetHandler None

    SetHandler None
cd /etc/apache2/mod_available
cp mod_wsgi.* ../mod_enable
sudo service apache2 restart
对于使用mod_python,apache配置为:

ameVirtualHost *:80
NameVirtualHost *:8000
Listen 80
Listen 8000

WSGIDaemonProcess xxxx display-name=%{GROUP}
WSGIProcessGroup xxxx
<VirtualHost *:80>
    ServerName  xxxx
    WSGIScriptAlias / /home/xxx/xxxx/xxxx.wsgi

    Alias /js "/home/xxx/xxxx/xxxx/public/js"
    <Location "/js">
        SetHandler None
    </Location>
    <Directory "/home/xxx/xxxx/xxxx/public/js">
       Order Deny,Allow
       Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost *:8080
<VirtualHost *:8080>
        WSGIScriptAlias / /home/xxxx/xxxx/wsgi_handler.py
        #WSGIDaemonProcess xxxx_com22 user=xxxx processes=1 threads=10
        #WSGIProcessGroup xxxx_com1

        Alias /upload/ "/home/xxxx/xxxx/upload/"
        <Directory /home/xxxx/xxxx/upload/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
Listen 8080
ameVirtualHost*:80
名称虚拟主机*:8000
听80
听着
WSGIDaemonProcess xxxx显示名称=%{GROUP}
WSGIProcessGroup xxxx
服务器名xxxx
WSGIScriptAlias//home/xxx/xxxx/xxxx.wsgi
别名/js“/主页/xxx/xxxx/xxxx/public/js”
SetHandler无
命令拒绝,允许
通融
名称虚拟主机*:8080
WSGIScriptAlias//home/xxxx/xxxx/wsgi_handler.py
#WSGIDaemonProcess xxxx\U com22用户=xxxx进程=1线程=10
#WSGIProcessGroup xxxx_com1
别名/upload/“/home/xxxx/xxxx/upload/”
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
听8080
对于使用uwsgi,我推荐使用nginx+uwsgi,如果您感兴趣,我将发布教程和配置