博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
业务迁移---web
阅读量:6330 次
发布时间:2019-06-22

本文共 4573 字,大约阅读时间需要 15 分钟。

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

迁移代码

将源代码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@]# lltotal 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; 
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
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-tagshort_open_tag = ON

  

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

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

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

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

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

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

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

 

转载于:https://www.cnblogs.com/liuquan/p/7263381.html

你可能感兴趣的文章
【springboot】【redis】springboot+redis实现发布订阅功能,实现redis的消息队列的功能...
查看>>
【RocketMQ】【分布式事务】使用RocketMQ实现分布式事务
查看>>
cURL实现Get和Post
查看>>
爬取王垠的博客并生成pdf
查看>>
六.期货期权及其他金融衍生品(投资分析)
查看>>
[AX]AX2012 SSRS报表使用Report Data Provider Class作为数据集
查看>>
window for jdk install
查看>>
BufferedInputSream和BufferedOutputSream,,,
查看>>
【Java】 Java网络编程总结
查看>>
Unique Paths II
查看>>
数据库SQL Server
查看>>
set集合
查看>>
抽象类的运用
查看>>
linux sed命令详解
查看>>
汉诺塔2(四个柱)
查看>>
你不知道的z-index
查看>>
LeetCode - 31. Next Permutation
查看>>
团队任务(一)
查看>>
this keyword details
查看>>
./和../和/三种路径的区别
查看>>