gpt4 book ai didi

python - 在 Ubuntu 远程服务器上安装 Django 项目

转载 作者:行者123 更新时间:2023-12-04 18:51:16 25 4
gpt4 key购买 nike

我正在尝试安装我的 Django project从我的 MacOSX localhost 到 ubuntu 远程服务器。为了显示我的项目,我遇到了 Apache 的问题。

这是我已经完成的一些步骤:

  • 创建一个 IP 地址为 172.30.10.58
  • 的 ubuntu 远程服务器
  • 将我的 Django 项目复制/粘贴到/var/www/html/
  • 安装 Apache2
  • 安装所有 Django 模块(没关系,因为如果我运行 python manage.py runserver ,我不会收到错误)

  • 我遵循了一些教程:
  • Running django project on apache in ubuntu

  • 所以我的 /etc/apache2/sites-available/000-defaut.conf 好像 :
    <VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/etat_civil/


    Alias /static/ /var/www/html/etat_civil/BirthCertificate/static/
    Alias /uploads/ /secure_dir/uploads/

    WSGIDaemonProcess daemon-etat_civil user=www-data group=www-data processes=1 maximum-requests=1 threads=1 inactivity-timeout=6
    WSGIProcessGroup daemon-etat_civil
    WSGIScriptAlias / /var/www/html/etat_civil/Etat_civil/wsgi.py

    <Directory /var/www/html/etat_civil/Etat_civil>
    Order deny,allow
    Allow from all
    </Directory>

    <Location "/uploads/">
    SetHandler None
    </Location>

    ErrorLog /var/log/apache2/monprojet.error.log
    CustomLog /var/log/apache2/mystock.access.log combined

    </VirtualHost>

    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

    然后,我运行: python manage.py runserver
    我越来越 :
    ec@srvEC:/var/www/html/etat_civil$ python manage.py runserver
    Performing system checks...

    System check identified some issues:

    WARNINGS:
    ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.

    System check identified 1 issue (0 silenced).
    January 31, 2017 - 09:25:12
    Django version 1.10.5, using settings 'Etat_civil.settings'
    Starting development server at http://127.0.0.1:8000/
    Quit the server with CONTROL-C.

    但是当我在浏览器中运行时: http://172.30.10.58或者别的什么,我得到:

    enter image description here

    或者

    enter image description here

    你能帮我弄一个工作的 Django 项目吗?

    谢谢

    编辑:

    日志文件 :
    [Tue Jan 31 11:12:47.052359 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] mod_wsgi (pid=7731): Target WSGI script '/var/www/html/etat_civil/Etat_civil/wsgi.py' cannot be loaded as Python module.
    [Tue Jan 31 11:12:47.052493 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] mod_wsgi (pid=7731): Exception occurred processing WSGI script '/var/www/html/etat_civil/Etat_civil/wsgi.py'.
    [Tue Jan 31 11:12:47.052529 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] Traceback (most recent call last):
    [Tue Jan 31 11:12:47.052560 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/var/www/html/etat_civil/Etat_civil/wsgi.py", line 16, in <module>
    [Tue Jan 31 11:12:47.052660 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] application = get_wsgi_application()
    [Tue Jan 31 11:12:47.052677 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    [Tue Jan 31 11:12:47.052727 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] django.setup(set_prefix=False)
    [Tue Jan 31 11:12:47.052744 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup
    [Tue Jan 31 11:12:47.052793 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    [Tue Jan 31 11:12:47.052807 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__
    [Tue Jan 31 11:12:47.052900 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] self._setup(name)
    [Tue Jan 31 11:12:47.052917 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
    [Tue Jan 31 11:12:47.052940 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] self._wrapped = Settings(settings_module)
    [Tue Jan 31 11:12:47.052951 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 97, in __init__
    [Tue Jan 31 11:12:47.052968 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] mod = importlib.import_module(self.SETTINGS_MODULE)
    [Tue Jan 31 11:12:47.052979 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    [Tue Jan 31 11:12:47.053042 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] __import__(name)
    [Tue Jan 31 11:12:47.053070 2017] [:error] [pid 7731] [remote 172.30.10.54:52913] ImportError: No module named Etat_civil.settings

    和树结构:
    .
    ├── etat_civil
    │   ├── Accueil
    │   │   ├── admin.py
    │   │   ├── admin.pyc
    │   │   ├── apps.py
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── static
    │   │   │   ├── css
    │   │   │   │   └── Base.css
    │   │   │   └── images
    │   │   │   ├── admin.png
    │   │   │   ├── employé.png
    │   │   │   ├── logo.png
    │   │   │   ├── maire.png
    │   │   │   ├── officier.png
    │   │   │   └── visiteur.png
    │   │   ├── templates
    │   │   │   └── Accueil.html
    │   │   ├── templatetags
    │   │   │   ├── __init__.py
    │   │   │   ├── __init__.pyc
    │   │   │   ├── user_tags.py
    │   │   │   └── user_tags.pyc
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── views.py
    │   │   └── views.pyc
    │   ├── BirthCertificate
    │   │   ├── admin.py
    │   │   ├── admin.pyc
    │   │   ├── apps.py
    │   │   ├── forms.py
    │   │   ├── forms.pyc
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── migrations
    │   │   │   ├── 0001_initial.py
    │   │   │   ├── 0001_initial.pyc
    │   │   │   ├── __init__.py
    │   │   │   └── __init__.pyc
    │   │   ├── models.py
    │   │   ├── models.pyc
    │   │   ├── __pycache__
    │   │   │   ├── admin.cpython-35.pyc
    │   │   │   ├── countries.cpython-35.pyc
    │   │   │   ├── forms.cpython-35.pyc
    │   │   │   ├── __init__.cpython-35.pyc
    │   │   │   ├── models.cpython-35.pyc
    │   │   │   ├── sexe.cpython-35.pyc
    │   │   │   ├── urls.cpython-35.pyc
    │   │   │   └── views.cpython-35.pyc
    │   │   ├── static
    │   │   │   ├── css
    │   │   │   │   └── BC_base.css
    │   │   │   └── images
    │   │   │   └── logo.jpeg
    │   │   ├── templates
    │   │   │   ├── BC_accueil.html
    │   │   │   ├── BC_form.html
    │   │   │   ├── BC_PDF.html
    │   │   │   ├── BC_preview.html
    │   │   │   ├── BC_raw2.html
    │   │   │   ├── BC_raw.html
    │   │   │   ├── BC_resume.html
    │   │   │   └── Not_Found.html
    │   │   ├── templatetags
    │   │   │   ├── __init__.py
    │   │   │   ├── __init__.pyc
    │   │   │   ├── user_tags.py
    │   │   │   └── user_tags.pyc
    │   │   ├── tests.py
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── views.py
    │   │   └── views.pyc
    │   ├── db.sqlite3
    │   ├── Etat_civil
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── __pycache__
    │   │   │   ├── __init__.cpython-35.pyc
    │   │   │   ├── settings.cpython-35.pyc
    │   │   │   ├── urls.cpython-35.pyc
    │   │   │   └── wsgi.cpython-35.pyc
    │   │   ├── settings.py
    │   │   ├── settings.pyc
    │   │   ├── static
    │   │   │   ├── css
    │   │   │   │   └── BC_base.css
    │   │   │   └── images
    │   │   │   ├── chantier.jpeg
    │   │   │   ├── chantier.png
    │   │   │   └── logo.png
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── wsgi.py
    │   │   └── wsgi.pyc
    │   ├── Identity
    │   │   ├── admin.py
    │   │   ├── admin.pyc
    │   │   ├── apps.py
    │   │   ├── forms.py
    │   │   ├── forms.pyc
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── migrations
    │   │   │   ├── 0001_initial.py
    │   │   │   ├── 0001_initial.pyc
    │   │   │   ├── __init__.py
    │   │   │   └── __init__.pyc
    │   │   ├── models.py
    │   │   ├── models.pyc
    │   │   ├── __pycache__
    │   │   │   ├── admin.cpython-35.pyc
    │   │   │   ├── countries.cpython-35.pyc
    │   │   │   ├── forms.cpython-35.pyc
    │   │   │   ├── __init__.cpython-35.pyc
    │   │   │   ├── models.cpython-35.pyc
    │   │   │   ├── sexe.cpython-35.pyc
    │   │   │   ├── urls.cpython-35.pyc
    │   │   │   └── views.cpython-35.pyc
    │   │   ├── static
    │   │   │   ├── css
    │   │   │   │   └── Base.css
    │   │   │   └── images
    │   │   │   └── logo.png
    │   │   ├── templates
    │   │   │   ├── delete.html
    │   │   │   ├── edit.html
    │   │   │   ├── form_Identity.html
    │   │   │   ├── Identity_home.html
    │   │   │   ├── identity_resume.html
    │   │   │   ├── preview.html
    │   │   │   └── resume.html
    │   │   ├── templatetags
    │   │   │   ├── __init__.py
    │   │   │   ├── __init__.pyc
    │   │   │   ├── user_tags.py
    │   │   │   └── user_tags.pyc
    │   │   ├── tests.py
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── views.py
    │   │   └── views.pyc
    │   ├── log
    │   │   ├── admin.py
    │   │   ├── admin.pyc
    │   │   ├── apps.py
    │   │   ├── forms.py
    │   │   ├── forms.pyc
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── migrations
    │   │   │   ├── 0001_initial.py
    │   │   │   ├── 0001_initial.pyc
    │   │   │   ├── __init__.py
    │   │   │   └── __init__.pyc
    │   │   ├── models.py
    │   │   ├── models.pyc
    │   │   ├── templates
    │   │   │   └── connexion.html
    │   │   ├── templatetags
    │   │   │   ├── __init__.py
    │   │   │   ├── __init__.pyc
    │   │   │   ├── user_tags.py
    │   │   │   └── user_tags.pyc
    │   │   ├── tests.py
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── views.py
    │   │   └── views.pyc
    │   ├── Mairie
    │   │   ├── admin.py
    │   │   ├── admin.pyc
    │   │   ├── apps.py
    │   │   ├── forms.py
    │   │   ├── forms.pyc
    │   │   ├── __init__.py
    │   │   ├── __init__.pyc
    │   │   ├── migrations
    │   │   │   ├── 0001_initial.py
    │   │   │   ├── 0001_initial.pyc
    │   │   │   ├── __init__.py
    │   │   │   └── __init__.pyc
    │   │   ├── models.py
    │   │   ├── models.pyc
    │   │   ├── __pycache__
    │   │   │   ├── admin.cpython-35.pyc
    │   │   │   ├── countries.cpython-35.pyc
    │   │   │   ├── forms.cpython-35.pyc
    │   │   │   ├── __init__.cpython-35.pyc
    │   │   │   ├── models.cpython-35.pyc
    │   │   │   ├── sexe.cpython-35.pyc
    │   │   │   ├── urls.cpython-35.pyc
    │   │   │   └── views.cpython-35.pyc
    │   │   ├── static
    │   │   │   ├── css
    │   │   │   │   └── Base.css
    │   │   │   └── images
    │   │   │   └── logo.png
    │   │   ├── templates
    │   │   │   ├── Mairie_form.html
    │   │   │   ├── Mairie_home.html
    │   │   │   └── Mairie_Resume.html
    │   │   ├── templatetags
    │   │   │   ├── __init__.py
    │   │   │   ├── __init__.pyc
    │   │   │   ├── user_tags.py
    │   │   │   └── user_tags.pyc
    │   │   ├── tests.py
    │   │   ├── urls.py
    │   │   ├── urls.pyc
    │   │   ├── views.py
    │   │   └── views.pyc
    │   ├── manage.py
    │   ├── media
    │   │   └── logo.jpeg
    │   ├── static
    │   │   └── images
    │   └── templates
    │   ├── Base_Accueil.html
    │   ├── Base_BirthCertificate.html
    │   ├── Base_Identity.html
    │   ├── Base_Mairie.html
    │   └── Base_Not_Found.html
    ├── index.html
    └── Individus

    最佳答案

    在你的 apache 配置文件中导入 mod_wsgi 模块

    /etc/apache2/sites-available/000-defaut.conf

    关于python - 在 Ubuntu 远程服务器上安装 Django 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41953852/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com