Python+apache+django Configuration

Source: Internet
Author: User
Tags install django

Python+apache+django Configuration

Python2.7 https://www.python.org/downloads/release/python-2710/

Apache2.2: HTTP://WWW.APACHEHAUS.COM/CGI-BIN/DOWNLOAD.PLX

Django1.8 https://www.djangoproject.com/download/

Mod-wsgi: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

Mysql: https://www.baidu.com/s?wd=mysql%E4%B8%8B%E8%BD%BD&rsv_spt=1&rsv_iqid=0xa549e540000101cd&issp= 1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=0&oq=django%20%e4%b8% 8b%e8%bd%bd&rsv_t=9d17e6iwaiauit9l%2fobezeyqa0cl6aexnzjx6svkvoyq13ynpgafwcr7ms8yzwpgfbgx&rsv_pq= 88b5acbb0002c328&inputt=11278&rsv_sug3=150&rsv_sug1=108&sug=mysql%e4%b8%8b%e8%bd%bd&rsv_n= 1&BS=DJANGO%20%E4%B8%8B%E8%BD%BD

MySQLdb: http://sourceforge.net/projects/mysql-python/files/

1 , first download and install Python and Apache modules,

Apache downloads msi format. installation See http://jingyan.baidu.com/article/ed15cb1b73b3071be269816d.html

2 , set up Python environment variables, debug the installation is normal, http://jingyan.baidu.com/article/48206aeafdcf2a216ad6b316.html

Computer--right--properties in the left column find "Advanced system settings" click on "Environment variables" in the system variable, find path, double-click, then the end of the string, plus a semicolon;

Then enter your path to install Python, OK, OK, until the setup is complete, open the command line, enter Python, the following prompt is the configuration success

3 , install Django

after Django is downloaded as a compressed package, unzip with Python in the same root directory, enter into the Django directory under DOS, execute the python setup.py install, and then start the installation, Django will be installed into Python's lib under Site-packages.

4 , add Django environment variables, method with 2

For example: C:/python33/lib/site-packages/django; C:/python33/scripts

5 , installation Mod_wsgi ,

When selecting this file version, please see the number of operating systems in your machine, as well as the Python version and the Apache version.

Rename mod_wsgi-win32-ap22py27-3.3.so to Mod_wsgi and put it under Apache modules.

6 , modify apached:\apache22\conf\httpd.conf Add Mod_wsgi

Add Location # Example:

# LoadModule Foo_module modules/mod_foo.so

#

LoadModule Wsgi_module modules/mod_wsgi.so

LoadModule Actions_module modules/mod_actions.so

LoadModule Alias_module modules/mod_alias.so

LoadModule Asis_module modules/mod_asis.so

LoadModule Auth_basic_module modules/mod_auth_basic.so

#LoadModule Auth_digest_module modules/mod_auth_digest.so

#LoadModule Authn_alias_module modules/mod_authn_alias.so

#LoadModule Authn_anon_module modules/mod_authn_anon.so

#LoadModule Authn_dbd_module modules/mod_authn_dbd.so

#LoadModule Authn_dbm_module modules/mod_authn_dbm.so

LoadModule Authn_default_module modules/mod_authn_default.so

7 enter Apache \ bin DOS window Run Httpd.exe commands to view There is no error,

Here's the next step, or check to see if the Mod-wsgi version is correct,

error here, Most of the version is not correct, please reconfirm version selection

8 , modify apached:\apache22\conf\httpd.conf add at the end

The following statement, the file location changes itself

############# #tEST #######################

#指定myweb项目的wsgi. py configuration file path

wsgiscriptalias/e:/wwwpython/project/project/wsgi.py

#指定项目路径

Wsgipythonpath E:/wwwpython/project

#此处注意文件路径

<directory e:/wwwpython/project/project>

AllowOverride None

<files wsgi.py>

#Require all granted

Options FollowSymLinks

Order Deny,allow

Allow from all

</Files>

</Directory>

Alias/static d:/software/python27/lib/site-packages/django-1.8.4-py2.7.egg/django/contrib/admin/static/

#################################################

9 Modify seeting.py in a project file

allowed_hosts = [' 127.0.0.1 ', ' localhost '],

Debug to Run,

Ten , Write a View test:

The file directory is as follows:

Ten recommended use of Pycharm The compiler can save seeting.py and other modifications,

http://www.jetbrains.com/pycharm/

One , search download MySQL, use MSI as much as possible format files for easy installation, no configuration,

A , download MySQLdb , in Python command line, type import MySQL Debug is installed correctly,

the , modify seting.py the configuration section of the database in the file

DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' Project ', #数据库名称

' USER ': ' Root ', #用户名
' PASSWORD ': ' 1234 ', #密码
' HOST ': ' 127.0.0.1 ', #
' PORT ': ' 3306 ', #端口号
}
}

Python+apache+django Configuration

Related Article

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.