CentOS6+nginx+uwsgi+mysql+django1.6.6+python2.6.6
1.配置网关
#vi /etc/sysconfig/network
NETWORKING=yes(表示系统是否使用网络,一般设置为yes。如果设为no,则不能使用网络,而且很多系统服务程序将无法启动)
HOSTNAME=centos(设置本机的主机名,这里设置的主机名要和/etc/hosts中设置的主机名对应)
GATEWAY=192.168.1.1(设置本机连接的网关的IP地址。例如,网关为10.0.0.2)
2.配置DNS
#vi /etc/resolv.conf
nameserver: 114.114.114.114 # IBM哥们讲的国内比较快的一个DNS
3.CentOS 修改IP地址
修改对应网卡的IP地址的配置文件
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
修改以下内容
DEVICE=eth0 #描述网卡对应的设备别名,例如ifcfg-eth0的文件中它为eth0
BOOTPROTO=static #设置网卡获得ip地址的方式,可能的选项为static,dhcp或bootp,分别对应静态指定的 ip地址,通过dhcp协议获得的ip地址,通过bootp协议获得的ip地址
BROADCAST=192.168.0.255 #对应的子网广播地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
IPADDR=12.168.1.2 #如果设置网卡获得 ip地址的方式为静态指定,此字段就指定了网卡对应的ip地址
IPV6INIT=no
IPV6_AUTOCONF=no
NETMASK=255.255.255.0 #网卡对应的网络掩码
NETWORK=192.168.1.0 #网卡对应的网络地址
ONBOOT=yes #系统启动时是否设置此网络接口,设置为yes时,系统启动时激活此设备
4.重新启动网络配置
# service network restart
或
# /etc/init.d/network restart
5.配置epal源(别的源没有的它也有,比如saltstack)
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm# 下载
chmod +x epel-release-6-8.noarch.rpm# 权限
rpm -ivh epel-release-6-8.noarch.rpm# 安装
yum update
6.安装pip
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
wget https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py# 没有install
https://bootstrap.pypa.io/get-pip.py
变成这个了,2016年04月11日22:08:44更新
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
2016年06月12日11:32:45 更新
7.pip安装django
pip install django==1.6.6
8.pip安装mysqldb
yum install mysql-devel mysql mysql-server python-devel
pip install MySQL-python
9.修改mysql的root密码
mysql -uroot
use mysql;#有的版本默认管理数据库不是这个名字(*注意)
MySQL> update user set password=PASSWORD('newpassword') where User='root';
MySQL> flush privileges; //刷新权限,重启mysql也可以
MySQL> quit
或者:
/usr/bin/mysqladmin -u root password 'passw0rd'
10.mysql创建schema
CREATE SCHEMA `xtyw` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
# 这样创建的表不会出现admin中表更新中文内容的时候乱码
11.安装nginx
yum -y install nginx
12.配置nginx
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 files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
#-----------------------------------------------------
client_max_body_size 1024m;
server {
listen 80;
server_name 192.168.46.5;
location / {
uwsgi_pass 127.0.0.1:9000;
include uwsgi_params;
uwsgi_param UWSGI_CHDIR /data/www/helloworld;
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;
}
}
#---------------------------------以下是我添加的内容
then
/etc/init.d/nginx start
13.安装uwsgi
pip install uwsgi
14.开始用uwsgi部署django应用到nginx上
进入项目主目录,即settings.py所在目录,创建uwsgi.ini配置文件
内容如下
[uwsgi]
socket = 0.0.0.0:9000
master = true
pidfile = /etc/nginx/uwsgi.pid
processes = 4
chdir = /data/www/xtyw/
wsgi-file = /data/www/xtyw/xtyw/wsgi.py
profiler = true
memory-report = true
enable-threads = true
logdate = true
limit-as = 6048
daemnize = /data/logs/django.log
执行:
#uwsgi uwsgi.ini
如果是xml文件
#uwsgi -x uwsgi.xml
15.最后附上自动django源码自动重载方法
1.安装工具
yum -y install inotify-tools
2.编写一个监视脚本autoreload.sh
#!/bin/sh objectdir="/data/www/xtyw"
# 启动inotify监视项目目录, 参数"--exclude" 为忽略的文件或目录正则
/usr/bin/inotifywait -mrq --exclude "(static|logs|shell|\.swap|\.pyc|\.swx|\.py\~)" --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' --event modify,delete,move,create,attrib ${objectdir} | while read files
do
/bin/touch /data/www/xtyw/shell/reload.set
continue
done &
3.编写监视文件reload.set(内容即是uwsgi启动脚本)
#!/bin/bash
if [ ! -n "$1" ]
then
echo "Usages: sh uwsgiserver.sh [start|stop|restart]"
exit 0
fi if [ $1 = start ]
then
psid=`ps aux | grep "uwsgi" | grep -v "grep" | wc -l`
if [ $psid -gt 4 ]
then
echo "uwsgi is running!"
exit 0
else
uwsgi /data/www/xtyw/xtyw/uwsgi.ini
echo "Start uwsgi service [OK]"
fi elif [ $1 = stop ];then
killall -9 uwsgi
echo "Stop uwsgi service [OK]"
elif [ $1 = restart ];then
killall -9 uwsgi
/usr/bin/uwsgi --ini /data/www/xtyw/xtyw/uwsgi.ini --touch-reload "/data/www/xtyw/shell/reload.set"
echo "Restart uwsgi service [OK]" else
echo "Usages: sh uwsgiserver.sh [start|stop|restart]"
fi
上线:
./autoreload.sh
all done
CentOS6+nginx+uwsgi+mysql+django1.6.6+python2.6.6的更多相关文章
- [阿里云部署] Ubuntu+Flask+Nginx+uWSGI+Mysql搭建阿里云Web服务器
部署地址:123.56.7.181 Ubuntu+Flask+Nginx+uWSGI+Mysql搭建阿里云Web服务器 这个标题就比之前的"ECS服务器配置Web环境的全过程及参考资料&qu ...
- Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器 闲着无聊的时候部署了一个Django项目玩,用vm虚拟机部署的. 准备工作 我使用的系统是Ubuntu16 ...
- centos6+nginx+php+mysql+memcached+wordpress
centos6+nginx+php+mysql+memcached+wordpress 搭建步骤(1) LNMP 平台搭建: 请参考:http://www.cnblogs.com/ligao/p/61 ...
- 云服务器部署Python项目(nginx+uwsgi+mysql+项目)
python项目部署到云服务器 关注公众号"轻松学编程"了解更多. 一.硬件准备 云服务器,系统ubuntu_16_04 . 注意:要在安全组中开放Http的80端口. 二.软件准 ...
- docker 部署django项目(nginx + uwsgi +mysql)
最近在学习用docker部署Django项目,经过百折不挠的鼓捣,终于将项目部署成功,爬过好多坑,也发现很多技能需要提高.特此写下随笔与小伙伴们分享,希望能对大家有所启发. docker的理论我就不赘 ...
- Django+Nginx+MongoDB+Mysql+uWsgi的搭建
搭建目标如下: 图:系统架构图 这个系统可以提供web服务及其它查询应用服务,我用其做一个二手房信息搜集.处理及分发的系统,可以通过浏览器访问,也可以通过定制的客户端进行访问. 一.安装篇 1.下载安 ...
- centos6.5+Django+mysql+nginx+uwsgi
centos6.5+Django+mysql+nginx+uwsgi 1.nginx的安装.这里采用nginx-1.6.0, 建立一个shell脚本然后执行. #!/bin/bash nginx_ve ...
- Nginx+uWSGI+Django+Python+ MySQL 搭建可靠的Python Web服务器
一.安装所需工具 yum -y install gcc gcc-c++ rpm-build mysql* libtool-ltdl* libtool automake autoconf libtool ...
- nginx+uwsgi+django+supervisor+mysql+redis
目录 1. 概述 3 2. 安装与配置 3 2.1 django项目与应用创建 3 2.2 uwsgi安装与配置 6 2.3 supervisor安装与配置 8 2.4 nginx安装与作为反向代理服 ...
随机推荐
- 【接口】HttpClient 处理get和post请求(二)(2019-07-14 18:41)
一.环境准备 1.导入httpClient依赖包 <dependency> <groupId>org.apache.httpcomponents</groupId> ...
- 【java+selenium3】元素的扩展操作(二)
1.判断当前元素是否可显示 isDisplay(); //判断元素是否可见 boolean a= driver.findElement(By.id("xxx")).isDispla ...
- Django 中间件 详细总结
一.什么是中间件 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用,用不好会影 ...
- MySQL——DML数据增、删、改
插入 方式一(经典) 语法: insert into 表名(列名,...) values(值,...); 若要一次插入多行 create table if NOT EXISTS user( name ...
- node 读取文件内容并响应
node 读取文件内容并响应 const http = require('http'); const fs = require('fs') //创建 Server const server = htt ...
- CefSharp-基于C#的客户端开发框架技术栈开发全记录
CefSharp简介 源于Google官方 CefSharp用途 CefSharp开发示例 CefSharp应用--弹窗与右键 不弹出子窗体 禁用右键 CefSharp应用--High DPI问题 缩 ...
- Android LayoutInflater(布局填充器)
先来看一下LayoutInflater的基本用法吧,它的用法非常简单,首先需要获取到LayoutInflater的实例,有两种方法可以获取到,第一种写法如下: LayoutInflater layou ...
- [hdu7097]Just a Data Structure Problem
(四边形不等式的套路题) 对于某一组$a_{i}$,显然可以区间dp,设$f_{l,r}$表示区间$[l,r]$的答案,则转移即$$f_{l,r}=\begin{cases}0&(l=r)\ ...
- [luogu4107]兔子和樱花
有两个贪心:1.自底向上dfs,能删就删,这样显然是正确的,因为它最多只会造成它父亲不能删除:2.对于一个节点,优先删除其代价($c[i]+son[i]$)最大的i删除,一定最优,证明略 1 #inc ...
- 十.Go并发编程--channel使用
一.设计原理 Go 语言中最常见的.也是经常被人提及的设计模式就是: "不要通过共享内存来通信,我们应该使用通信来共享内存" 通过共享内存来通信是直接读取内存的数据,而通过通信来共 ...