CentOS6+nginx+uwsgi+mysql+django1.6.6+python2.6.6详解编程语言
2023-06-13 09:20:45 时间
#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哥们讲的国内比较快的一个DNS3.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 restart5.配置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 update6.安装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安装djangopip install django==1.6.68.pip安装mysqldb
yum install mysql-devel mysql mysql-server python-devel pip install MySQL-python9.修改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 passw0rd10.mysql创建schema
CREATE SCHEMA `xtyw` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; # 这样创建的表不会出现admin中表更新中文内容的时候乱码11.安装nginx
yum -y install nginx12.配置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 start13.安装uwsgi
pip install uwsgi14.开始用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.xml15.最后附上自动django源码自动重载方法 1.安装工具
yum -y install inotify-tools2.编写一个监视脚本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 /bin/touch /data/www/xtyw/shell/reload.set continue done3.编写监视文件reload.set(内容即是uwsgi启动脚本)
#!/bin/bash if [ ! -n "$1" ] then echo "Usages: sh uwsgiserver.sh [start|stop|restart]" exit 0 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]"
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
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/15569.html
ccentosgojavamysqlpythonxml相关文章
- mysql读写分离延迟问题_MySQL读写分离后的延迟解决方案
- Kettle的MySQL数据源版本问题及解决
- MySQL的繁体字之旅(mysql繁体字)
- Spring Boot 2 (五):Docker Compose + Spring Boot + Nginx + Mysql 实践详解编程语言
- Python3:Django连接Mysql数据库时出错,’Did you install mysqlclient or MySQL-python’详解编程语言
- 关系MySQL查询:解决一对多关系问题(mysql查询一对多)
- MySQL:一种基于SQL的编程语言(mysql什么语言写的)
- Mysql: 对Null操作的全方位解析(mysql等于null)
- MySQL表变量的使用方法(mysql表变量)
- 的安装MySQL 5.7 的安装详解(5.7mysql)
- MySQL如何快速安装?25字教你一分钟搞定!(mysql怎么安装)
- MySQL实现汉字拼音排序的办法(mysql汉字拼音排序)
- 如何将MySQL数据导出为CSV文件?(mysql导出到csv)
- MySQL机房间之间的数据同步(mysql 机房同步)
- 深入了解MySQL:探索这款流行的关系型数据库编程语言(mysql编程语言)
- MySQL函数中参数的实用性分析(mysql函数参数)
- 深入了解MySQL中PLSQL编程语言(mysql中pl sql)
- MySQL中OR运算符的使用(mysql 中 or)
- 千万级MySQL数据库极速查询,秒杀慢速(100万mysql数据库)
- MySQL出现问题教你轻松解决(mysql中出现怎么解决)
- MySQL下载如何获取注册码(mysql下载需要注册码)
- 使用MySQL进行数据比较的技巧分享(mysql 两条数据比较)
- GET MYSQL 免费下载并破解MySQL数据库软件(mysql下载和破解)
- MySQL上机试卷题目检验你的数据库技能水平(mysql上机试卷题目)
- MYSQL离线使用方法大揭秘不联网也能愉快地使用MySQL(mysql 不联网吗)
- MySQL不是编程语言或可执行程序(mysql不是可运行程序)