{"id":862,"date":"2013-11-28T16:28:49","date_gmt":"2013-11-28T08:28:49","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=862"},"modified":"2015-01-25T12:51:09","modified_gmt":"2015-01-25T12:51:09","slug":"migrating-site-to-digital-ocean","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2013\/11\/migrating-site-to-digital-ocean\/","title":{"rendered":"\u8fc1\u79fb\u535a\u5ba2\u5230Digital Ocean"},"content":{"rendered":"<p>\u641c\u4e86\u4e0b\u636e\u8bf4\u6027\u4ef7\u6bd4\u8fd8\u53ef\u4ee5\u7684VPS\uff0c\u4f3c\u4e4e\u6211\u5728\u4e0a\u6d77ping\u503c\u5f88\u9ad8\uff0c\u7528\u7528\u770b\u5427(\u53ef\u4ee5\u6309\u5c0f\u65f6\u4ed8\u8d39)\u3002<\/p>\n<p>\u6ce8\u518c\u8d26\u53f7\uff0c\u521b\u5efaVPS\uff0c\u62ff\u5230root\u7528\u6237<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh root@162.243.117.95<\/pre>\n<p>\u521b\u5efa\u5e38\u7528\u8d26\u6237<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh guohai@162.243.117.95<\/pre>\n<p>\u62ff\u5230\u4e4b\u540e\u5f53\u7136\u5148\u88c5\u4e9b\u57fa\u7840\u7684\u8f6f\u4ef6\uff0c\u6bd4\u5982FTP\u670d\u52a1\uff0cSSL\u7b49\u7b49\uff0c\u8fd9\u4e2a\u770b\u81ea\u5df1\u7684\u7231\u597d\u3002<br \/>\n\u6478\u51fa\u6211\u5f53\u5e74\u505a\u5404\u79cdMIS\u7684\u7ecf\u9a8c\uff0c\u4ec0\u4e48Nginx\/MySQL\/PHP\uff0c\u4e0d\u8fc7PHP\u6211\u4e4b\u524d\u6ca1\u6709\u5f04\u8fc7\uff0c\u7167\u7740\u7f51\u7edc\u4e0a\u7b80\u5355\u7684\u641e\u641e\u3002<\/p>\n<p>[root@Knight-on-the-Cloud ~]# yum -y install vsftpd<br \/>\n\u53c2\u7167<br \/>\nhttp:\/\/my.oschina.net\/u\/130017\/blog\/15229<br \/>\n\u57fa\u7840\u914d\u7f6e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nlocal_enable=YES\r\nascii_upload_enable=YES\r\nascii_download_enable=YES\r\nwrite_enable=YES\r\n<\/pre>\n<p>\u7136\u540e\u5c31\u662fMySQL<br \/>\n[root@Knight-on-the-Cloud log]# yum -y install mysql-server<\/p>\n<p>[root@Knight-on-the-Cloud log]# service mysqld start<br \/>\nInitializing MySQL database:  WARNING: The host &#8216;Knight-on-the-Cloud&#8217; could not be looked up with resolveip.<br \/>\nThis probably means that your libc libraries are not 100 % compatible<br \/>\nwith this binary MySQL version. The MySQL daemon, mysqld, should work<br \/>\nnormally with the exception that host name resolving will not work.<br \/>\nThis means that you should use IP addresses instead of hostnames<br \/>\nwhen specifying MySQL privileges !<br \/>\nInstalling MySQL system tables&#8230;<br \/>\nOK<br \/>\nFilling help tables&#8230;<br \/>\nOK<\/p>\n<p>To start mysqld at boot time you have to copy<br \/>\nsupport-files\/mysql.server to the right place for your system<\/p>\n<p>PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !<br \/>\nTo do so, start the server, then issue the following commands:<\/p>\n<p>\/usr\/bin\/mysqladmin -u root password &#8216;new-password&#8217;<br \/>\n\/usr\/bin\/mysqladmin -u root -h Knight-on-the-Cloud password &#8216;new-password&#8217;<\/p>\n<p>Alternatively you can run:<br \/>\n\/usr\/bin\/mysql_secure_installation<\/p>\n<p>which will also give you the option of removing the test<br \/>\ndatabases and anonymous user created by default.  This is<br \/>\nstrongly recommended for production servers.<\/p>\n<p>See the manual for more instructions.<\/p>\n<p>You can start the MySQL daemon with:<br \/>\ncd \/usr ; \/usr\/bin\/mysqld_safe &#038;<\/p>\n<p>You can test the MySQL daemon with mysql-test-run.pl<br \/>\ncd \/usr\/mysql-test ; perl mysql-test-run.pl<\/p>\n<p>Please report any problems with the \/usr\/bin\/mysqlbug script!<\/p>\n<p>                                                           [  OK  ]<br \/>\nStarting mysqld:                                           [  OK  ]<\/p>\n<p>\u8fd9\u6837\u88c5\u597d\u4e4b\u540e\u5c31\u8bb0\u4f4f\u4f60MySQL\u7684root\u5bc6\u7801\u5566\uff0c\u8bb0\u5f97\u6240\u6709\u90fd\u662f\u6700\u5c0f\u6743\u9650\u539f\u5219\uff0c\u4e0d\u7528\u7684\u5c31\u4e0d\u9700\u8981\u5f00\u3002<\/p>\n<p>\u79fb\u52a8MySQL\u6570\u636e\u6587\u4ef6\u4f4d\u7f6e\uff0c\u5f53\u7136\u5148\u5f97\u505c\u6b62MySQL\u670d\u52a1\u3002<br \/>\n\u8fd9\u51e0\u4e2a\u547d\u4ee4\u90fd\u662f\u5728OS\u7684root\u6743\u9650\u4e0b\u8fdb\u884c\u7684\u3002<br \/>\nmkdir -p \/usr\/local\/mysql<br \/>\ncp -afir \/var\/lib\/mysql\/* \/usr\/local\/mysql<\/p>\n<p>vim \/etc\/my.cnf<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;mysqld]\r\ndatadir=\/usr\/local\/mysql\r\nsocket=\/usr\/local\/mysql\/mysql.sock\r\ndefault-character-set=utf8\r\nuser=mysql\r\n# Disabling symbolic-links is recommended to prevent assorted security risks\r\nsymbolic-links=0\r\n\r\n&#x5B;mysqld_safe]\r\nlog-error=\/var\/log\/mysqld.log\r\npid-file=\/var\/run\/mysqld\/mysqld.pid\r\n\r\n&#x5B;mysql]\r\ndefault-character-set=utf8\r\n<\/pre>\n<p>vim \/etc\/init.d\/mysqld<br \/>\ndatadir=\/usr\/local\/mysql<\/p>\n<p>\u542f\u52a8MySQL\uff0c\u5e76\u767b\u5f55\u8bd5\u8bd5\u3002<br \/>\nmysql -h 127.0.0.1 -P 3306 -u root -p<br \/>\n\u6216\u8005\u7528<br \/>\nmysql -u root -p<br \/>\n\u6765\u767b\u5f55<\/p>\n<p>\u6700\u540e\u8fd8\u662f\u521b\u5efa\u4e00\u4e2a\u8f6f\u94fe\u63a5\uff0c\u4e3b\u8981\u662f\u540e\u9762PHP\u7a0b\u5e8f\u8fde\u8fc7\u6765\u7684\u65f6\u5019\u662f\u627e\u7684\u9ed8\u8ba4\u8fd9\u4e2a\u5730\u65b9(\/var\/lib\/mysql\/mysql.sock)<br \/>\n[root@Knight-on-the-Cloud mysql]# mkdir -p \/var\/lib\/mysql\/<br \/>\n[root@Knight-on-the-Cloud mysql]# ln -s \/usr\/local\/mysql\/mysql.sock \/var\/lib\/mysql\/mysql.sock<\/p>\n<p>\u5982\u679c\u6570\u636e\u5e93\u80fd\u542f\u52a8\uff0c\u770b\u770b\/var\/log\/mysqld.log\u91cc\u9762\u65e5\u5fd7\u90fd\u6b63\u5e38\u7684\u8bdd\uff0c\u8fd9\u6b65\u5c31\u5e94\u8be5\u597d\u4e86\u3002<\/p>\n<p>\u5b89\u88c5Nginx<br \/>\nhttps:\/\/www.digitalocean.com\/community\/articles\/how-to-compile-nginx-from-source-on-an-centos-6-4-x64-vps<br \/>\n\u7f16\u8bd1\u53c2\u6570\u5982\u4e0b<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n.\/configure \\\r\n--user=nginx                          \\\r\n--group=nginx                         \\\r\n--prefix=\/etc\/nginx                   \\\r\n--sbin-path=\/usr\/sbin\/nginx           \\\r\n--conf-path=\/etc\/nginx\/nginx.conf     \\\r\n--pid-path=\/var\/run\/nginx.pid         \\\r\n--lock-path=\/var\/run\/nginx.lock       \\\r\n--error-log-path=\/var\/log\/nginx\/error.log \\\r\n--http-log-path=\/var\/log\/nginx\/access.log \\\r\n--with-http_gzip_static_module        \\\r\n--with-http_stub_status_module        \\\r\n--with-http_ssl_module                \\\r\n--with-pcre                           \\\r\n--with-file-aio                       \\\r\n--with-http_realip_module             \\\r\n--without-http_scgi_module            \\\r\n--without-http_uwsgi_module           \\\r\n--without-http_fastcgi_module\r\n<\/pre>\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u5f04\u597d\u8fd9\u4e9b\u542f\u52a8\u7684\u8bdd\uff0c\u53d1\u73b0<br \/>\nnginx: [emerg] unknown directive &#8220;fastcgi_pass&#8221;<br \/>\nnginx\u4e0d\u8981\u5e26\u8fd9\u4e2a\u53c2\u6570&#8211;without-http_fastcgi_module\u7f16\u8bd1\uff0c\u8fd9\u6837\u5c31\u8868\u793aNginx\u96c6\u6210\u4e86fastCGI\u7684\u529f\u80fd\uff0c\u4e5f\u5c31\u4e0d\u9700\u8981\u4f7f\u7528spawn-fcgi\u7b49\u7b49\u3002<\/p>\n<p>\u914d\u7f6e\/etc\/nginx\/nginx.conf<br \/>\ntypes_hash_bucket_size 64;<br \/>\nserver_names_hash_bucket_size 128;<\/p>\n<p>\u52a0\u5165<br \/>\ninclude \/etc\/nginx\/conf.d\/*.conf;<br \/>\n\u5230\/etc\/nginx\/nginx.conf<\/p>\n<p>\u5b89\u88c5PHP<br \/>\nhttps:\/\/www.digitalocean.com\/community\/articles\/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u542f\u7528Nginx\u6216\u8005PHP\u7684fastCGI\uff0c\u5c31\u53ea\u80fd\u5b89\u88c5<br \/>\nhttp:\/\/www.lighttpd.net\/download\/spawn-fcgi-1.6.3.tar.gz<br \/>\n\u4e86\uff0c\u56e0\u4e3a\u6211\u4eec\u5728\u7f16\u8bd1Nginx\u7684\u65f6\u5019\u6709http_fastcgi_module\uff0c\u6240\u4ee5\u5c31\u4e0d\u9700\u8981\u8fd9\u4e2a\u4e86<\/p>\n<p>Nginx\u51fa\u73b0403\uff0c<br \/>\n\u539f\u56e0http:\/\/www.linuxidc.com\/Linux\/2013-06\/85625.htm<\/p>\n<p>vim \/etc\/nginx\/nginx.conf<br \/>\nuser  guohai;<\/p>\n<p>root     18137  0.0  0.2  44552  1092 ?        Ss   13:30   0:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf<br \/>\nguohai   18139  0.0  0.3  44956  1708 ?        S    13:30   0:00 nginx: worker process<br \/>\nguohai   18140  0.0  0.3  44956  1708 ?        S    13:30   0:00 nginx: worker process<br \/>\nguohai   18141  0.0  0.3  44956  1680 ?        S    13:30   0:00 nginx: worker process<br \/>\nguohai   18142  0.0  0.3  44956  1692 ?        S    13:30   0:00 nginx: worker process       <\/p>\n<p>\u8bbf\u95ee\u76ee\u5f55\u6743\u9650<br \/>\n[guohai@Knight-on-the-Cloud html]$ ls -l<br \/>\ntotal 4<br \/>\ndrwxrwxr&#8211; 2 guohai guohai 4096 Nov 27 11:07 guoh.ai<\/p>\n<p>[guohai@Knight-on-the-Cloud guoh.ai]$ ls -l<br \/>\ntotal 8<br \/>\n-rw-rw-r&#8211; 1 guohai guohai   0 Nov 27 13:37 hello.txt<br \/>\n-rw-rw-r&#8211; 1 guohai guohai 612 Nov 27 11:33 index.html<br \/>\n-rw-rw-r&#8211; 1 guohai guohai 617 Nov 27 11:05 info.php<\/p>\n<p>PHP\u9875\u9762\u51fa\u73b0\uff0c<br \/>\n404, No input file specified.<br \/>\nvim \/etc\/php-fpm.d\/www.conf<br \/>\nUnix user\/group of processes\u91cc\u9762\u7528\u6237\u548c\u7ec4\u63a7\u5236\u7684\u548c\u6240\u9700\u8981\u8bbf\u95ee\u6587\u4ef6\u5c5e\u4e8e\u540c\u4e00\u4e2a\u7528\u6237\u548c\u7ec4\u5c31\u597d\uff0c\u6211\u8fd9\u91cc\u90fd\u6539\u6210guohai\u3002<\/p>\n<p>root     18409  0.0  0.7 125452  3952 ?        Ss   15:09   0:00 php-fpm: master process (\/etc\/php-fpm.conf)<br \/>\nguohai   18410  0.0  1.0 126088  5208 ?        S    15:09   0:00 php-fpm: pool www<br \/>\nguohai   18411  0.0  1.0 125972  5216 ?        S    15:09   0:00 php-fpm: pool www<br \/>\nguohai   18412  0.0  0.8 125972  4136 ?        S    15:09   0:00 php-fpm: pool www<br \/>\nguohai   18413  0.0  0.8 125452  4124 ?        S    15:09   0:00 php-fpm: pool www<br \/>\nguohai   18414  0.0  1.0 126088  5208 ?        S    15:09   0:00 php-fpm: pool www<\/p>\n<p>\u6240\u4ee5\u8fd9\u4e24\u4e2a<strong>\u8be1\u5f02\u7684\u95ee\u9898\u90fd\u662f\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<p>\u4e5f\u5c31\u662f\u6211\u4eec\u8fd9\u91ccNginx\u548cPHP\u7684\u8fd0\u884c\u7528\u6237\u90fd\u662fguohai\uff0c\u6587\u4ef6\u6240\u5c5e\u4e5f\u90fd\u662fguohai\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u4efb\u4f55\u95ee\u9898\u4e86(Nginx\u6216\u8005PHP\u7684master process\u90fd\u662f\u8fd0\u884c\u5728daemon\u5f53\u4e2d\uff0c\u6240\u4ee5\u8fd9\u91cc\u662froot)\uff0c\u5f53\u7136\u53ef\u80fd\u6b63\u5f0f\u670d\u52a1\u5668\u4e0a\u5e94\u8be5\u90e8\u7f72\u5728www\u8fd9\u79cd\u6743\u9650\u6bd4\u8f83\u5c11\u7684\u7528\u6237\u4e0b\u9762\u3002<\/p>\n<p>\u6211\u8fd9\u91cc\u662f\u8fc1\u79fb\u5de5\u4f5c\uff0c\u6240\u4ee5\u6570\u636e\u5e93\u548c\u7a0b\u5e8f\u6587\u4ef6\u6211\u90fd\u6709\u5bfc\u5165\u51fa\u6765\uff0c\u73b0\u5728\u53ea\u9700\u8981\u5bfc\u5165\u6570\u636e\u5e93\uff0c\u628a\u6587\u4ef6\u653e\u5230\u6307\u5b9a\u7684\u76ee\u5f55\u5c31\u597d\u3002\u5982\u679c\u662f\u5168\u65b0\u5b89\u88c5\u7684\u8bdd\uff0c\u53ea\u8981\u521b\u5efa\u597d\u6570\u636e\u5e93\u548c\u7528\u6237\u5c31\u597d\uff0c\u5b89\u88c5WP\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u751f\u6210\u6570\u636e\u5e93\u3002<br \/>\n\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nCREATE DATABASE wp_db;\r\nCREATE USER wp_user@localhost;\r\nSET PASSWORD FOR wp_user@localhost= PASSWORD(&quot;YOUR_STRONG_PASSWORD&quot;);\r\nGRANT ALL PRIVILEGES ON wp_db.* TO wp_user@localhost IDENTIFIED BY &#039;YOUR_STRONG_PASSWORD&#039;;\r\nFLUSH PRIVILEGES;\r\n<\/pre>\n<p>\u5f53\u7136\u4f60\u5982\u679c\u719f\u6089MySQL\u7684\u8bdd\uff0c\u53ef\u4ee5\u7ec6\u5206\u6743\u9650\uff0c\u7ed9\u591f\u5c31\u884c\u4e86\u3002<\/p>\n<p>https:\/\/www.digitalocean.com\/community\/articles\/how-to-install-wordpress-with-nginx-on-centos-6&#8211;2<\/p>\n<p>WordPress\u5728Nginx\u4e0a\u5f00\u542f\u56fa\u5b9a\u94fe\u63a5(permalinks)\uff0c\u53c2\u89c1\u7684\u662fhttp:\/\/blog.dighost.me\/archives\/3233.html\uff0c\u7f51\u7edc\u4e0a\u5f88\u591a\u65b9\u6cd5\u90fd\u4e0d\u6210\u529f\uff0c\u4e0d\u77e5\u9053\u5230\u5e95\u662f\u5bf9\u89c6\u9519\uff0c\u6211\u7684\u662fWP\u653e\u5728\u5b50\u76ee\u5f55(lifelog)\u4e0b\u9762\uff0c\u6240\u4ee5<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n    location \/ {\r\n        index index.php  index.html index.htm;\r\n        try_files $uri $uri\/ \/index.php?$args;\r\n#       try_files and rewrite, which is better?\r\n#        if (-f $request_filename\/index.html) {\r\n#            rewrite (.*) $1\/index.html break;\r\n#        }\r\n#        if (-f $request_filename\/index.php) {\r\n#            rewrite (.*) $1\/index.php;\r\n#        }\r\n#        if (!-f $request_filename) {\r\n#            rewrite (.*) \/index.php;\r\n#        }\r\n    }\r\n\r\n    location \/lifelog\/ {\r\n        index index.php  index.html index.htm;\r\n        try_files $uri $uri\/ \/lifelog\/index.php?$args;\r\n    }\r\n<\/pre>\n<p>\u4e5f\u5c31\u662f\u6211\u53ea\u4fee\u6539\u4e86location \/lifelog\/\u7684\u5185\u5bb9\uff0c\u5e76\u4e14index\u540e\u9762\u6709\u8fd9\u4e48\u591a\uff0c\u90e8\u5206\u4eba\u53ea\u653e\u4e86index.php\uff0c\u4f46\u662f\u6211\u8fd9\u6837\u5c31\u4f1a\u51fa\u73b0404\uff0c\u5982\u679c\u5199\u5168\u5c31\u80fd\u5de5\u4f5c\uff0c\u6240\u4ee5\u3002\u3002\u3002<\/p>\n<p>\u6240\u6709\u4e1c\u897f\u90fd\u5f04\u597d\u4e4b\u540e\uff0c\u7136\u540e\u53ef\u4ee5\u9690\u85cf\u6389Nginx\/PHP\u7248\u672c\u53f7\uff0c\u907f\u514d\u8f6f\u4ef6\u6f0f\u6d1e\u51fa\u73b0\u540e\uff0c\u653b\u51fb\u8005\u5f88\u5bb9\u6613\u77e5\u9053\u4f60\u7684\u7cfb\u7edf\u8f6f\u4ef6\u7248\u672c\uff0c\u7136\u540e\u76f4\u63a5\u62ff\u4e0b\u4f60\u7684\u673a\u5668\uff0c\u4e0d\u8fc7\u6211\u8fd9\u53f0\u673a\u5668\u5e94\u8be5\u6ca1\u6709\u4eba\u611f\u5174\u8da3\u3002<br \/>\n\u53c2\u89c1http:\/\/wangye.org\/blog\/archives\/352\/<br \/>\n\u5206\u522b\u5728\/etc\/nginx\/nginx.conf\u589e\u52a0<br \/>\nhttp {<br \/>\n    # &#8230;\u7701\u7565\u4e00\u4e9b\u914d\u7f6e<br \/>\n    server_tokens off;<br \/>\n  }<\/p>\n<p>\u5728\/etc\/php.ini\u5173\u95edexpose_php\uff0c\u5373\u4fee\u6539\u4e3a<br \/>\nexpose_php = Off<br \/>\n\u6216\u8005\u4f60\u81ea\u5df1\u7f16\u8bd1\u6e90\u7801\uff0c\u5c3d\u91cf\u9690\u85cf\u6389\u4f60\u4e0d\u60f3\u8ba9\u522b\u4eba\u770b\u5230\u7684\u4fe1\u606f\u3002<\/p>\n<p>P.S.<br \/>\n\u8fd0\u884c\u4e86\u51e0\u4e2a\u5c0f\u65f6\uff0c\u53d1\u73b0\u6709\u65f6\u5019\u8fd8\u662f\u4f1a\u6709404\uff0c\u5148\u7528\u7528\u770b\u6709\u6ca1\u6709\u4ec0\u4e48\u6bd4\u8f83\u4e25\u91cd\u7684\u95ee\u9898\uff0c\u5907\u4efd\u5f88\u91cd\u8981\uff0c\u6709\u7a7a\u6765\u5199\u51e0\u4e2a\u811a\u672c\u53bb\u5b9a\u65f6\u5bfc\u51fa\u548c\u6253\u5305\u6570\u636e\u5e93\u548c\u6587\u4ef6\u3002<br \/>\n\u9700\u8981\u6ce8\u518c\u7684\u540c\u5b66\u53ef\u4ee5\u4f7f\u7528<a href=\"https:\/\/www.digitalocean.com\/?refcode=7340d6d347a6\" target=\"_blank\">https:\/\/www.digitalocean.com\/?refcode=7340d6d347a6<\/a>\u8fd9\u4e2a\u4f18\u60e0\u7801\uff0c\u4f60\u597d\u6211\u4e5f\u597d\uff0c\u54c8\u54c8\u54c8 \/\u5077\u7b11<\/p>\n<p>\u8dd1\u4e86\u4f1a\u513f\u5c31\u89c9\u5f97\u7ad9\u70b9\u53cd\u5e94\u6162\uff0c\u770b\u4e86\u4e0b<br \/>\ntop\u53d1\u73b0CPU\u5f88\u7a7a\uff0cMemory\u51e0\u4e4e\u6ee1\u6389\u4e86<br \/>\nps -A &#8211;sort -rss -o comm,pmem,pcpu | uniq -c | head -15<br \/>\n\u53d1\u73b0php-fpm\u5360\u4e86\u5f88\u591a\u5185\u5b58<br \/>\nps aux | grep php-fpm<br \/>\n\u7f51\u4e0a\u641c\u4e86\u4e0b\uff0c\u9047\u5230php-fpm\u5f00\u7684\u591a\u7684\u4eba\u5f88\u591a\uff0c\u800c\u6bcf\u4e2aphp-fpm\u8fdb\u7a0b\u5927\u7ea6\u5360\u752820M\u5de6\u53f3\u7684\u5185\u5b58\uff0c\u6240\u4ee5\u5185\u5b58\u5f88\u5feb\u5c31\u4f1a\u8017\u5149\u4e86<br \/>\nhttp:\/\/www.perfgeeks.com\/?p=599<br \/>\nhttp:\/\/www.ha97.com\/4339.html<br \/>\n\u8fd9\u4e24\u7bc7\u535a\u5ba2\u89e3\u91ca\u4e86php-fpm\u7684\u5de5\u4f5c\u65b9\u5f0f\uff0c\u6211\u8fd9\u91cc\u662f\u52a8\u6001\u7684\uff0c\u7136\u540e\u6211\u8fd9\u91ccVPS\u7684\u5185\u5b58\u6bd4\u8f83\u5c0f\uff0c\u800cmax_spare_servers\u9ed8\u8ba4\u662f35\u4e2a\uff0c\u6240\u4ee5\u5c31\u4f1a\u8017\u975e\u5e38\u591a\u7684\u5185\u5b58\uff0c\u4e8e\u662f\u6211\u5c1d\u8bd5\u5c06\u8fd9\u4e2a\u503c\u6539\u5c0f\u3002<br \/>\nvim \/etc\/php-fpm.d\/www.conf<br \/>\n\u4fee\u6539pm.max_spare_servers<br \/>\n\u518d\u8dd1\u8dd1\u770b\u3002<\/p>\n<p>P.P.S. \u96be\u9053\u4e3a\u4e86\u641e\u4e2aVPS\u642d\u4e2a\u5c0f\u7ad9\uff0c\u8fd8\u8981\u903c\u6211\u5b66\u4e60\u5982\u4f55\u8c03\u4f18Nginx\/PHP\/MySQL\uff1f\u7a81\u7136\u53d1\u73b0\u8fd8\u662f\u6211\u90a3\u4e2a40\u4eba\u6c11\u5e01\/\u5e74\u7684\u7a7a\u95f4\u6bd4\u8f83\u597d\uff0cping\u503c\u4e5f\u4f4e\uff0c\u4e5f\u6ca1\u6709\u8fd9\u4e48\u591a\u4e8b\uff0c\u53ef\u60dc\u5b83\u7ecf\u5e38\u4e0d\u51fa\u58f0\u54cd\u7684\u5c31\u5904\u4e8e\u7ef4\u62a4\u72b6\u6001\uff0c\u8ba9\u4eba\u6bd4\u8f83\u5934\u75bc\u3002\u7528\u4e86\u8fd9\u4e2aVPS\uff0c\u73b0\u5728\u5982\u679c\u574f\u4e86\u5f97\u81ea\u5df1\u4fee\u4e86\u3002\u3002\u3002<\/p>\n<p>P.P.P.S \u53d1\u73b0\u8fd9\u4e8b\u505c\u4e0d\u4e0b\u6765\u4e86<br \/>\n\u4e00\u4e9bNginx\u7b80\u5355\u7684\u914d\u7f6e<br \/>\nvim \/etc\/nginx\/nginx.conf<\/p>\n<p>Nginx\u4e0a\u5f00\u542fgzip\u9009\u9879<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n    gzip  on;\r\n    gzip_min_length 1k;\r\n    gzip_buffers 4 16k;\r\n    gzip_http_version 1.0;\r\n    gzip_comp_level 2;\r\n    gzip_types text\/plain application\/x-javascript text\/css application\/xml;\r\n    gzip_vary on;\r\n    gzip_disable &quot;MSIE &#x5B;1-6]\\.&quot;;\r\n<\/pre>\n<p>\u53ef\u4ee5\u7528curl\u547d\u4ee4\u6d4b\u8bd5\u4e0b\u662f\u5426\u8bbe\u7f6e\u751f\u6548<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -I guoh.ai\/lifelog\/ -H Accept-Encoding:gzip,defalte \/\/ \u6307\u5b9aHead\u63a5\u6536\u7f16\u7801\u4fe1\u606f\r\ncurl -A &quot;Mozilla\/4.0 (compatible; MSIE 6.0; Windows NT 5.0)&quot; -I guoh.ai\/lifelog\/ -H Accept-Encoding:gzip,defalte \/\/ \u6307\u5b9a\u4ee3\u7406\u4e3a\u67d0\u79cd\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u7528\u4efb\u610f\u503c\u6765&quot;\u6b3a\u9a97&quot;\u670d\u52a1\u5668\r\ncurl -A &quot;Mozilla\/4.73 &#x5B;en] (X11; U; Linux 2.2.15 i686)&quot; -I guoh.ai\/lifelog\/ -H Accept-Encoding:gzip,defalte\r\n<\/pre>\n<p>\u914d\u7f6e\u9759\u6001\u6587\u4ef6\u8d85\u65f6\u65f6\u95f4(\u8fd9\u6bb5\u9759\u6001\u6587\u4ef6\u8d85\u65f6\u7684\u914d\u7f6e\u6587\u4ef6\u662f\u9519\u7684\uff0c\u53c2\u89c12015\/01\/25 UPDATE\u90e8\u5206)<br \/>\n<del datetime=\"2015-01-25T12:28:07+00:00\"><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n    location ~* .(ico|gif|bmp|jpg|jpeg|png|swf|js|css|mp3) {\r\n        expires 30d;\r\n    }\r\n<\/pre>\n<p><\/del><\/p>\n<p>Nginx Proxy Cache\u5982\u679c\u6709\u9700\u8981\u7684\u8bdd\uff0c\u518d\u6765\u7814\u7a76\u3002<br \/>\nhttp\u6bb5\u91cc\u9762\u6dfb\u52a0<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nproxy_connect_timeout 10;\r\nproxy_read_timeout 180;\r\nproxy_send_timeout 5;\r\nproxy_buffer_size 16k;\r\nproxy_buffers 4 64k;\r\nproxy_busy_buffers_size 256k;\r\nproxy_temp_file_write_size 256k;\r\nproxy_temp_path \/tmp\/temp_dir;\r\nproxy_cache_path \/tmp\/cache levels=1:2 keys_zone=cache_one:100m inactive=1d max_size=10g;\r\n<\/pre>\n<p>server\u6bb5\u91cc\u9762\u6dfb\u52a0<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nlocation ~ .*\\.(gif|jpg|png|css|js)(.*) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_pass http:\/\/appserver ;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_redirect off;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_set_header Host $host;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_cache cache_one;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_cache_valid 200 302 24h;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_cache_valid 301 30d;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0proxy_cache_valid any 5m;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0expires 90d;\r\n}\r\n<\/pre>\n<p>WP\u63d2\u4ef6\u6709\u5173<br \/>\n\u987a\u624b\u628aSyntaxHighlighter\u505a\u4e86\u4e9b\u8c03\u6574\uff0c\u9009\u7528\u7b2c\u4e09\u7248\uff0c\u8c03\u6574\u4e86\u4e0b\u5b83\u7684\u9694\u884c\u53d8\u8272\u4ee5\u53ca\u9ad8\u4eae\u884c\u989c\u8272<br \/>\nvim lifelog\/wp-content\/plugins\/syntaxhighlighter\/syntaxhighlighter3\/styles\/shThemeDefault.css<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n.syntaxhighlighter .line.alt1 {\r\n  background-color: white !important;\r\n}\r\n.syntaxhighlighter .line.alt2 {\r\n  background-color: #EEE !important;\r\n}\r\n.syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {\r\n  background-color: #FFFF00 !important;\r\n}\r\n<\/pre>\n<p>2015\/01\/25 UPDATE:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n2015\/01\/25 11:01:17 &#x5B;error] 1265#0: *5 &quot;\/path\/to\/guoh.ai\/lifelog\/2013\/09\/nanojpeg-a-compact-jpeg-decoder\/index.html&quot; is not found (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: guoh.ai, request: &quot;GET \/lifelog\/2013\/09\/nanojpeg-a-compact-jpeg-decoder\/ HTTP\/1.1&quot;, host: &quot;guoh.ai&quot;, referrer: &quot;http:\/\/guoh.ai\/lifelog\/?s=jpeg&quot;\r\n<\/pre>\n<p>\u53d1\u73b0\u535a\u5ba2\u6709\u51e0\u7bc7\u6587\u7ae0\u4e00\u76f4\u62a5\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ee5\u524d\u4e00\u76f4\u90fd\u4e0d\u77e5\u9053\u4ec0\u4e48\u539f\u56e0\uff0c\u6ca1\u5565\u65f6\u95f4\u6765\u7814\u7a76\u8fd9\u4e2a\uff0c\u4e8e\u662f\u4e00\u653e\u5c31\u653e\u4e86\u4e00\u5e74\u591a\uff0c\u524d\u51e0\u5929\u628aWP\u5347\u7ea7\u4e86\u4e0b(\u6000\u7740\u4fa5\u5e78\u7684\u5fc3\u7406\u4f1a\u4fee\u590d\u8fd9\u4e2abug\uff0c\u5e76\u4e14\u4f3c\u4e4e\u5347\u7ea7\u4e4b\u540e\u7b2c\u4e00\u6b21\u771f\u7684\u80fd\u8bbf\u95ee\u6216\u8005\u8fd8\u662f\u6211\u5e7b\u89c9\u4e86\uff0c\u603b\u4e4b\u5c31\u6ca1\u7ba1\u4e86)\uff0c\u4eca\u5929\u51c6\u5907\u6765\u4fee\u590d\u53e6\u5916\u4e00\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\u53c8\u53d1\u73b0\u95ee\u9898\u590d\u73b0\u4e86\uff0c\u770b\u4e86\u4f1a\u513f\u4e0d\u77e5\u9053\u662f\u8111\u5b50\u54ea\u6839\u7ebf\u8def\u8fde\u4e0a\u4e86\uff0c\u7a81\u7136\u6000\u7591\u5230\u662fURL\u5f53\u4e2d\u5305\u542bjpeg\u5c31\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\uff0c\u4e8e\u662f\u8bd5\u4e86\u4e0b\u679c\u771f\u5305\u542bjpeg\u7684\u5c31\u6709\u95ee\u9898\uff0c\u679c\u65ad\u731c\u60f3\u914d\u7f6e\u6587\u4ef6\u5199\u7684\u6709\u95ee\u9898\uff0c\u641c\u4e86\u4e0b\u914d\u7f6e\u6587\u4ef6\u5f53\u4e2d\u5305\u542bjpeg\u7684\u90e8\u5206\uff0c\u5c31\u53ea\u6709\u9759\u6001\u6587\u4ef6\u8d85\u65f6\u914d\u7f6e\u7684\u90e8\u5206\u5305\u542bjpeg\uff0c\u4e8e\u662f\u4fee\u6539\u4e86\u4e0b\uff0c\u53d1\u73b0\u95ee\u9898\u6d88\u5931\u4e86\uff0c\u8bd5\u4e86\u591a\u6b21\u786e\u8ba4\u5c31\u662f\u8fd9\u91cc\u3002\u6b63\u786e\u7684\u914d\u7f6e\u5982\u4e0b(\u6ce8\u610f\u548c\u539f\u6765\u7684\u5dee\u522b)\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n    location ~ .*\\.(ico|gif|bmp|jpg|jpeg|png|swf|js|css|mp3) {\r\n        expires 30d;\r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u641c\u4e86\u4e0b\u636e\u8bf4\u6027\u4ef7\u6bd4\u8fd8\u53ef\u4ee5\u7684VPS\uff0c\u4f3c\u4e4e\u6211\u5728\u4e0a\u6d77ping\u503c\u5f88\u9ad8\uff0c\u7528\u7528\u770b\u5427(\u53ef\u4ee5\u6309\u5c0f\u65f6\u4ed8\u8d39)\u3002 \u6ce8\u518c\u8d26\u53f7\uff0c\u521b\u5efaVPS\uff0c\u62ff\u5230root\u7528\u6237 ssh root@162.243.117.95 \u521b\u5efa\u5e38\u7528\u8d26\u6237 ssh guohai@162.243.117.95 \u62ff\u5230\u4e4b\u540e\u5f53\u7136\u5148\u88c5\u4e9b\u57fa\u7840\u7684\u8f6f\u4ef6\uff0c\u6bd4\u5982FTP\u670d\u52a1\uff0cSSL\u7b49\u7b49\uff0c\u8fd9\u4e2a\u770b\u81ea\u5df1\u7684\u7231\u597d\u3002 \u6478\u51fa\u6211\u5f53\u5e74\u505a\u5404\u79cdMIS\u7684\u7ecf\u9a8c\uff0c\u4ec0\u4e48Nginx\/MySQL\/PHP\uff0c\u4e0d\u8fc7PHP\u6211\u4e4b\u524d\u6ca1\u6709\u5f04\u8fc7\uff0c\u7167\u7740\u7f51\u7edc\u4e0a\u7b80\u5355\u7684\u641e\u641e\u3002 [root@Knight-on-the-Cloud ~]# yum -y install vsftpd \u53c2\u7167 http:\/\/my.oschina.net\/u\/130017\/blog\/15229 \u57fa\u7840\u914d\u7f6e local_enable=YES ascii_upload_enable=YES ascii_download_enable=YES write_enable=YES \u7136\u540e\u5c31\u662fMySQL [root@Knight-on-the-Cloud log]# yum -y install mysql-server [root@Knight-on-the-Cloud log]# service mysqld start Initializing MySQL database: WARNING: The host &#8216;Knight-on-the-Cloud&#8217; could not be looked up with resolveip. This probably means that your libc libraries &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2013\/11\/migrating-site-to-digital-ocean\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u8fc1\u79fb\u535a\u5ba2\u5230Digital Ocean<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-862","post","type-post","status-publish","format-standard","hentry","category-misc"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":9,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":944,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/862\/revisions\/944"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}