Configure Django applications with apache, wsgi and MySQL on CentOS 7

Django is popular Web framework for writing web applications. With django you can built faster and scalable applications, without writing the code from scratch (without reinventing the wheel). Web framework were design to aid programmer to create applications. These web framework are the core and takes care of functionalities like user session managemet, database connectivity etc.

CentOS 7 still have Python 2.7 as the default tool. Now, lets install pip and python devel, libraries and setup tools.

[dweb@wave ~]$ python -V
Python 2.7.5
[dweb@wave ~]$ sudo yum install python2-pip python-devel python-setuptools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * epel: epel.mirror.net.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
--> Running transaction check
---> Package python-devel.x86_64 0:2.7.5-48.el7 will be installed
--> Processing Dependency: python(x86-64) = 2.7.5-48.el7 for package: python-devel-2.7.5-48.el7.x86_64
---> Package python-setuptools.noarch 0:0.9.8-4.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-4.el7.noarch
---> Package python2-pip.noarch 0:8.1.2-5.el7 will be installed
--> Running transaction check
---> Package python.x86_64 0:2.7.5-34.el7 will be updated
---> Package python.x86_64 0:2.7.5-48.el7 will be an update
--> Processing Dependency: python-libs(x86-64) = 2.7.5-48.el7 for package: python-2.7.5-48.el7.x86_64
---> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 will be installed
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-libs.x86_64 0:2.7.5-34.el7 will be updated
---> Package python-libs.x86_64 0:2.7.5-48.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved
===========================================================================================================================================================
 Package                                                  Arch                        Version                              Repository                 Size
===========================================================================================================================================================
Installing:
 python-devel                                             x86_64                      2.7.5-48.el7                         base                      393 k
 python-setuptools                                        noarch                      0.9.8-4.el7                          base                      396 k
 python2-pip                                              noarch                      8.1.2-5.el7                          epel                      1.7 M
Installing for dependencies:
 python-backports                                         x86_64                      1.0-8.el7                            base                      5.8 k
 python-backports-ssl_match_hostname                      noarch                      3.4.0.2-4.el7                        base                       12 k
Updating for dependencies:
 python                                                   x86_64                      2.7.5-48.el7                         base                       90 k
 python-libs                                              x86_64                      2.7.5-48.el7                         base                      5.6 M

Transaction Summary
===========================================================================================================================================================
Install  3 Packages (+2 Dependent packages)
Upgrade             ( 2 Dependent packages)

Total download size: 8.2 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/7): python-backports-1.0-8.el7.x86_64.rpm                                                                                        | 5.8 kB  00:00:00
(2/7): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm                                                                 |  12 kB  00:00:00
(3/7): python-2.7.5-48.el7.x86_64.rpm                                                                                               |  90 kB  00:00:00
(4/7): python-devel-2.7.5-48.el7.x86_64.rpm                                                                                         | 393 kB  00:00:00
(5/7): python-setuptools-0.9.8-4.el7.noarch.rpm                                                                                     | 396 kB  00:00:00
(6/7): python-libs-2.7.5-48.el7.x86_64.rpm                                                                                          | 5.6 MB  00:00:01
(7/7): python2-pip-8.1.2-5.el7.noarch.rpm                                                                                           | 1.7 MB  00:00:03
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      1.9 MB/s | 8.2 MB  00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : python-libs-2.7.5-48.el7.x86_64                                                                                                         1/9
  Updating   : python-2.7.5-48.el7.x86_64                                                                                                              2/9
  Installing : python-backports-1.0-8.el7.x86_64                                                                                                       3/9
  Installing : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                4/9
  Installing : python-setuptools-0.9.8-4.el7.noarch                                                                                                    5/9
  Installing : python2-pip-8.1.2-5.el7.noarch                                                                                                          6/9
  Installing : python-devel-2.7.5-48.el7.x86_64                                                                                                        7/9
  Cleanup    : python-2.7.5-34.el7.x86_64                                                                                                              8/9
  Cleanup    : python-libs-2.7.5-34.el7.x86_64                                                                                                         9/9
  Verifying  : python-setuptools-0.9.8-4.el7.noarch                                                                                                    1/9
  Verifying  : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                2/9
  Verifying  : python2-pip-8.1.2-5.el7.noarch                                                                                                          3/9
  Verifying  : python-libs-2.7.5-48.el7.x86_64                                                                                                         4/9
  Verifying  : python-2.7.5-48.el7.x86_64                                                                                                              5/9
  Verifying  : python-backports-1.0-8.el7.x86_64                                                                                                       6/9
  Verifying  : python-devel-2.7.5-48.el7.x86_64                                                                                                        7/9
  Verifying  : python-2.7.5-34.el7.x86_64                                                                                                              8/9
  Verifying  : python-libs-2.7.5-34.el7.x86_64                                                                                                         9/9

Installed:
  python-devel.x86_64 0:2.7.5-48.el7                python-setuptools.noarch 0:0.9.8-4.el7                python2-pip.noarch 0:8.1.2-5.el7

Dependency Installed:
  python-backports.x86_64 0:1.0-8.el7                              python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7

Dependency Updated:
  python.x86_64 0:2.7.5-48.el7                                              python-libs.x86_64 0:2.7.5-48.el7

Complete!
[dweb@wave ~]$

[dweb@wave ~]$ sudo yum install python-virtualenv
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * epel: epel.mirror.net.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
--> Running transaction check
---> Package python-virtualenv.noarch 0:1.10.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved
===========================================================================================================================================================
 Package                                     Arch                             Version                                 Repository                      Size
===========================================================================================================================================================
Installing:
 python-virtualenv                           noarch                           1.10.1-3.el7                            base                           1.2 M

Transaction Summary
===========================================================================================================================================================
Install  1 Package

Total download size: 1.2 M
Installed size: 1.6 M
Is this ok [y/d/N]: y
Downloading packages:
python-virtualenv-1.10.1-3.el7.noarch.rpm                                                                                           | 1.2 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-virtualenv-1.10.1-3.el7.noarch                                                                                                   1/1
  Verifying  : python-virtualenv-1.10.1-3.el7.noarch                                                                                                   1/1

Installed:
  python-virtualenv.noarch 0:1.10.1-3.el7

Complete!
[dweb@wave ~]$
[dweb@wave ~]$ python -V
Python 2.7.5
[dweb@wave ~]$ pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

Successfully, installed pip and python related tools.

It is recommended to install development tools.

[dweb@wave ~]$ sudo yum groupinstall 'Development Tools'

Install MySQL Server

MySQL is the most popular database management system used for powering web applications. MariaDB becomes the default database and MySQL is no longer available in CentOS 7. MariaDB is a drop in replacement for MySQL. In order to install MySQL, we have to install MySQL repository from mysql.com site. The choice is yours, you can go with MySQL, MariaDB or Percona fork. I’ll use MariaDB.

[dweb@wave ~]$ sudo yum install mariadb-server mariadb-devel mariadb-libs
[sudo] password for dweb:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * epel: epel.mirror.net.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.52-1.el7 will be installed
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.52-1.el7.x86_64
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be updated
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be an update
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be installed
--> Processing Dependency: mariadb(x86-64) = 1:5.5.52-1.el7 for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.52-1.el7 will be installed
---> Package openssl-devel.x86_64 1:1.0.1e-60.el7 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7 for package: 1:openssl-devel-1.0.1e-60.el7.x86_64
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.1e-60.el7.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.1e-60.el7.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.14.1-27.el7_3 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.14.1-27.el7_3 for package: krb5-devel-1.14.1-27.el7_3.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.14.1-27.el7_3 for package: krb5-devel-1.14.1-27.el7_3.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.14.1-27.el7_3.x86_64
---> Package openssl-libs.x86_64 1:1.0.1e-42.el7.9 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-42.el7.9 for package: 1:openssl-1.0.1e-42.el7.9.x86_64
---> Package openssl-libs.x86_64 1:1.0.1e-60.el7 will be an update
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
---> Package zlib-devel.x86_64 0:1.2.7-17.el7 will be installed
--> Processing Dependency: zlib = 1.2.7-17.el7 for package: zlib-devel-1.2.7-17.el7.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.13.2-10.el7 will be updated
---> Package krb5-libs.x86_64 0:1.14.1-27.el7_3 will be an update
---> Package libcom_err-devel.x86_64 0:1.42.9-9.el7 will be installed
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-9.el7 for package: libcom_err-devel-1.42.9-9.el7.x86_64
---> Package libkadm5.x86_64 0:1.14.1-27.el7_3 will be installed
---> Package libselinux-devel.x86_64 0:2.5-6.el7 will be installed
--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinux-devel-2.5-6.el7.x86_64
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-6 for package: libselinux-devel-2.5-6.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-6.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-6.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
---> Package openssl.x86_64 1:1.0.1e-42.el7.9 will be updated
---> Package openssl.x86_64 1:1.0.1e-60.el7 will be an update
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
---> Package zlib.x86_64 0:1.2.7-15.el7 will be updated
---> Package zlib.x86_64 0:1.2.7-17.el7 will be an update
--> Running transaction check
---> Package libcom_err.x86_64 0:1.42.9-7.el7 will be updated
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-7.el7 for package: e2fsprogs-libs-1.42.9-7.el7.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-7.el7 for package: e2fsprogs-1.42.9-7.el7.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-7.el7 for package: libss-1.42.9-7.el7.x86_64
---> Package libcom_err.x86_64 0:1.42.9-9.el7 will be an update
---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated
--> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-utils-2.2.2-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-6.el7 will be an update
--> Processing Dependency: libsepol(x86-64) >= 2.5-6 for package: libselinux-2.5-6.el7.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: libselinux-2.5-6.el7.x86_64
---> Package libsepol-devel.x86_64 0:2.5-6.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-15.el7_2.1 will be installed
--> Processing Dependency: pcre(x86-64) = 8.32-15.el7_2.1 for package: pcre-devel-8.32-15.el7_2.1.x86_64
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Running transaction check
---> Package e2fsprogs.x86_64 0:1.42.9-7.el7 will be updated
---> Package e2fsprogs.x86_64 0:1.42.9-9.el7 will be an update
---> Package e2fsprogs-libs.x86_64 0:1.42.9-7.el7 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.42.9-9.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-6.el7 will be an update
---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated
---> Package libsepol.x86_64 0:2.5-6.el7 will be an update
---> Package libss.x86_64 0:1.42.9-7.el7 will be updated
---> Package libss.x86_64 0:1.42.9-9.el7 will be an update
---> Package pcre.x86_64 0:8.32-15.el7 will be updated
---> Package pcre.x86_64 0:8.32-15.el7_2.1 will be an update
--> Processing Conflict: libselinux-2.5-6.el7.x86_64 conflicts systemd < 219-20
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package systemd.x86_64 0:219-19.el7 will be updated
--> Processing Dependency: systemd = 219-19.el7 for package: systemd-sysv-219-19.el7.x86_64
---> Package systemd.x86_64 0:219-30.el7_3.6 will be an update
--> Processing Dependency: systemd-libs = 219-30.el7_3.6 for package: systemd-219-30.el7_3.6.x86_64
--> Running transaction check
---> Package systemd-libs.x86_64 0:219-19.el7 will be updated
--> Processing Dependency: systemd-libs = 219-19.el7 for package: libgudev1-219-19.el7.x86_64
---> Package systemd-libs.x86_64 0:219-30.el7_3.6 will be an update
---> Package systemd-sysv.x86_64 0:219-19.el7 will be updated
---> Package systemd-sysv.x86_64 0:219-30.el7_3.6 will be an update
--> Running transaction check
---> Package libgudev1.x86_64 0:219-19.el7 will be updated
---> Package libgudev1.x86_64 0:219-30.el7_3.6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved
===========================================================================================================================================================
 Package                                        Arch                          Version                                 Repository                      Size
===========================================================================================================================================================
Installing:
 mariadb-devel                                  x86_64                        1:5.5.52-1.el7                          base                           750 k
 mariadb-server                                 x86_64                        1:5.5.52-1.el7                          base                            11 M
Updating:
 mariadb-libs                                   x86_64                        1:5.5.52-1.el7                          base                           761 k
 systemd                                        x86_64                        219-30.el7_3.6                          updates                        5.2 M
Installing for dependencies:
 keyutils-libs-devel                            x86_64                        1.5.8-3.el7                             base                            37 k
 krb5-devel                                     x86_64                        1.14.1-27.el7_3                         updates                        651 k
 libcom_err-devel                               x86_64                        1.42.9-9.el7                            base                            31 k
 libkadm5                                       x86_64                        1.14.1-27.el7_3                         updates                        173 k
 libselinux-devel                               x86_64                        2.5-6.el7                               base                           186 k
 libsepol-devel                                 x86_64                        2.5-6.el7                               base                            74 k
 libverto-devel                                 x86_64                        0.2.5-4.el7                             base                            12 k
 mariadb                                        x86_64                        1:5.5.52-1.el7                          base                           8.7 M
 openssl-devel                                  x86_64                        1:1.0.1e-60.el7                         base                           1.2 M
 pcre-devel                                     x86_64                        8.32-15.el7_2.1                         base                           479 k
 perl-Compress-Raw-Bzip2                        x86_64                        2.061-3.el7                             base                            32 k
 perl-Compress-Raw-Zlib                         x86_64                        1:2.061-4.el7                           base                            57 k
 perl-DBD-MySQL                                 x86_64                        4.023-5.el7                             base                           140 k
 perl-DBI                                       x86_64                        1.627-4.el7                             base                           802 k
 perl-IO-Compress                               noarch                        2.061-2.el7                             base                           260 k
 perl-Net-Daemon                                noarch                        0.48-5.el7                              base                            51 k
 perl-PlRPC                                     noarch                        0.2020-14.el7                           base                            36 k
 zlib-devel                                     x86_64                        1.2.7-17.el7                            base                            50 k
Updating for dependencies:
 e2fsprogs                                      x86_64                        1.42.9-9.el7                            base                           698 k
 e2fsprogs-libs                                 x86_64                        1.42.9-9.el7                            base                           166 k
 krb5-libs                                      x86_64                        1.14.1-27.el7_3                         updates                        740 k
 libcom_err                                     x86_64                        1.42.9-9.el7                            base                            40 k
 libgudev1                                      x86_64                        219-30.el7_3.6                          updates                         76 k
 libselinux                                     x86_64                        2.5-6.el7                               base                           161 k
 libselinux-utils                               x86_64                        2.5-6.el7                               base                           151 k
 libsepol                                       x86_64                        2.5-6.el7                               base                           288 k
 libss                                          x86_64                        1.42.9-9.el7                            base                            45 k
 openssl                                        x86_64                        1:1.0.1e-60.el7                         base                           713 k
 openssl-libs                                   x86_64                        1:1.0.1e-60.el7                         base                           958 k
 pcre                                           x86_64                        8.32-15.el7_2.1                         base                           420 k
 systemd-libs                                   x86_64                        219-30.el7_3.6                          updates                        368 k
 systemd-sysv                                   x86_64                        219-30.el7_3.6                          updates                         63 k
 zlib                                           x86_64                        1.2.7-17.el7                            base                            90 k

Transaction Summary
===========================================================================================================================================================
Install  2 Packages (+18 Dependent packages)
Upgrade  2 Packages (+15 Dependent packages)

Total download size: 35 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
Delta RPMs reduced 6.3 M of updates to 3.5 M (44% saved)
(1/37): krb5-libs-1.13.2-10.el7_1.14.1-27.el7_3.x86_64.drpm                                                                         | 325 kB  00:00:00
(2/37): e2fsprogs-1.42.9-9.el7.x86_64.rpm                                                                                           | 698 kB  00:00:00
(3/37): krb5-devel-1.14.1-27.el7_3.x86_64.rpm                                                                                       | 651 kB  00:00:00
(4/37): e2fsprogs-libs-1.42.9-9.el7.x86_64.rpm                                                                                      | 166 kB  00:00:01
(5/37): libcom_err-1.42.9-9.el7.x86_64.rpm                                                                                          |  40 kB  00:00:00
(6/37): libcom_err-devel-1.42.9-9.el7.x86_64.rpm                                                                                    |  31 kB  00:00:00
(7/37): libgudev1-219-30.el7_3.6.x86_64.rpm                                                                                         |  76 kB  00:00:00
(8/37): systemd-219-19.el7_219-30.el7_3.6.x86_64.drpm                                                                               | 3.0 MB  00:00:01
(9/37): libselinux-2.5-6.el7.x86_64.rpm                                                                                             | 161 kB  00:00:00
(10/37): libselinux-utils-2.5-6.el7.x86_64.rpm                                                                                      | 151 kB  00:00:00
(11/37): libsepol-2.5-6.el7.x86_64.rpm                                                                                              | 288 kB  00:00:00
(12/37): libsepol-devel-2.5-6.el7.x86_64.rpm                                                                                        |  74 kB  00:00:00
(13/37): libss-1.42.9-9.el7.x86_64.rpm                                                                                              |  45 kB  00:00:00
(14/37): libselinux-devel-2.5-6.el7.x86_64.rpm                                                                                      | 186 kB  00:00:00
(15/37): libverto-devel-0.2.5-4.el7.x86_64.rpm                                                                                      |  12 kB  00:00:00
(16/37): mariadb-devel-5.5.52-1.el7.x86_64.rpm                                                                                      | 750 kB  00:00:00
(17/37): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                                                                                 |  37 kB  00:00:01
(18/37): mariadb-libs-5.5.52-1.el7.x86_64.rpm                                                                                       | 761 kB  00:00:00
(19/37): systemd-libs-219-19.el7_219-30.el7_3.6.x86_64.drpm                                                                         | 169 kB  00:00:02
(20/37): openssl-1.0.1e-60.el7.x86_64.rpm                                                                                           | 713 kB  00:00:00
(21/37): openssl-libs-1.0.1e-60.el7.x86_64.rpm                                                                                      | 958 kB  00:00:00
(22/37): pcre-8.32-15.el7_2.1.x86_64.rpm                                                                                            | 420 kB  00:00:00
(23/37): pcre-devel-8.32-15.el7_2.1.x86_64.rpm                                                                                      | 479 kB  00:00:00
(24/37): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                             |  32 kB  00:00:00
(25/37): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                              |  57 kB  00:00:00
(26/37): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                                                                                      | 140 kB  00:00:00
(27/37): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                            | 802 kB  00:00:00
(28/37): mariadb-5.5.52-1.el7.x86_64.rpm                                                                                            | 8.7 MB  00:00:03
(29/37): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                    | 260 kB  00:00:00
(30/37): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                        |  36 kB  00:00:00
(31/37): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                      |  51 kB  00:00:00
(32/37): systemd-sysv-219-30.el7_3.6.x86_64.rpm                                                                                     |  63 kB  00:00:00
(33/37): zlib-devel-1.2.7-17.el7.x86_64.rpm                                                                                         |  50 kB  00:00:00
(34/37): zlib-1.2.7-17.el7.x86_64.rpm                                                                                               |  90 kB  00:00:00
(35/37): libkadm5-1.14.1-27.el7_3.x86_64.rpm                                                                                        | 173 kB  00:00:07
(36/37): openssl-devel-1.0.1e-60.el7.x86_64.rpm                                                                                     | 1.2 MB  00:00:09
(37/37): mariadb-server-5.5.52-1.el7.x86_64.rpm                                                                                     |  11 MB  00:01:03
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      502 kB/s |  32 MB  00:01:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libcom_err-1.42.9-9.el7.x86_64                                                                                                         1/54
  Updating   : zlib-1.2.7-17.el7.x86_64                                                                                                               2/54
  Updating   : libsepol-2.5-6.el7.x86_64                                                                                                              3/54
  Updating   : pcre-8.32-15.el7_2.1.x86_64                                                                                                            4/54
  Updating   : libselinux-2.5-6.el7.x86_64                                                                                                            5/54
  Updating   : 1:openssl-libs-1.0.1e-60.el7.x86_64                                                                                                    6/54
  Updating   : krb5-libs-1.14.1-27.el7_3.x86_64                                                                                                       7/54
  Updating   : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                     8/54
  Updating   : systemd-libs-219-30.el7_3.6.x86_64                                                                                                     9/54
  Updating   : systemd-219-30.el7_3.6.x86_64                                                                                                         10/54
  Installing : 1:mariadb-5.5.52-1.el7.x86_64                                                                                                         11/54
  Installing : libkadm5-1.14.1-27.el7_3.x86_64                                                                                                       12/54
  Installing : pcre-devel-8.32-15.el7_2.1.x86_64                                                                                                     13/54
  Installing : libsepol-devel-2.5-6.el7.x86_64                                                                                                       14/54
  Installing : libselinux-devel-2.5-6.el7.x86_64                                                                                                     15/54
  Installing : zlib-devel-1.2.7-17.el7.x86_64                                                                                                        16/54
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                           17/54
  Installing : libcom_err-devel-1.42.9-9.el7.x86_64                                                                                                  18/54
  Updating   : libss-1.42.9-9.el7.x86_64                                                                                                             19/54
  Updating   : e2fsprogs-libs-1.42.9-9.el7.x86_64                                                                                                    20/54
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                                                                     21/54
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                     22/54
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                            23/54
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                   24/54
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                       25/54
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                           26/54
  Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                     27/54
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                                                28/54
  Installing : krb5-devel-1.14.1-27.el7_3.x86_64                                                                                                     29/54
  Installing : 1:openssl-devel-1.0.1e-60.el7.x86_64                                                                                                  30/54
  Installing : 1:mariadb-devel-5.5.52-1.el7.x86_64                                                                                                   31/54
  Installing : 1:mariadb-server-5.5.52-1.el7.x86_64                                                                                                  32/54
  Updating   : e2fsprogs-1.42.9-9.el7.x86_64                                                                                                         33/54
  Updating   : systemd-sysv-219-30.el7_3.6.x86_64                                                                                                    34/54
  Updating   : libgudev1-219-30.el7_3.6.x86_64                                                                                                       35/54
  Updating   : 1:openssl-1.0.1e-60.el7.x86_64                                                                                                        36/54
  Updating   : libselinux-utils-2.5-6.el7.x86_64                                                                                                     37/54
  Cleanup    : 1:openssl-1.0.1e-42.el7.9.x86_64                                                                                                      38/54
  Cleanup    : e2fsprogs-1.42.9-7.el7.x86_64                                                                                                         39/54
  Cleanup    : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                             40/54
  Cleanup    : systemd-sysv-219-19.el7.x86_64                                                                                                        41/54
  Cleanup    : krb5-libs-1.13.2-10.el7.x86_64                                                                                                        42/54
  Cleanup    : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                                                                                                 43/54
  Cleanup    : systemd-219-19.el7.x86_64                                                                                                             44/54
  Cleanup    : e2fsprogs-libs-1.42.9-7.el7.x86_64                                                                                                    45/54
  Cleanup    : libss-1.42.9-7.el7.x86_64                                                                                                             46/54
  Cleanup    : libgudev1-219-19.el7.x86_64                                                                                                           47/54
  Cleanup    : systemd-libs-219-19.el7.x86_64                                                                                                        48/54
  Cleanup    : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                   49/54
  Cleanup    : libselinux-2.2.2-6.el7.x86_64                                                                                                         50/54
  Cleanup    : pcre-8.32-15.el7.x86_64                                                                                                               51/54
  Cleanup    : libsepol-2.1.9-3.el7.x86_64                                                                                                           52/54
  Cleanup    : libcom_err-1.42.9-7.el7.x86_64                                                                                                        53/54
  Cleanup    : zlib-1.2.7-15.el7.x86_64                                                                                                              54/54
  Verifying  : zlib-devel-1.2.7-17.el7.x86_64                                                                                                         1/54
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                                                 2/54
  Verifying  : libkadm5-1.14.1-27.el7_3.x86_64                                                                                                        3/54
  Verifying  : 1:openssl-devel-1.0.1e-60.el7.x86_64                                                                                                   4/54
  Verifying  : libsepol-2.5-6.el7.x86_64                                                                                                              5/54
  Verifying  : libselinux-2.5-6.el7.x86_64                                                                                                            6/54
  Verifying  : 1:mariadb-devel-5.5.52-1.el7.x86_64                                                                                                    7/54
  Verifying  : libsepol-devel-2.5-6.el7.x86_64                                                                                                        8/54
  Verifying  : pcre-devel-8.32-15.el7_2.1.x86_64                                                                                                      9/54
  Verifying  : libselinux-devel-2.5-6.el7.x86_64                                                                                                     10/54
  Verifying  : systemd-libs-219-30.el7_3.6.x86_64                                                                                                    11/54
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                            12/54
  Verifying  : libselinux-utils-2.5-6.el7.x86_64                                                                                                     13/54
  Verifying  : 1:openssl-libs-1.0.1e-60.el7.x86_64                                                                                                   14/54
  Verifying  : libcom_err-devel-1.42.9-9.el7.x86_64                                                                                                  15/54
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                     16/54
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                                                                     17/54
  Verifying  : krb5-libs-1.14.1-27.el7_3.x86_64                                                                                                      18/54
  Verifying  : zlib-1.2.7-17.el7.x86_64                                                                                                              19/54
  Verifying  : pcre-8.32-15.el7_2.1.x86_64                                                                                                           20/54
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                           21/54
  Verifying  : systemd-219-30.el7_3.6.x86_64                                                                                                         22/54
  Verifying  : 1:openssl-1.0.1e-60.el7.x86_64                                                                                                        23/54
  Verifying  : libss-1.42.9-9.el7.x86_64                                                                                                             24/54
  Verifying  : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                     25/54
  Verifying  : 1:mariadb-5.5.52-1.el7.x86_64                                                                                                         26/54
  Verifying  : e2fsprogs-libs-1.42.9-9.el7.x86_64                                                                                                    27/54
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                    28/54
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                           29/54
  Verifying  : systemd-sysv-219-30.el7_3.6.x86_64                                                                                                    30/54
  Verifying  : libcom_err-1.42.9-9.el7.x86_64                                                                                                        31/54
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                   32/54
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                       33/54
  Verifying  : libgudev1-219-30.el7_3.6.x86_64                                                                                                       34/54
  Verifying  : krb5-devel-1.14.1-27.el7_3.x86_64                                                                                                     35/54
  Verifying  : e2fsprogs-1.42.9-9.el7.x86_64                                                                                                         36/54
  Verifying  : 1:mariadb-server-5.5.52-1.el7.x86_64                                                                                                  37/54
  Verifying  : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                   38/54
  Verifying  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                             39/54
  Verifying  : systemd-sysv-219-19.el7.x86_64                                                                                                        40/54
  Verifying  : libgudev1-219-19.el7.x86_64                                                                                                           41/54
  Verifying  : pcre-8.32-15.el7.x86_64                                                                                                               42/54
  Verifying  : zlib-1.2.7-15.el7.x86_64                                                                                                              43/54
  Verifying  : krb5-libs-1.13.2-10.el7.x86_64                                                                                                        44/54
  Verifying  : e2fsprogs-libs-1.42.9-7.el7.x86_64                                                                                                    45/54
  Verifying  : libsepol-2.1.9-3.el7.x86_64                                                                                                           46/54
  Verifying  : libcom_err-1.42.9-7.el7.x86_64                                                                                                        47/54
  Verifying  : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                                                                                                 48/54
  Verifying  : e2fsprogs-1.42.9-7.el7.x86_64                                                                                                         49/54
  Verifying  : libss-1.42.9-7.el7.x86_64                                                                                                             50/54
  Verifying  : systemd-libs-219-19.el7.x86_64                                                                                                        51/54
  Verifying  : libselinux-2.2.2-6.el7.x86_64                                                                                                         52/54
  Verifying  : systemd-219-19.el7.x86_64                                                                                                             53/54
  Verifying  : 1:openssl-1.0.1e-42.el7.9.x86_64                                                                                                      54/54

Installed:
  mariadb-devel.x86_64 1:5.5.52-1.el7                                         mariadb-server.x86_64 1:5.5.52-1.el7

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7         krb5-devel.x86_64 0:1.14.1-27.el7_3                  libcom_err-devel.x86_64 0:1.42.9-9.el7
  libkadm5.x86_64 0:1.14.1-27.el7_3                libselinux-devel.x86_64 0:2.5-6.el7                  libsepol-devel.x86_64 0:2.5-6.el7
  libverto-devel.x86_64 0:0.2.5-4.el7              mariadb.x86_64 1:5.5.52-1.el7                        openssl-devel.x86_64 1:1.0.1e-60.el7
  pcre-devel.x86_64 0:8.32-15.el7_2.1              perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7         perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBD-MySQL.x86_64 0:4.023-5.el7              perl-DBI.x86_64 0:1.627-4.el7                        perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7              perl-PlRPC.noarch 0:0.2020-14.el7                    zlib-devel.x86_64 0:1.2.7-17.el7

Updated:
  mariadb-libs.x86_64 1:5.5.52-1.el7                                            systemd.x86_64 0:219-30.el7_3.6

Dependency Updated:
  e2fsprogs.x86_64 0:1.42.9-9.el7        e2fsprogs-libs.x86_64 0:1.42.9-9.el7   krb5-libs.x86_64 0:1.14.1-27.el7_3    libcom_err.x86_64 0:1.42.9-9.el7
  libgudev1.x86_64 0:219-30.el7_3.6      libselinux.x86_64 0:2.5-6.el7          libselinux-utils.x86_64 0:2.5-6.el7   libsepol.x86_64 0:2.5-6.el7
  libss.x86_64 0:1.42.9-9.el7            openssl.x86_64 1:1.0.1e-60.el7         openssl-libs.x86_64 1:1.0.1e-60.el7   pcre.x86_64 0:8.32-15.el7_2.1
  systemd-libs.x86_64 0:219-30.el7_3.6   systemd-sysv.x86_64 0:219-30.el7_3.6   zlib.x86_64 0:1.2.7-17.el7

Complete!
[dweb@wave ~]$

Create a mysql user account for python to access.

Setup Django

Let’s create a directory to keep django data.

[dweb@wave ~]$ mkdir entra
[dweb@wave ~]$ cd entra

Create virtual environment using virtualenv command. This command will create a directory and setup all the files. After that activate the virtual environment. The ssh prompt will change as below.

[dweb@wave entra]$ virtualenv entraenv
New python executable in entraenv/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
[dweb@wave entra]$
[dweb@wave entra]$ source entraenv/bin/activate
(entraenv)[dweb@wave entra]$

Let’s install django into the virtual environment.

(entraenv)[dweb@wave entra]$ pip install mysqlclient
Downloading/unpacking mysqlclient
  Downloading mysqlclient-1.3.9.tar.gz (81kB): 81kB downloaded
  Running setup.py egg_info for package mysqlclient

    warning: no files found matching 'GPL-2.0'
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient
    building '_mysql' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,3,9,'final',1) -D__version__=1.3.9 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
    In file included from /usr/include/python2.7/pyconfig.h:6:0,
                     from /usr/include/python2.7/Python.h:8,
                     from _mysql.c:40:
    /usr/include/python2.7/pyconfig-64.h:1188:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
     #define _POSIX_C_SOURCE 200112L
     ^
    In file included from /usr/include/sys/types.h:25:0,
                     from /usr/include/mysql/mysql.h:49,
                     from _mysql.c:30:
    /usr/include/features.h:168:0: note: this is the location of the previous definition
     # define _POSIX_C_SOURCE 200809L
     ^
    In file included from /usr/include/python2.7/pyconfig.h:6:0,
                     from /usr/include/python2.7/Python.h:8,
                     from _mysql.c:40:
    /usr/include/python2.7/pyconfig-64.h:1210:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
     #define _XOPEN_SOURCE 600
     ^
    In file included from /usr/include/sys/types.h:25:0,
                     from /usr/include/mysql/mysql.h:49,
                     from _mysql.c:30:
    /usr/include/features.h:170:0: note: this is the location of the previous definition
     # define _XOPEN_SOURCE 700
     ^
    gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/usr/lib64 -lmysqlclient -lpthread -lz -lm -lssl -lcrypto -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so

    warning: no files found matching 'GPL-2.0'
Successfully installed mysqlclient
Cleaning up...
(entraenv)[dweb@wave entra]$
(entraenv)[dweb@wave entra]$ pip install django
Downloading/unpacking django
  Downloading Django-1.10.5.tar.gz (7.7MB): 7.7MB downloaded
  Running setup.py egg_info for package django

    no previously-included directories found matching 'django/contrib/admin/bin'
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
Installing collected packages: django
  Running setup.py install for django

    no previously-included directories found matching 'django/contrib/admin/bin'
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    changing mode of build/scripts-2.7/django-admin.py from 664 to 775
    changing mode of /home/dweb/entra/entraenv/bin/django-admin.py to 775
    Installing django-admin script to /home/dweb/entra/entraenv/bin
Successfully installed django
Cleaning up...
(entraenv)[dweb@wave entra]$
(entraenv)[dweb@wave entra]$ pip list
Django (1.10.5)
mysqlclient (1.3.9)
pip (1.4.1)
setuptools (0.9.8)
wsgiref (0.1.2)
(entraenv)[dweb@wave entra]$

Django framework has been installed, now you start a new project. This command will create a new directory in the working directory.

(entraenv)[dweb@wave entra]$ django-admin startproject mysite .
(entraenv)[dweb@wave entra]$ ls -ltrh
total 4.0K
drwxrwxr-x 5 dweb dweb  52 Jan 15 02:39 entraenv
-rw-rw-r-- 1 dweb dweb 804 Jan 15 02:41 manage.py
drwxrwxr-x 2 dweb dweb  70 Jan 15 02:41 mysite
(entraenv)[dweb@wave entra]$

Create a static directory to hold static data and define into the settings file.

(entraenv)[dweb@wave entra]$ mkdir static
(entraenv)[dweb@wave entra]$ ls -ltrh
total 4.0K
drwxrwxr-x 5 dweb dweb  52 Jan 15 02:39 entraenv
-rw-rw-r-- 1 dweb dweb 804 Jan 15 02:41 manage.py
drwxrwxr-x 2 dweb dweb  70 Jan 15 02:41 mysite
drwxrwxr-x 2 dweb dweb   6 Jan 15 02:45 static
(entraenv)[dweb@wave entra]$

(entraenv)[dweb@wave entra]$ tail mysite/settings.py

STATIC_ROOT = os.path.join(BASE_DIR, "static/")
(entraenv)[dweb@wave entra]$

By default, the application will run on the localhost. If you need to access on remote server, then the IP address needs to be added to ‘ALLOWED_HOSTS’ section in the settings file.

Currently, django back-end is sqlite. Now, changing django backend to MySQL.

 cat mysite/settings.py

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.sqlite3',
#        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#    }
#}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'djcms',
        'USER': 'udjcms',
        'PASSWORD': 'pdjcms',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

After that check and migrate metadata to MySQL and start the server.

(entraenv)[dweb@wave entra]$ python manage.py check
System check identified no issues (0 silenced).
(entraenv)[dweb@wave entra]$
(entraenv)[dweb@wave entra]$ python manage.py migrate
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
        HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/1.10/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying sessions.0001_initial... OK
(entraenv)[dweb@wave entra]$
(entraenv)[dweb@wave entra]$ python manage.py createsuperuser
Username (leave blank to use 'dweb'): admin
Email address: abc@123.com
Password:
Password (again):
Superuser created successfully.
(entraenv)[dweb@wave entra]$
(entraenv)[dweb@wave entra]$ python manage.py runserver 192.168.56.112:8000
Performing system checks...

System check identified no issues (0 silenced).
January 15, 2017 - 07:57:09
Django version 1.10.5, using settings 'mysite.settings'
Starting development server at http://192.168.56.112:8000/
Quit the server with CONTROL-C.
[15/Jan/2017 07:57:23] "GET / HTTP/1.1" 200 1767
Not Found: /favicon.ico
[15/Jan/2017 07:57:23] "GET /favicon.ico HTTP/1.1" 404 1941
[15/Jan/2017 07:57:28] "GET /admin HTTP/1.1" 301 0
[15/Jan/2017 07:57:28] "GET /admin/ HTTP/1.1" 302 0
[15/Jan/2017 07:57:28] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1653
[15/Jan/2017 07:57:28] "GET /static/admin/css/base.css HTTP/1.1" 200 15937
[15/Jan/2017 07:57:28] "GET /static/admin/css/login.css HTTP/1.1" 200 1203
[15/Jan/2017 07:57:28] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[15/Jan/2017 07:57:28] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 80304
[15/Jan/2017 07:57:28] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 81348
[15/Jan/2017 07:57:36] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
[15/Jan/2017 07:57:36] "GET /admin/ HTTP/1.1" 200 2779
[15/Jan/2017 07:57:36] "GET /static/admin/css/dashboard.css HTTP/1.1" 200 434
[15/Jan/2017 07:57:36] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 82564
[15/Jan/2017 07:57:36] "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 200 331
[15/Jan/2017 07:57:36] "GET /static/admin/img/icon-changelink.svg HTTP/1.1" 200 380

djangodmsPress ‘Clt + C’ to quit the application and ‘deactivate’ command to leave the virtual environment.

(entraenv)[dweb@wave entra]$ deactivate

Configure Django with Apache.

Let’s install apache and mod_wsgi.

(entraenv)[dweb@wave entra]$ sudo yum install httpd mod_wsgi
[sudo] password for dweb:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fibergrid.in
 * epel: epel.mirror.net.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-45.el7.centos for package: httpd-2.4.6-45.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-45.el7.centos.x86_64
---> Package mod_wsgi.x86_64 0:3.4-12.el7_0 will be installed
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved
===========================================================================================================================================================
 Package                               Arch                             Version                                       Repository                      Size
===========================================================================================================================================================
Installing:
 httpd                                 x86_64                           2.4.6-45.el7.centos                           base                           2.7 M
 mod_wsgi                              x86_64                           3.4-12.el7_0                                  base                            76 k
Installing for dependencies:
 httpd-tools                           x86_64                           2.4.6-45.el7.centos                           base                            84 k
 mailcap                               noarch                           2.1.41-2.el7                                  base                            31 k

Transaction Summary
===========================================================================================================================================================
Install  2 Packages (+2 Dependent packages)

Total download size: 2.9 M
Installed size: 9.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): httpd-tools-2.4.6-45.el7.centos.x86_64.rpm                                                                                   |  84 kB  00:00:00
(2/4): httpd-2.4.6-45.el7.centos.x86_64.rpm                                                                                         | 2.7 MB  00:00:00
(3/4): mod_wsgi-3.4-12.el7_0.x86_64.rpm                                                                                             |  76 kB  00:00:00
(4/4): mailcap-2.1.41-2.el7.noarch.rpm                                                                                              |  31 kB  00:00:01
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      2.2 MB/s | 2.9 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                             1/4
  Installing : httpd-tools-2.4.6-45.el7.centos.x86_64                                                                                                  2/4
  Installing : httpd-2.4.6-45.el7.centos.x86_64                                                                                                        3/4
  Installing : mod_wsgi-3.4-12.el7_0.x86_64                                                                                                            4/4
  Verifying  : httpd-tools-2.4.6-45.el7.centos.x86_64                                                                                                  1/4
  Verifying  : mod_wsgi-3.4-12.el7_0.x86_64                                                                                                            2/4
  Verifying  : httpd-2.4.6-45.el7.centos.x86_64                                                                                                        3/4
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                             4/4

Installed:
  httpd.x86_64 0:2.4.6-45.el7.centos                                             mod_wsgi.x86_64 0:3.4-12.el7_0

Dependency Installed:
  httpd-tools.x86_64 0:2.4.6-45.el7.centos                                          mailcap.noarch 0:2.1.41-2.el7

Complete!
(entraenv)[dweb@wave entra]$

All the clients requests are translated to WSGI format which is by default used with Django with “mod_wsgi”. You have to create a new configuration file in order to define WSGI process.

sudo vim /etc/httpd/conf.d/django.conf

Alias /static /home/dweb/entra/static/
<Directory /home/dweb/entra/static>
 Require all granted
</Directory>
<Directory /home/dweb/entra/mysite>
<Files wsgi.py>
 Require all granted
</Files>
</Directory>

It is recommended to use the daemon mode to run the WSGI process. The “WSGIDaemonProcess” will be used for that. You have to specify the name for the process because an arbitrary one will be used. Two paths will be used. One for our project and other, “lib/pythonx.x/site-packages”. In order to find all the needed Python code but Apache to run our project.Conf

Alias /static /home/dweb/entra/static/
<Directory /home/dweb/entra/static>
 Require all granted
</Directory>
<Directory /home/dweb/entra/mysite>
<Files wsgi.py>
 Require all granted
</Files>
</Directory>

WSGIDaemonProcess mysite python-path=/home/dweb/entra:/home/dweb/entra/entraenv/lib64/python2.7/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /home/dweb/entra/mysite/wsgi.py

Permission Fix:

We will need the “apache” user in our user’s group in order have access to all django files. You can make this by using:

(entraenv)[dweb@wave entra]$ sudo usermod -a -G dweb apache
(entraenv)[dweb@wave entra]$ tail /etc/group
krishna:x:1000:
dweb:x:1001:apache
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
mysql:x:27:
apache:x:48:
(entraenv)[dweb@wave entra]$

Finally, the Apache group have to get the ownership of the parent directory using.

(entraenv)[dweb@wave entra]$ sudo chown :apache ~/entra
(entraenv)[dweb@wave entra]$ ls -ltrh ../
total 0
drwxrwxr-x 5 dweb apache 63 Jan 15 02:45 entra
(entraenv)[dweb@wave entra]$

Now, we can give our user group execute permissions on our home directory. This will allow the Apache process to enter and access content. After that start the apache services.

(entraenv)[dweb@wave entra]$ chmod 710 /home/dweb
(entraenv)[dweb@wave entra]$ sudo systemctl start httpd

Collect, django static file using the below command and restart apache server.

(entraenv)[dweb@wave entra]$ python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    /home/dweb/entra/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/base.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/changelists.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/dashboard.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/fonts.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/forms.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/login.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/rtl.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/widgets.css'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/fonts/LICENSE.txt'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/fonts/README.txt'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/fonts/Roboto-Bold-webfont.woff'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/fonts/Roboto-Light-webfont.woff'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/fonts/Roboto-Regular-webfont.woff'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/LICENSE'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/README.txt'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/calendar-icons.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-addlink.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-alert.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-calendar.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-changelink.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-clock.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-deletelink.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-no.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-unknown-alt.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-unknown.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/icon-yes.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/inline-delete.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/search.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/selector-icons.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/sorting-icons.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/tooltag-add.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/tooltag-arrowright.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/gis/move_vertex_off.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/img/gis/move_vertex_on.svg'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/SelectBox.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/SelectFilter2.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/actions.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/actions.min.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/calendar.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/cancel.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/change_form.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/collapse.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/collapse.min.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/core.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/inlines.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/inlines.min.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/jquery.init.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/popup_response.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/prepopulate.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/prepopulate.min.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/prepopulate_init.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/timeparse.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/urlify.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/LICENSE-JQUERY.txt'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.min.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/xregexp/LICENSE-XREGEXP.txt'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js'
Copying '/home/dweb/entra/entraenv/lib/python2.7/site-packages/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.min.js'

61 static files copied to '/home/dweb/entra/static'.
(entraenv)[dweb@wave entra]$

Successfully configured Django with Apache.

djangocms1

I really like django. Hope, you will like too. It’s very nice and versatile.

Leave a Reply

Your email address will not be published. Required fields are marked *