併發網伺服器遷移
本月將併發程式設計網站遷移到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
恭喜你遷移完成。
相關文章
- 網站遷移更換伺服器的方法網站伺服器
- MyISAM分割槽表遷移 && 合併
- 利用MongoDB的SplitVector命令實現併發資料遷移MongoDB
- 伺服器遷移備忘錄伺服器
- linux伺服器網站到windows伺服器的一次遷移Linux伺服器網站Windows
- sap網站遷移後網站
- 伺服器資料遷移的方法-硬體不同如何遷移資料伺服器
- 網站進行伺服器遷移前應做好哪些準備?網站伺服器
- 移動網際網路伺服器端開發伺服器
- EntityFramework Core併發遷移解決方案Framework
- KVM線上遷移(動態遷移)
- 【通告】機房伺服器臨時遷移公告伺服器
- 選擇無伺服器:Babbel 的遷移故事伺服器
- [基礎常識]遷移ECS雲伺服器伺服器
- 伺服器遷移的兩種方式淺談伺服器
- 關於伺服器資料遷移,介紹在伺服器資料遷移計劃中的7個步驟伺服器
- 【遷移】使用rman遷移資料庫資料庫
- 全網唯一:移動網際網路伺服器端開發!伺服器
- Elasticsearch 叢集誇網路快照遷移Elasticsearch
- 無外網Oracle資料庫遷移Oracle資料庫
- 遷移公告
- CCU遷移
- 棧遷移
- SharePoint伺服器端物件遷移資料夾伺服器物件
- 再談遷移學習:微調網路遷移學習
- 二維網格的遷移(java實現)Java
- 網站遷移SSL證書該如何操作網站
- Linux+PHP+MySql網站遷移配置LinuxPHPMySql網站
- 一次網站遷移故障及分析網站
- 網站高併發網站
- 【遷移】SqlServer 遷移到 MySQL 方法ServerMySql
- Azure ASM到ARM遷移 (三) Reserved IP的遷移ASM
- 遷移案例一: oracle 8i 檔案遷移Oracle
- 查詢行遷移及消除行遷移(chained rows)AI
- 解析DELLR710伺服器遷移操作內容伺服器
- 記一次快取伺服器遷移史,心塞!快取伺服器
- 工作中雲伺服器遷移的幾點經驗伺服器
- 更換主域伺服器,如何完整遷移AD和DNS伺服器DNS