#vi /etc/sysconfig/network NETWORKING=yes(表示系統是否使用網絡,通常設置爲yes。若是設爲no,則不能使用網絡,並且不少系統服務程序將沒法啓動) HOSTNAME=centos(設置本機的主機名,這裏設置的主機名要和/etc/hosts中設置的主機名對應) GATEWAY=192.168.1.1(設置本機鏈接的網關的IP地址。例如,網關爲10.0.0.2)
#vi /etc/resolv.conf nameserver: 114.114.114.114 # IBM哥們講的國內比較快的一個DNS
修改對應網卡的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時,系統啓動時激活此設備
# service network restart
或
# /etc/init.d/network restart
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
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.pypython
變成這個了,2016年04月11日22:08:44更新mysql
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
2016年06月12日11:32:45 更新
nginx
pip install django==1.6.6
yum install mysql-devel mysql mysql-server python-devel
pip install MySQL-python
mysql -uroot use mysql;#有的版本默認管理數據庫不是這個名字(*注意) MySQL> update user set password=PASSWORD('newpassword') where User='root'; MySQL> flush privileges; //刷新權限,重啓mysql也能夠 MySQL> quit
或者:git
/usr/bin/mysqladmin -u root password 'passw0rd'
CREATE SCHEMA `xtyw` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
# 這樣建立的表不會出現admin中表更新中文內容的時候亂碼
yum -y install 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; } }
#---------------------------------如下是我添加的內容github
thensql
/etc/init.d/nginx start
pip install uwsgi
進入項目主目錄,即settings.py所在目錄,建立uwsgi.ini配置文件shell
內容以下數據庫
[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
執行:django
#uwsgi uwsgi.ini
若是是xml文件
#uwsgi -x uwsgi.xml
yum -y install inotify-tools
#!/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 &
#!/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
上線:bootstrap
./autoreload.sh
all done