zoukankan      html  css  js  c++  java
  • 业务迁移---web

    #本文是做记录使用,不做为任何参考文档#

    迁移代码

    将源代码scp至新的server上

    搭建服务

    yum安装nginx服务

    yum install nginx   #yum安装
    service nginx start #启动服务

    配置文件相关

    备份原文件

     cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

    因为我是同时迁移两个不通域名的web后台,所以涉及到了nginx的虚拟目录

    为了主配置文件清晰点,所以使用了 include /etc/nginx/conf.d/*.conf;  将不通的server配置拆分出去~  

    include 要写在http字段内(#废话#)

    vi /etc/nginx/nginx.conf
    
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
    # Settings for a TLS enabled server.
    "/etc/nginx/nginx.conf" 69L, 1979C
    

     虚拟目录配置

    到/etc/nginx/conf.d/ 下创建以.conf结尾的文件会被nginx解析  aaa.com.conf  bbb.com.conf

    [root@]# cd /etc/nginx/conf.d/
    [root@]# ll
    total 12
    -rw-r--r-- 1 root root 516 Jul 24 13:54 aaa.com.conf
    -rw-r--r-- 1 root root 556 Jul 28 16:59 bbb.conf
    [root@]# 
    
    [root@iz8vbilqy0q9v8tds55bqzz conf.d]# cat aaa.com.conf 
    server {
        listen       80;                        
        server_name aaa.com;    
        root  /var/www/aaa.com;             
        index index.html index.htm index.php;   
    	location /APP/{   #例如nginx的重定向功能,将访问/APP/开头指定到interface文件中
    	index index.php;
    	if (!-e $request_filename){
    		rewrite ^/APP/(.*)$ /interface.php?s=$1 last;
    		break;
        	}
       	}
    
    
    	location ~ .php$ {                #指定本地php解析,fastcgi 信息
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param  SCRIPT_FILENAME /var/www/aaa.com$fastcgi_script_name;
                include        fastcgi_params;
            }
    }
    [root@]# 
    
    [root@iz8vbilqy0q9v8tds55bqzz conf.d]# cat bbb.com.conf 
    server {
        listen       80;                        
        server_name bbb.com;    
        root  /var/www/bbb.com;             
        index index.html index.htm index.php;   
    	location /APP/{   #例如nginx的重定向功能,将访问/APP/开头指定到interface文件中
    	index index.php;
    	if (!-e $request_filename){
    		rewrite ^/APP/(.*)$ /interface.php?s=$1 last;
    		break;
        	}
       	}
    
    
    	location ~ .php$ {                #指定本地php解析,fastcgi 信息
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                #fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param  SCRIPT_FILENAME /var/www/bbb.com$fastcgi_script_name;
                include        fastcgi_params;
            }
    }
    [root@]# 
    

     

    按以上配置完成后,即可访问相应的目录~ 

    www.aaa.com

    www.bbb.com

    ##########################################################

    有个小插曲记录一下,我搭建好服务后发现bbb.com的php文件没有解析,aaa却正常,报错~

    原来两个服务的框架不一样,bbb的框架写的不太规范,导致了解析失败,更改php.ini文件解决

    short_open_tag = Off 默认为OFF更改为 short_open_tag = ON   

    官方的解释,是要打开适配 <?  ?>  这种不规则的写法。~~~~

    ; This directive determines whether or not PHP will recognize code between
    ; <? and ?> tags as PHP source which should be processed as such. It's been
    ; recommended for several years that you not use the short tag "short cut" and
    ; instead to use the full <?php and ?> tag combination. With the wide spread use
    ; of XML and use of these tags by other languages, the server can become easily
    ; confused and end up parsing the wrong code in the wrong context. But because
    ; this short cut has been a feature for such a long time, it's currently still
    ; supported for backwards compatibility, but we recommend you don't use them.
    ; Default Value: On
    ; Development Value: Off
    ; Production Value: Off
    ; http://php.net/short-open-tag
    short_open_tag = ON
    

      

    #######################

    还有类似的权限啊,chown  -R nginx.nginx  /var/www/xxxx 等等细节需要注意,有可能会影响~

    #######################

    如果有redis服务的话,也会影响使用,例如缺少了redis的插件,redis服务没有集体迁移

    我就遇到了redis服务迁移出的问题,redis内容太大了我内存比较低导致了服务总被系统kill掉,通过dmesg日志才发现的。。。

    #######################

    迁移的时候问题很多,查看nginx和php的错误日志可以很快定位问题

    好记性不如烂笔头-_-
  • 相关阅读:
    poj 1222 EXTENDED LIGHTS OUT (高斯消元 )
    poj 2187 Beauty Contest (凸包: 最远点对,最长直径 , 旋转卡壳法)
    poj 1408 Fishnet (几何:线段相交 + 叉积 求面积 )
    poj 1228 Grandpa's Estate ( 凸包 )
    高斯消元 模版
    poj 1830 开关问题 (高斯消元 )
    poj 1113 Wall (凸包:周长)
    旋转卡壳算法
    poj 1681 Painter's Problem (高斯消元 )
    字符串相关处理
  • 原文地址:https://www.cnblogs.com/liuquan/p/7263381.html
Copyright © 2011-2022 走看看