django setup in apache +centos 7

784 Views Asked by At

I tried to used Django in my dedicated server and I got few issues if anybody can help me to setup Django in apache server using centos 7 python run in y server and when

I use "Django run server" in port 0.0.0.0:8000 after active source its work well but I cannot run Django in my apache server I thought the issue may be because I don't have WSGI but I don't know even how to set it up I run this comment in my root

"pip install 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/

next, I tried 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

my first question is am I have wsgi install in my system or not and if I have next step is to config my apache server then when I make django.conf file in my etc folder then the next question is I check all stuck overflow about config my apache server and all of them don't work for me my django.conf is in "/etc/httpd/conf.d"

<virtualHost *:80>
 ServerAdmin [email protected]
 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>

I use inmotion hosting a dedicated server when I type python and follow that

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

the result is

[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)
>>>

and once again in practice server, my app works well and the problem is I cannot run it in apache with centos

0

There are 0 best solutions below