Code Monkey home page Code Monkey logo

blog_auth's Introduction

Server2008 R2 sp1
IIS7.0 
pip install Django
pip install wfastcgi
pip install mysqlclient pymysql

1.  IIS,“添加角色服务”-》 勾选“应用程序开发(已安装)”下“CGI"
2.  将lib/site-packages/wfastcgi.py 复制至 项目根目录文件夹下,如./mysite/下
3.  将项目文件夹整个复制至“c\inetpub\wwwroot\"下
4.  添加网站,设置内容物理路径,端口等,对开发端口,设置防火墙。
5.  “处理程序映射”-> “添加模块映射”,
     请求路径: *
     模块:FastCgiModule
     可执行文件:python.exe路径| 项目下wfastcgi.py文件路径
     名称:DjangoWebHandler
6.   返回主页,进入FastCGI设置 
     环境变量-》集合,添加:
     1)get_wsgi_application()方法的位置,C:\Anaconda3\Lib\site-packages\django\core\wsgi.py
        Name: WSGI_HANDLER
        Value: django.core.wsgi.get_wsgi_application()
     2)Django项目目录
        Name: PYTHONPATH
        Value: C:\inetpub\wwwroot\PowerX
     3)项目settings.py文件的位置
        Name: DJANGO_SETTINGS_MODULE
        Value: 
5.    设置静态文件
      setting.py 添加  STATIC_ROOT = 'static/'
      python manage.py collectstatic
      网站“虚拟目录static”,设置静态文件夹别名和物理路径,
      选中“虚拟目录static”,双击“处理程序映射”,删除DjangoWebHandler,只保留StaticFile映射。 (关键步骤,admin css正常访问)
6.   setting.py
     DEBUG=Fasle
     ALLOWED_HOSTS = ['*']
7.   设置网站文件夹IIS用户访问权限。
8.   启动网站

------------------------------
MSSQL:
1、安装django-pyodbc-azure和pyodbc

pip install django-pyodbc-azure pyodbc
2、修改settings.py的DATABASES:

复制代码
DATABASES = {
    'default': {
         'ENGINE': 'sql_server.pyodbc',
         'NAME': 'MyDB',
         'USER': 'user',
         'PASSWORD': 'password',
         'HOST': '127.0.0.1',
         'PORT': '',
          'OPTIONS': {
              'driver':'SQL Server Native Client 11.0',
              'MARS_Connection': True,

         },
     },
}

# set this to False if you want to turn off pyodbc's connection pooling
DATABASE_CONNECTION_POOLING = False
---------------------------------

Sqlite3 数据库向MySQL迁移
pip install mysqlclient

1.在MYSQL建立空的数据库,mysite,  CREATE DATABASE mysite CHARACTER SET utf8 COLLATE utf8_general_ci; 
2.先建立一个SLAVE数据库
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": "dev.db",        
    },
    "slave": {
        "ENGINE": "django.db.backends.mysql",
        "NAME": "mysite",
        "USER": "root",
        "PASSWORD": "",
        "HOST": "",
        "PORT": "",
    },
}

3.python manage.py makemigrations & migrate
4.将SQLITE主库的数据导出   python manage.py dumpdata > mysite_all_data.json
5.切换主库和从库的setting.py设置,将MYSQL设置为主库,导入数据。
python manage.py loaddata mysite_all_data.json


===========================
setting.py

DEBUG = False
ALLOWED_HOSTS = ['202.192.XXX.XXX'] #服务器本机ip

LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_TZ = False

STATIC_URL = '/static/'
STATIC_ROOT = 'static/'

# LOGIN_URL = '/blog/login/'
LOGIN_URL = '/admin/login/'
LOGIN_REDIRECT_URL = '/blog/list/'

SESSION_COOKIE_AGE = 60 * 30  # 30分钟
# SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True  # 关闭浏览器,则COOKIE失效

blog_auth's People

Contributors

yanjl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.