Centos7 + Apache2.4 + python3.5 +mod_wsgi4.5.15 + Django1.10 Installation Instructions

Source: Internet
Author: User
Tags sqlite sqlite database install django

This article directs the installation of Python3.5, mod_wsgi4.5.15, Django1.10, as well as the problems and solutions that may arise during installation.

The operating system is not limited to CentOS, and most Linux operating systems are available. Other versions of the operating system problems with the solution of the idea and method is basically the same ... Begin...

1. Installing Apache2.4

In the case of the CENTOS7 version, the Apache installed by default is version 2.4, and it is recommended to install the latest version. Because we are going to install MOD_WSGI later, it relies on Apache's development library and Python's development library, so we have to install the Apache Development Library incidentally.

The command is as follows:

Yum-y Install httpd Httpd-devel

2. Compile and install Python3.5.

The default Python version for most Linux distributions is 2.X, using the latest 3. x version of the need to install their own means, where the use of compiling source code to install, source packages can be downloaded on the Python website itself.

The relevant commands are as follows:

TAR-ZXF mod_wsgi-4.5.15.tar.gz #解压python源码包

CD python-3.5.3/

./configure--prefix=/usr/local/python35--enable-shared--enable-loadable-sqlite-extensions #配置选项, It is recommended to use--prefix to specify the installation directory, easy to delete when not used,--enable-shared enable shared library, Mod_wsgi need Python Development library support, Django default to use SQLite database, need to use this database of the development library

Make

make install #编译并安装, the corresponding version of PIP3 will be installed by default after installation, if prompted after compiling "ignoring ENSUREPIP Failure:pip 9.0.1 requires SSL/TLS ", you cannot install PIP3 because of a lack of dependencies, you can use the following command to install dependencies after you recompile the installation: yum install Zlib-devel bzip2-devel Openssl-devel Ncurese-devel

After the installation of the Python3 Development Library in the/usr/local/python35/lib directory, the system cannot be found, enable the Python35 Development Library can configure the system library load directory, the command is as follows:

echo "/usr/local/python35/lib" >>/etc/ld.so.conf.d/python35.conf

Ldconfig


3. Compile and install mod_wsgi4.5.15.

WSGI supports apache2.0, 2.2, 2.4, Apache must have a development library installed, and the Apache Development library name in the common release version of the software library is similar to the following: Httpd-devel. A Python development library is also required, with the development library's name similar to the version of the Release Software library: Python-devel. Use--enable-shared and configure the system library to load the directory using the source code, refer to the above 2. Compile and install Python3.5.

if Apache is installed as source code, APXS is not in the system executable path and needs to be used --with-apxs Specifies the execution directory of the APXS, Python uses the source code installation, the Python executable is not in the system executable path, needs to use--with-python to specify the python executable file path. In this example, the Install Configuration compilation installation command is as follows:


./configure--with-python=/usr/local/python35/bin/python3.5 # #一定要是python3.5, cannot be python3, see below for reasons.

Make # #如果上面使用--with-python The specified python executable is /usr/local/python35/bin/python3, this step will error:src/server/ws Gi_python.h:24:20:fatal error:python.h:no such file or directory

Make install


4. Install Django1.10 and create engineering and applications

cd/usr/local/python35/bin/

./pip3.5 Install the Django #./pip3.5 install django==1.8 can be installed 1.8 Django, if there is no pip3.5 after the installation of Python, because the compile time does not install the phase Please install 2 for the dependent package. Compile the installation of the python3.5 step after installing the dependent package and recompile the install.


After installation, you can verify that the installation was successful by using the following command:

python3-m Django--version # #如果输出版本, stating that the installation was successful, or that no installation was successful.


Please refer to the respective website for the use of each part.

Django-admin startproject MySite # #新建工程mysite

Django-admin Startapp mysite                              ## #如果django命令不存在, use the command absolute path /usr/local/python35/bin/ Added to the system path variable.

# # #如果执行此命令报错: django.core.exceptions.ImproperlyConfigured:Error Loading either PYSQLITE2 or Sqlite3 modules (tried in that Ord ER): No module named ' _sqlite3 ', install the Sqlite-devel package (yum install sqlite-devel), and then recompile the installation python3.5

path= $PATH: /usr/local/python35/bin/


5. Configure Apache Support WSGI

Vim/etc/httpd/conf.d/wsgi.conf

LoadModule Wsgi_module modules/mod_wsgi.so # #主配置文件中加载mod_wsgi模块

<virtualhost *:80> # #配置虚拟主机

ServerName skyofus.cn

DocumentRoot "/weixin"

DirectoryIndex index.html index.py

wsgiscriptalias/weixin//weixin/cgi-bin/weixin/weixin/wsgi.py # #指定url对应的wsgi文件

<directory "/weixin" >

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

</VirtualHost>


This article is from the "can't remember the former Cup of Wine" blog, please be sure to keep this source http://9429042.blog.51cto.com/9419042/1913978

Centos7 + Apache2.4 + python3.5 +mod_wsgi4.5.15 + Django1.10 Installation Instructions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.