您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 招聘面试 > django+cloudshop部署
安装相关开发包yuminstallgccgcc-c++zlib-develbzip2-develpcre-developenssl-develncurses-develsqlite-develreadline-develtk-devellibjpeg-turbo-develmemcachedlibmemcached-devel安装python-2.7.9python-2.7.9wget=/opt/python2.7--enable-shared--enable-unicode=ucs4makemakeinstall输出python2.7的头文件至系统头文件路径/usr/include:#ln-sv/opt/python2.7/include/usr/include/python2.7输出python2.7的库文件给系统库查找路径:#echo'/opt/python2.7/lib'/etc/ld.so.conf.d/python2.7.conf而后让系统重新载入系统库:#ldconfig修改PATH环境变量,让系统可以直接使用python2.7的相关命令编辑:/etc/profile.d/python2.7.shexportPATH=/opt/python2.7/bin:$PATH执行:source/etc/profile.d/python2.7.sh安装python安装工具setuptools-18.1.tar.gzwget=f72e87f34fbf07f299f6cb46256a0b06tarxfsetuptools-18.1.tar.gzcdsetuptools-18.1python2.7setup.pybuildpython2.7setup.pyinstall安装python仓库pip-7.1.0.tar.gzwget=d935ee9146074b1d3f26c5f0acfd120etarxfpip-7.1.0.tar.gzcdpip-7.1.0python2.7setup.pybuildpython2.7setup.pyinstall安装python的mysql驱动wget=654f75b302db6ed8dc5a898c625e030cunzipMySQL-python-1.2.5.zipcdMySQL-python-1.2.5python2.7setup.pybuildpython2.7setup.pyinstall安装uwsgipipinstalluwsgi编辑uwsgi配置文件/etc/uwsgi.ini[uwsgi]socket=127.0.0.1:9090master=truevhost=trueno-stie=trueworkers=2reload-mercy=10vacuum=truemax-requests=1000limit-as=512buffer-sizi=30000pidfile=/var/run/uwsgi.piddaemonize=/var/log/uwsgi.logchdir=/cloudshop//django项目路径module=cloudshop.wsgi//wsgi.py所在路径.表示上级目录uwsgi启动脚本/usr/local/python2.7/bin/startup.sh#!/bin/bash#/usr/local/python2.7/bin/uwsgi--ini/etc/uwsgi.ini--http-auto-chunked//--http-auto-chunked解决图片上传编码问题Uwsgi停止脚本/usr/local/python2.7/bin/shutdown.sh#!/bin/bash#PS_LIST=`/usr/bin/ps-ef|/usr/bin/grep'uwsgi'|/usr/bin/grep-v'grep'|/usr/bin/awk'{print$2}'`forIin$PS_LISTdo/usr/bin/kill-9$I&/dev/nulldone/usr/bin/echoStopuwsgiservice----------------------------------------------------------设置执行权限chmod+x/usr/local/python2.7/bin/startup.shchmod+x/usr/local/python2.7/bin/shutdown.sh安装djangopipinstalldjango安装django相关包pipinstalldjango_messagespipinstalldjango_datatables_view测试django运行cloudshop是否正常uwsgi–http:8000–chdir/cloudshop–modulecloushop.wsgi项目目录“.”表示上级目录/cloudshop/cloudshop/wsgi安装nginxwget根据系统的平台架构下载rpm-ivhnginx-release-rhel-6-0.el6.ngx.noarch.rpmchkconfignginxonyuminstallnginx修改nginx配置文件/etc/nginx/conf.d/default.confserver{listen80;server_namelocalhost;indexindex.htmlindex.htm;location/{includeuwsgi_params;uwsgi_pass127.0.0.1:9090;//如果是动态则转到后端的uwsgiuwsgi_paramUWSGI_SCRIPTcloudshop.wsgi;uwsgi_paramUWSGI_CHDIR/cloudshop;client_max_body_size35m;}location/static/{alias/cloudshop/public/static/;}location/static/admin/{alias/usr/local/python2.7/lib/python2.7/site-packages/django/contrib/admin/static/admin/;}启动nginxservicenginxstart在mysql中创建数据库cloudshop导入数据#mysql-uroot-p123456cloudshopcloudshop.sql安装cloudshop把cloudshop解压到根目录下修改/cloudshop/cloudshop/settings.pyDATABASES={'default':{'ENGINE':'django.db.backends.mysql','NAME':'cloudshop',//数据库名'USER':'root',//数据库用户名,根据实际情况'PASSWORD':'123456',//数据库用户密码,根据实际情况'HOST':'localhost',//数据库所在主机'PORT':'3306',//数据库端口,一般mysql为3306}}pipinstallmigrate数据库models同步插件pipinstalldjango_messagespipinstalldjango_datatables_viewpipinstalltablibpipinstalldjango-stored-messagespipinstallPillow图片处理插件pipinstallmysql-pythonmysql驱动pipinstallxlsxwriterexcel导出用插件pipinstallrsarsa密钥插件访问试试说明部署成功Memcached在python上使用安装python-memcachedyuminstalllibmemcachedpipinstallpython-memcached安装pylibmcPipinstallpylibmc==1.2.3。安装redispython驱动Pipinstallredis
本文标题:django+cloudshop部署
链接地址:https://www.777doc.com/doc-4225280 .html