Chinaunix首页 | 论坛 | 博客
  • 博客访问: 184895
  • 博文数量: 26
  • 博客积分: 215
  • 博客等级: 入伍新兵
  • 技术积分: 346
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-21 15:00
文章分类

全部博文(26)

文章存档

2017年(10)

2016年(1)

2015年(2)

2014年(1)

2013年(7)

2012年(5)

我的朋友

分类: 系统运维

2017-11-06 17:51:51

1、安装wget,gcc-c++ gcc*
# yum install -y wget gcc-c++ epel-release

2、升级安装python2.7和pip
http://blog.csdn.net/zack1989/article/details/53549913

3、解决yum冲突问题
http://www.cnblogs.com/liwei0526vip/p/6219998.html?utm_source=itdadao&utm_medium=referral

4、python2.7使用python2.6的site-packages
# mkdir /usr/local/python/2.7.12/site-packages
# ln -s /usr/lib64/python2.6/site-packages/* /usr/local/python/2.7.12/site-packages/

5、安装mysql-python
# yum install -y  python-devel
# pip install PyMySQL
6、安装配置mysql
# yum install mysql-devel mysql mysql-server python-devel
# chkconfig mysqld on
# service mysqld start
# /usr/bin/mysqladmin -u root password 'passw0rd'

mysql创建schema
CREATE SCHEMA `Moniter` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
# 这样创建的表不会出现admin中表更新中文内容的时候乱码

7、安装配置nginx    
yum install nginx
配置nginx.conf

点击(此处)折叠或打开

  1. http{
  2.     include/etc/nginx/mime.types;
  3.     default_type application/octet-stream;
  4.   
  5.     log_format main'$remote_addr - $remote_user [$time_local] "$request" '
  6.                       '$status $body_bytes_sent "$http_referer" '
  7.                       '"$http_user_agent" "$http_x_forwarded_for"';
  8.   
  9.     access_log/var/log/nginx/access.log main;
  10.   
  11.     sendfile on;
  12.     #tcp_nopush on;
  13.   
  14.     #keepalive_timeout 0;
  15.     keepalive_timeout 65;
  16.   
  17.     #gzip on;
  18.   
  19.     # Load config filesfromthe/etc/nginx/conf.d directory
  20.     # The default serverisinconf.d/default.conf
  21.     include/etc/nginx/conf.d/*.conf;
  22. #-----------------------------------------------------
  23.     client_max_body_size 1024m;
  24.     server{
  25.         listen 80;
  26.         server_name 192.168.1.35;
  27.         location/{
  28.             uwsgi_pass 127.0.0.1:9000;
  29.             include uwsgi_params;
  30.             uwsgi_param UWSGI_CHDIR/data/www/moniter;
  31.             uwsgi_param UWSGI_SCRIPT django_wsgi;
  32.             access_log off;
  33.         }
  34.         location^~/static{
  35.             root/data/www/xtyw/;
  36.         }
  37.         location~*^.+\.(png|mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|docx|xls|exe|ppt|t|tar|mid|midi|wav|rtf|,peg)${
  38.             root/data/medias;
  39.             access_log off;
  40.         }
  41.     }
  42.     events{
  43.          use epoll;
  44.          worker_connections 1024;## Default: 1024
  45.     }

8、安装 uwsgi 和django
# pip install uwsgi
# pip install django

在创建django项目时报错,后查证为django的新版本不支持python2.6.6,需要升级
1)测试uwsgi
# pip install uwsgi
# uwsgi --version

测试uwsgi是否正常:
新建test.py文件,内容如下:
def application(env, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return "Hello World"

然后在终端运行:
# uwsgi --http :8001 --wsgi-file test.py
在浏览器内输入:,看是否有“Hello World”输出,若没有输出,请检查你的安装过程。

2)测试django
# cd moniter
# vim moniter/__init__.py
import pymysql
pymysql.install_as_MySQLdb()

# vim moniter/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'Moniter',
        'USER': 'root',
        'PASSWORD': 'passw0rd',
        'HOST': '127.0.0.1',
        'PORT': 3306,
    }
}
# python manage.py runserver 8001
Performing system checks...

System check identified no issues (0 silenced).

You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

October 31, 2017 - 07:02:43
Django version 1.11.6, using settings 'moniter.settings'
Starting development server at /
Quit the server with CONTROL-C.
说明:django项目(moniter)正常跑起来了

阅读(1706) | 评论(0) | 转发(0) |
0

上一篇:zabbix性能调优(未完待续)

下一篇:没有了

给主人留下些什么吧!~~