1

我尝试在我的专用服务器中使用 Django,如果有人可以帮助我使用在 y 服务器中运行的 centos 7 python 在 apache 服务器中设置 Django 以及何时

我在端口 0.0.0.0:8000 中使用“Django 运行服务器”在活动源运行良好但我无法在我的 apache 服务器中运行 Django 我认为问题可能是因为我没有 WSGI 但我什至不知道如何要设置它,我在我的根目录中运行此评论

“点安装 mod_wsgi”

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting mod_wsgi
  Using cached https://files.pythonhosted.org/packages/47/69/5139588686eb40053f8355eba1fe18a8bee94dc3efc4e36720c73e07471a/mod_wsgi-4.6.5.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-f6NC1P/mod-wsgi/setup.py", line 168, in <module>
        'missing Apache httpd server packages.' % APXS)
    RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites inthe documentation for this package and install any missing Apache httpd server packages.
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-f6NC1P/mod-wsgi/

接下来,我尝试了 sudo yum install mod_wsgi -y

Loaded plugins: fastestmirror, langpacks, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 104.219.172.10
 * cpanel-addons-production-feed: 104.219.172.10
 * cpanel-plugins: 104.219.172.10
 * base: repos-lax.psychz.net
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: mirrors.usc.edu
 * ius: mirrors.kernel.org
 * updates: mirror.fileplanet.com
Resolving Dependencies
--> Running transaction check
---> Package mod_wsgi.x86_64 0:3.4-18.el7 will be installed
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: mod_wsgi-3.4-18.el7.x86_64
--> Finished Dependency Resolution
Error: Package: mod_wsgi-3.4-18.el7.x86_64 (base)
           Requires: httpd-mmn = 20120211x8664
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我的第一个问题是我是否在我的系统中安装了 wsgi,如果我有下一步是配置我的 apache 服务器,那么当我在我的 etc 文件夹中创建 django.conf 文件时,下一个问题是我检查所有关于配置的卡住溢出我的 apache 服务器和它们都对我不起作用我的 django.conf 在“/etc/httpd/conf.d”中

<virtualHost *:80>
 ServerAdmin webmaster@mysite.com
 ServerName  djangotest.mysite.com
 DocumentRoot /home/user6/public_html/djangotest.mysite.com/httdocs
 ErrorLog   /var/log/httpd/djangotest.mysite.com-error.log
 CustomLog  /var/log/httpd/djangotest.mysite.com-access.log combined
 WSGIScriptAlias / /home/user6/public_html/django1/djangotest/djangotest/wsgi.py
</VirtualHost>

WSGIPythonPath /home/user6/public_html/django1/djangotest/djangotest

# Further relax access to the default document root:
<Directory "/home/sites/djangotest.mysite.com//htdocs">
        Option Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
<Directory "/home/user6/django1/djangotest/djangotest">
        <Files wsgi.py>
                Require all granted
        </Files>
</Directory>

当我输入 python 并遵循它时,我使用 inmotion 托管一个专用服务器

python
>>> import django
>>> django.VERSION

结果是

[root@ded4729 conf.d]# python
Python 2.7.5 (default, Apr  9 2019, 14:30:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 11, 20, u'final', 0)
>>>

再次在实践服务器中,我的应用程序运行良好,问题是我无法使用 centos 在 apache 中运行它

4

0 回答 0