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
-
http{
-
include/etc/nginx/mime.types;
-
default_type application/octet-stream;
-
-
log_format main'$remote_addr - $remote_user [$time_local] "$request" '
-
'$status $body_bytes_sent "$http_referer" '
-
'"$http_user_agent" "$http_x_forwarded_for"';
-
-
access_log/var/log/nginx/access.log main;
-
-
sendfile on;
-
#tcp_nopush on;
-
-
#keepalive_timeout 0;
-
keepalive_timeout 65;
-
-
#gzip on;
-
-
# Load config filesfromthe/etc/nginx/conf.d directory
-
# The default serverisinconf.d/default.conf
-
include/etc/nginx/conf.d/*.conf;
-
#-----------------------------------------------------
-
client_max_body_size 1024m;
-
server{
-
listen 80;
-
server_name 192.168.1.35;
-
location/{
-
uwsgi_pass 127.0.0.1:9000;
-
include uwsgi_params;
-
uwsgi_param UWSGI_CHDIR/data/www/moniter;
-
uwsgi_param UWSGI_SCRIPT django_wsgi;
-
access_log off;
-
}
-
location^~/static{
-
root/data/www/xtyw/;
-
}
-
location~*^.+\.(png|mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|docx|xls|exe|ppt|t|tar|mid|midi|wav|rtf|,peg)${
-
root/data/medias;
-
access_log off;
-
}
-
}
-
events{
-
use epoll;
-
worker_connections 1024;## Default: 1024
-
}
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) |