并发网服务器迁移

本月将并发编程网站迁移到UCloud云服务,本文是迁移的步骤,希望对其他同学有所帮助。

第一步:安装软件

软件包括php,mysql和nginx。

yum -y install  php php-fpm mysql nginx lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy

第二步:软件配置

2.1 配置nginx

vi /etc/nginx/nginx.conf

user            www www;
worker_processes  8;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections  65535;
}
http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$request_time $upstream_response_time'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 10M;
sendfile on;
tcp_nopush     on;
keepalive_timeout 30;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
 fastcgi_read_timeout 300;
 fastcgi_buffer_size 64k;
 fastcgi_buffers 4 64k;
 fastcgi_busy_buffers_size 128k;
 fastcgi_temp_file_write_size 128k;
gzip on;
 gzip_min_length 1k;
 gzip_buffers 4 16k;
 gzip_http_version 1.0;
 gzip_comp_level 2;
 gzip_types text/plain application/x-javascript text/css application/xml;
 gzip_vary on;
server
 {
 listen 80;
 server_name ifeve.com www.ifeve.com;
 index index.html index.htm index.php;
 try_files $uri $uri/ /index.php?q=$uri&$args;
 root /home/www/ifeve;
#include wp_params_supercache.conf;
location ~ .*\.(php|php5)?$
 {
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 include fcgi.conf;
 }
}
 }

2.2 配置php-fpm

vi /etc/php-fpm.d/www.conf
;Start a new pool named 'www'.
 [www]
; The address on which to accept FastCGI requests.
 ; Valid syntaxes are:
 ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
 ; a specific port;
 ; 'port' - to listen on a TCP socket to all addresses on a
 ; specific port;
 ; '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
 listen = 127.0.0.1:9000
; Set listen(2) backlog. A value of '-1' means unlimited.
 ; Default Value: -1
 listen.backlog = 102400
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
 ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
 ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
 ; must be separated by a comma. If this value is left blank, connections will be
 ; accepted from any ip address.
 ; Default Value: any
 listen.allowed_clients = 127.0.0.1,120.132.54.203,115.192.118.9
; Set permissions for unix socket, if one is used. In Linux, read/write
 ; permissions must be set in order to allow connections from a web server. Many
 ; BSD-derived systems allow connections regardless of permissions.
 ; Default Values: user and group are set as the running user
 ; mode is set to 0666
 ;listen.owner = nobody
 ;listen.group = nobody
 listen.mode = 0666
; Unix user/group of processes
 ; Note: The user is mandatory. If the group is not set, the default user's group
 ; will be used.
 /pi
 ; be killed. This option should be used when the 'max_execution_time' ini option
 ; does not stop script execution for some reason. A value of '0' means 'off'.
 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
 ; Default Value: 0
 request_terminate_timeout = 3s
; The timeout for serving a single request after which a PHP backtrace will be
 ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
 ; Default Value: 0
 request_slowlog_timeout = 3s
; The log file for slow requests
 ; Default Value: not set
 ; Note: slowlog is mandatory if request_slowlog_timeout is set
 slowlog = /var/log/php-fpm/www-slow.log
; Set open file descriptor rlimit.
 ; Default Value: system defined value
 rlimit_files = 102400
; Set max core size rlimit.
 ; Possible Values: 'unlimited' or an integer greater or equal to 0
 ; Default Value: system defined value
 rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
 ; absolute path. When this value is not set, chroot is not used.
 ; Note: chrooting is a great security feature and should be used whenever
 ; possible. However, all PHP paths will be relative to the chroot
 ; (error_log, sessions.save_path, ...).
 ; Default Value: not set
 ;chroot =
; Chdir to this directory at the start. This value must be an absolute path.
 ; Default Value: current directory or / when chroot
 ;chdir = /var/www

第三步:迁移数据和网站

3.1 迁移数据库

  • 在旧服务器中导出ifeve数据库:mysql -f -h localhost -uroot -pifevepassword  ifeve > ifevedb_backup.sql
  • 在新服务器中设置新mysql的默认密码:mysqladmin -u root password 123
  • 在新服务器中创建ifeve数据库:mysqladmin -h localhost -u root -p create ifeve
  • 在新服务器中导入ifeve数据库:mysql -f -h localhost -uroot -pifevepassword  ifeve < ifevedb_backup.sql

3.2 迁移网站

scp -r 192.168.0.1:/home/www/ifeve  192.168.0.2:/home/www/

3.3 设置目录权限

  • chown -R  www.www /home/www/ifeve
  • chmod -R 755 /home/www/ifeve

第四步:启动应用

  • service php-fpm restart
  • service nginx restart
  • service mysqld restart

恭喜你迁移完成。

查询各种日志

  • tail -fn 5 /var/log/nginx/error.log
  • tail -fn 5 /var/log/nginx/access.log
  • tail -fn 500 /var/log/php-fpm/error.log
  • tail -fn 5 /var/log/php-fpm/www-slow.log
  • 转载自 并发编程网 - ifeve.com
时间: 2024-09-18 04:03:07

并发网服务器迁移的相关文章

Windows 2008 R2 DHCP服务器迁移到Windows Server 2012(一)

大多数企业在早期的IT基础架构中,都会考虑将DHCP等基础服务和域控角色混合部署.这样不但可以节约成本还能简化管理. 但随着企业规模的不断扩大,IT基础架构会越来越完善,这种混合部署从权限管理.可用性方面都会存在种种限制.将角色服务器进行分离无疑是最佳选择. 下面来看看如何将Windows2008 R2域控中的DHCP服务器迁移至Windows 2012中,并实现DHCP的故障转移功能. DHCP故障转移Windows2012的一个新功能, 此功能提供让两个 DHCP 服务器服务于 同一子网或作

服务器搭建-服务器迁移要注意哪些东西?

问题描述 服务器迁移要注意哪些东西? 对.net不了解,现在要做一个.net项目的服务器迁移工作.关于如何选择服务器,客户有自己的,这个不用担心.这个项目主要是一个网站项目,C#语言,数据库SQL server 2008,IIS版本不确定.现在要把项目移到一个新的服务器上,环境的话应该不会变.具体要怎么做? 大体的流程是①数据库分离,拷贝项目文件:②附加数据库,发布项目:③关联域名. 求具体操作步骤,以及IIS的安装步骤,还有要注意什么东西呢? 解决方案 有人吗?有人吗?别沉啊--

Domino8.5服务器迁移方案

对于Domino 8.5服务器的迁移,其基本思路是:在新服务器上安装相同版本的Domino服务器,但是一定不要配置它,然后从旧服务器上把数据目录data和notes.ini文件移植到新服务器上.新服务器相应DNS要做好解析,然后稍微配置Domino即可使用.具体的迁移及配置过程,如下: 第一步.安装和旧服务器相同版本的Domino.我们这是以Domino8.5.2为例,来进行迁移.有关Domino的安装就不在此做详细介绍.安装完Domino及其相应的软件后,我们不要进行任何的配置.同时还要把新服

分支缓存功能服务器迁移到Windows 2008 R2详解

分支缓存是 http://www.aliyun.com/zixun/aggregation/13975.html">Windows Server 2008 R2 和 Windows 7 客户端的一项功能,它使分支办公室中的客户端能够安全地检索缓存在本地的文件,而无需从主办公室服务器检索文件.因为分支办公室通常通过速度慢的广域网 (WAN) 进行连接,所以此功能可以减少对 WAN 链接的使用,并提升客户端应用程序的响应速度. 本系列文章如何将一个使用分支缓存功能的服务器迁移到另一个运行着 W

Spring+quartz服务器迁移后,启动定时器任务无法恢复。

问题描述 Spring+quartz服务器迁移后,启动定时器任务无法恢复. 问题描述:原来quartz定时任务都正常运行,目前进行服务器迁移,把war包部署到新服务器,并且数据库mysql 也迁移到新的服务器,定时器是持久化到mysql里面的,再重启应用时候,定时器一直提示"[org.springframework.scheduling.quartz.LocalDataSourceJobStore] Handling 4 trigger(s) that missed their schedule

记一次Linux物理服务器迁移总结

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://dgd2010.blog.51cto.com/1539422/1685184     两天前我们对生产系统中的两台服务器做了在线迁移,因此在此想总结一下迁移前后发生的一些事情和获得的经验教训.本着专业做事的风格,在此前后我阅读了微软和红帽官方的一些迁移指南,但发现实用的部分并不是特别多,因此在参考了微软和红帽的迁移指南后我决定自己一篇符合当前场景的服务器迁移"指南",仅

Windows Server 2008 R2实战:DHCP服务器迁移验证篇

本系列文章介绍了将现有 DHCP 服务器设置迁移到运行 http://www.aliyun.com/zixun/aggregation/13975.html">Windows Server 2008 R2 的服务器的步骤.如下图显示,迁移前过程包括手动收集数据,然后是在目标服务器和源服务器上运行程序.迁移过程包括源服务器和目标服务器迁移过程,这些过程使用 Export 和 Import cmdlet 自动收集.存储和迁移服务器角色设置.迁移后过程包括验证目标服务器是否已经成功替换源服务器并

Windows Server 2008 R2实战:DHCP服务器迁移准备篇

本系列文章介绍了将现有 DHCP 服务器设置迁移到运行 http://www.aliyun.com/zixun/aggregation/13975.html">Windows Server 2008 R2 的服务器的步骤.如下图显示,迁移前过程包括手动收集数据,然后是在目标服务器和源服务器上运行程序.迁移过程包括源服务器和目标服务器迁移过程,这些过程使用 Export 和 Import cmdlet 自动收集.存储和迁移服务器角色设置.迁移后过程包括验证目标服务器是否已经成功替换源服务器并

从传统服务器迁移到云服务器需要注意什么

在云计算时代下,云计算以其独特的优势获得越来越多的企业的青睐,为此,很多企业也开始从传统服务器向云计算迁徙.然而在整个迁徙的过程中并不是一个简单的过程,一个不相信都有可能导致功亏一篑.因此,从传统服务器迁移到云服务器需要考虑成本问题.选择合适版本以及正确的部署安全和管理工作,具体的将做一下分析: 从传统服务器迁移到云服务器需要注意什么 第一.成本问题 第一个错误是在部署和操作云服务器解决方案时,缺乏对TCO(总拥有成本)的成本优势的理解.我们需要复杂的指标来确定云计算是否能为企业节省资金,但大多