CentOS6.5 运维平台FourthGen部署说明

6 篇文章 0 订阅
3 篇文章 0 订阅

注:该部署说明会根据源码变动而更新,适用于最新源代码

一、升级python版本

yum -y install python-devel openssl-devel gcc gcc-c++ sqlite-devel readline-devel ncurses-devel bzip2-devel tk-devel
cd /usr/src/
wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar zxvf Python-2.7.5.tgz
cd Python-2.7.5
./configure --prefix=/usr/local/python2.7.5
make
make altinstall
echo 'export PATH=$PATH:/usr/local/python2.7.5/bin/' >> /etc/profile
source /etc/profile

二、安装setuptools

tar zxf setuptools-18.3.2.tar.gz   
cd setuptools-18.3.2/  
python2.7 setup.py build  
python2.7 setup.py install  
cd .. 
三、安装mysql数据库

参见:http://blog.csdn.net/hnhuangyiyang/article/details/50412892

四、安装django

easy_install Django==1.8.7
easy_install bootstrap_admin

五、安装uwsgi

easy_install uwsgi

六、安装supervisor

easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf
cat <<EOF>> /etc/supervisord.conf
[program:fourthgen]
command=/usr/local/python2.7.5/bin/uwsgi --ini /app/fourthgen/uwsgi.ini
directory=/app/fourthgen
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
EOF

七、安装MySQL-python

easy_install MySQL-python

八、安装pycurl

yum install libcurl-devel -y
easy_install pycurl
九、克隆FourthGen代码

yum install git -y
mkdir /app
git clone https://github.com/hyxc/fourthgen.git
mkdir -p /var/log/fourthgen/
touch /var/log/fourthgen/all.log /var/log/fourthgen/error.log
cd /app/fourthgen/
python2.7 manage.py makemigrations
python2.7  manage.py migrate
python2.7 manage.py collectstatic
python2.7 manage.py createsuperuser

十、安装nginx

1.安装

yum install pcre-devel -y
useradd -r www -s /sbin/nologin
tar zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-http_realip_module --user=www --group=www 
make
make install
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
mkdir -p /usr/local/nginx/conf/vhost
2.配置

文件/usr/local/nginx/conf/nginx.conf内容如下:

user www; 
worker_processes 4;
error_log  logs/nginx_error.log  notice;
pid        /usr/local/nginx/sbin/nginx.pid;

worker_rlimit_nofile 65535;

events
     {
              use epoll;
              worker_connections 65535;
      }
http
     {
              include       mime.types;
              default_type  application/octet-stream;
              charset  utf-8;
              server_names_hash_bucket_size 128;
              client_header_buffer_size 32k;
              large_client_header_buffers 4 32k;
              client_max_body_size 128m;
              sendfile on;
              tcp_nopush     on;
              keepalive_timeout 60;
              tcp_nodelay on;
              server_tokens off;
              client_body_buffer_size  512k;
              gzip on;
              gzip_min_length  1k;
              gzip_buffers     4 16k;
              gzip_http_version 1.1;
              gzip_comp_level 2;
              gzip_types      text/plain application/x-javascript text/css application/xml;
              gzip_vary on;
              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                                '$status $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for" "$host"' ;

              include vhost/*.conf;
       }
文件/usr/local/nginx/conf/vhost/fourthgen.conf内容如下:

server
        {
                listen       80;
                server_name 127.0.0.1; 
                #index index.html index.htm ;
                #root  html;
                #location ~ .*\.(php|php5)?$
                #        {
                #                try_files $uri =404;
                #                fastcgi_pass  unix:/tmp/php-cgi.sock;
                #                fastcgi_index index.php;
                #                include fcgi.conf;
                #        }
                #location /status {
                #       stub_status on;
                #}
                #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                #        {
                #                expires      30d;
                #        }
                #location ~ .*\.(js|css)?$
                #        {
                #                expires      1d;
                #        }
                charset     utf-8;

                client_max_body_size 75M;
                location /media  {
                        alias /app/fourthgen/media;
                }

                location /static {
                        alias /app/fourthgen/collected_static;
                }

                location / {
                        uwsgi_pass  unix:/tmp/fourthgen.sock;
                        include uwsgi_params;
                        #auth_basic  "FourthGen Auth";
                        #auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
                }
                access_log  logs/fourthgen-access.log  main;
        }

文件/etc/init.d/nginx内容如下:

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15 
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
 
lockfile=/var/lock/subsys/nginx
 
make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -z "`grep $user /etc/passwd`" ]; then
       useradd -M -s /bin/nologin $user
   fi
   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
   for opt in $options; do
       if [ `echo $opt | grep '.*-temp-path'` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}
 
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
 
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac
十一、重启各项服务

supervisord -c /etc/supervisord.conf
service nginx restart

十二、创建平台登录用户

浏览器打开"http://你的IP/admin"进入管理后台,在Accounts部分添加登录用户即可。



GitHup源码地址:FourthGen




交流QQ号:2393470186






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值