建立文件夹
cd /home
mkdir src
mkdir django
###上传文件到相应目录(按照目录名上传即可)
src目录文件上传到 /home/src
django目录文件上传到 /home/django
rc.d 目录文件上传到 /etc/rc.d/init.d
建立组和用户
groupadd cluster
useradd django -g cluster
安装Python
cd /home/src/
tar zxvf Python-2.7.5.tgz
cd Python-2.7.5
./configure --prefix=/usr/python && make install clean
升级系统自带的python2.4版本到新版本
mv /usr/bin/python /usr/bin/python-2.4.4.bak
ln -s /usr/python/bin/python2.7 /usr/bin/python
这时yum可能无法使用
vi /usr/bin/yum
将/usr/bin/yum代码中的/usr/bin/python修改为#!/usr/bin/python2.4配置即可
测试python版本,输入python命令,查看显示的版本,一般会出现如下字样
Python 2.7.5 (default, Dec 26 2013, 14:31:14)
安装setuptools
cd /home/src/
tar zxvf setuptools-17.0.tar.gz
cd setuptools-17.0
python setup.py install
安装Django
cd /home/src/
tar zxvf Django-1.5.5.tar.gz
cd Django-1.5.5
python setup.py install
安装uWSGI的生产环境
cd /home/src/
vi /etc/sysctl.conf
文件最后增加
----------------------------------------------------------------
net.core.somaxconn = 16384
----------------------------------------------------------------
让环境变量生效
sysctl -p
tar zxvf uwsgi-1.9.21.1.tar.gz
cd uwsgi-1.9.21.1
python setup.py build
make
mv uwsgi /home
授权
chmod 755 /home/uwsgi
建立sock文件,并授权
vi /home/django/uwsgi.sock
chmod 755 /home/django/uwsgi.sock
安装Nginx
安装openssl
yum -y install openssl-devel
手动链接库文件
cd /lib64
ln -s libpcre.so.0.0.1 libpcre.so.1
安装nginx时需要PCRE,并且PCRE是nginx服务配置正则的支持,所以先安装PCRE
cd /home/src
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure && make install clean
安装nginx
cd /home/src
tar zxvf ngx_cache_purge-2.1.tar.gz
tar zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
*修改nginx源代码,调整日志时间格式
vi src/core/ngx_times.c
--------------------------------------------------------------------------------------------
#行49
static u_char cached_http_log_time[NGX_TIME_SLOTS]
[sizeof("28/Sep/1970:12:00:00 +0600")];
修改为
static u_char cached_http_log_time[NGX_TIME_SLOTS]
[sizeof("1970-09-28 12:00:00")];
#行64
ngx_cached_http_log_time.len = sizeof("28/Sep/1970:12:00:00 +0600") - 1;
修改为
ngx_cached_http_log_time.len = sizeof("1970-09-28 12:00:00") - 1;
#行151
p2 = &cached_http_log_time[slot][0];
(void) ngx_sprintf(p2, "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d",
tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
tm.ngx_tm_year, tm.ngx_tm_hour,
tm.ngx_tm_min, tm.ngx_tm_sec,
修改为
p2 = &cached_http_log_time[slot][0];
(void) ngx_sprintf(p2, "%4d-%02d-%02d %02d:%02d:%02d",
tm.ngx_tm_year, tm.ngx_tm_mon,
tm.ngx_tm_mday, tm.ngx_tm_hour,
tm.ngx_tm_min, tm.ngx_tm_sec,
--------------------------------------------------------------------------------------------
#vi src/http/modules/ngx_http_log_module.c
--------------------------------------------------------------------------------------------
#行219
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
修改为
{ ngx_string("time_local"), sizeof("1970-09-28 12:00:00") - 1,
--------------------------------------------------------------------------------------------
./configure --prefix=/usr/nginx --user=django --group=cluster --with-http_stub_status_module --with-http_ssl_module --add-module=/home/src/ngx_cache_purge-2.1
make install clean
提示:
--with-http_ssl_module选项使nginx可以支持https协议;
--with-http_stub_status_module选项支持nginx的状态监视;
--add-module选项可以添加附加模块
启动nginx测试(可不做)
#/usr/nginx/sbin/nginx
安装memcached
cd /home/src
tar -zxvf python-memcached-latest.tar.gz
cd python-memcached-1.53
python setup.py install
创建系统根目录,变更所属的用户组
mkdir /home/django/wwwroot
chown -R django:cluster /home/django
修改中间件配置
vi /home/django/src/config.py
第1,2行IP地址(河北改成10.3.1.13, 长春10.2.1.13,沈阳10.1.1.13)
erpPath = 'http://10.1.1.12/'
erp_host = '10.1.1.12'
修改第8行和第10行中的IP地址为本机IP地址
'host': '192.168.4.32',
'as_host': '10.1.1.30',
vi /home/django/callback/callback_config.py
修改以下IP地址
erp_host = '10.1.1.13' #辽宁 10.1.1.13,河北10.3.1.13, 吉林 10.2.1.13
wm_host = '192.168.230.252' #修改为本机IP
as_host = '192.168.230.252' #修改为本机IP
设置自动任务
crontab -e
输入如下内容后保存退出 :wq
50 23 * * * cd /home/django/callback/logs&&./cplogs.sh
40 06 * * * /etc/init.d/ccmd restart
41 06 * * * /etc/init.d/cced restart
*/10 * * * * sh /home/django/scripts/ccpro.sh
00 08 * * * /etc/init.d/ccmd restart
01 08 * * * /etc/init.d/cced restart
注册中间件服务
cd /etc/rc.d/init.d
chmod 755 ccmd cced
chmod -R 755 /home/django/callback
chkconfig ccmd on
chkconfig cced on
启动服务
service ccmd start
service cced start
如果出现如下提示,重启ccmd即可
mv: cannot stat `/home/django/cc.log': No such file or directory
测试,如果报黄页,表示服务安装成功
http://192.168.4.32:8710