{"id":196,"date":"2016-05-27T21:27:49","date_gmt":"2016-05-27T13:27:49","guid":{"rendered":"http:\/\/www.zhuyanbin.com\/?p=196"},"modified":"2016-12-09T22:05:56","modified_gmt":"2016-12-09T14:05:56","slug":"%e5%a6%82%e4%bd%95%e6%ad%a3%e7%a1%ae%e5%8f%91%e5%b8%83php%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.yanbin888.com\/?p=196","title":{"rendered":"\u5982\u4f55\u6b63\u786e\u53d1\u5e03PHP\u4ee3\u7801"},"content":{"rendered":"<p>\u51e0\u4e4e\u6bcf\u4e00\u4e2a PHP \u7a0b\u5e8f\u5458\u90fd\u53d1\u5e03\u8fc7\u4ee3\u7801\uff0c\u53ef\u80fd\u662f\u901a\u8fc7 ftp \u6216\u8005 rsync \u540c\u6b65\u7684\uff0c\u4e5f\u53ef\u80fd\u662f\u901a\u8fc7 svn \u6216\u8005 git \u66f4\u65b0\u7684\u3002\u4e00\u4e2a\u6d3b\u8dc3\u7684\u9879\u76ee\u53ef\u80fd\u6bcf\u5929\u90fd\u8981\u53d1\u5e03\u82e5\u5e72\u6b21\u4ee3\u7801\uff0c\u4f46\u662f\u73b0\u5b9e\u5374\u662f\u5f88\u5c11\u6709\u4eba\u6ce8\u610f\u5176\u4e2d\u7684\u7ec6\u8282\uff0c\u5b9e\u9645\u4e0a\u8fd9\u91cc\u9762\u6709\u597d\u591a\u5751\uff0c\u5f88\u53ef\u80fd\u4f60\u5c31\u5728\u5751\u4e2d\u5374\u6d51\u7136\u4e0d\u77e5\u3002<\/p>\n<p>\u4e00\u4e2a\u6b63\u786e\u5b9e\u73b0\u7684\u53d1\u5e03\u7cfb\u7edf\u81f3\u5c11\u5e94\u8be5\u652f\u6301\u539f\u5b50\u53d1\u5e03\u3002\u5982\u679c\u8bf4\u6bcf\u4e00\u4e2a\u7248\u672c\u90fd\u8868\u793a\u4e00\u4e2a\u72ec\u7acb\u7684\u72b6\u6001\u7684\u8bdd\uff0c\u90a3\u4e48\u5728\u53d1\u5e03\u671f\u95f4\uff0c\u4efb\u4f55\u4e00\u6b21\u8bf7\u6c42\u53ea\u80fd\u5728\u5355\u4e00\u72b6\u6001\u4e0b\u88ab\u6267\u884c\u3002\u5982\u6b64\u79f0\u4e4b\u4e3a\u652f\u6301\u539f\u5b50\u53d1\u5e03\uff1b\u53cd\u4e4b\u5982\u679c\u5728\u53d1\u5e03\u671f\u95f4\uff0c\u4e00\u6b21\u8bf7\u6c42\u8de8\u8d8a\u4e0d\u540c\u7684\u72b6\u6001\uff0c\u90a3\u4e48\u5c31\u4e0d\u80fd\u79f0\u4e4b\u4e3a\u539f\u5b50\u53d1\u5e03\u3002\u6211\u4eec\u4e0d\u59a8\u4e3e\u4e2a\u4f8b\u5b50\u6765\u8bf4\u660e\u4e00\u4e0b\uff1a\u5047\u8bbe\u4e00\u6b21\u8bf7\u6c42\u9700\u8981 include \u4e24\u4e2a PHP \u6587\u4ef6\uff0c\u5206\u522b\u662f a.php \u548c b.php\uff0c\u5f53 include a.php \u5b8c\u6210\u540e\uff0c\u53d1\u5e03\u4ee3\u7801\uff0c\u63a5\u7740 include b.php\uff0c\u5982\u679c\u5904\u7406\u4e0d\u5f53\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u65e7\u7248\u672c\u7684 a.php \u548c\u65b0\u7248\u672c\u7684 b.php \u540c\u65f6\u5b58\u5728\u4e8e\u540c\u4e00\u4e2a\u8bf7\u6c42\u4e4b\u4e2d\uff0c\u6362\u53e5\u8bdd\u8bf4\u5c31\u662f\u6ca1\u6709\u5b9e\u73b0\u539f\u5b50\u53d1\u5e03\u3002<\/p>\n<p>\u5f00\u6e90\u4e16\u754c\u91cc\u6709\u5f88\u591a\u4e0d\u9519\u7684\u53d1\u5e03\u4ee3\u7801\u5de5\u5177\uff0c\u6bd4\u5982 ruby \u793e\u533a\u7684 <a href=\"http:\/\/capistranorb.com\/\">capistrano<\/a>\uff0c\u5176\u6d41\u7a0b\u5927\u81f4\u5c31\u662f\u53d1\u5e03\u4ee3\u7801\u5230\u4e00\u4e2a\u5168\u65b0\u7684\u76ee\u5f55\uff0c\u7136\u540e\u518d\u8f6f\u94fe\u63a5\u5230\u771f\u6b63\u7684\u53d1\u5e03\u76ee\u5f55\u3002<\/p>\n<pre>.\r\n\u251c\u2500\u2500 current -&gt; releases\/v1\r\n\u2514\u2500\u2500 releases\r\n    \u251c\u2500\u2500 v1\r\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 foo.php\r\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 bar.php\r\n    \u2514\u2500\u2500 v2\r\n        \u251c\u2500\u2500 foo.php\r\n        \u2514\u2500\u2500 bar.php<\/pre>\n<p>\u4e0d\u8fc7\u9274\u4e8e PHP \u672c\u8eab\u7684\u7279\u6b8a\u6027\uff0c\u5982\u679c\u53ea\u662f\u7b80\u5355\u5957\u7528\u4e0a\u9762\u7684\u6d41\u7a0b\uff0c\u90a3\u4e48\u5c06\u5f88\u96be\u5b9e\u73b0\u771f\u6b63\u7684\u539f\u5b50\u53d1\u5e03\u3002\u8981\u7406\u6e05\u4e2a\u4e2d\u7f18\u7531\uff0c\u8fd8\u9700\u8981\u4e86\u89e3\u4e00\u4e0b PHP \u4e2d\u7684\u4e24\u4e2a\u00a0Cache \u7684\u6982\u5ff5\uff1a<\/p>\n<ul>\n<li>opcode cache<\/li>\n<li>realpath cache<\/li>\n<\/ul>\n<p>\u5148\u804a\u804a opcode cache\uff0c\u65e9\u5148\u5927\u5bb6\u4e00\u76f4\u7528\u00a0apc\uff0c\u73b0\u5728\u591a\u534a\u9009\u62e9 zend opcode\uff0c\u5173\u4e8e\u5b83\u7684\u4f5c\u7528\uff0c\u5927\u5bb6\u90fd\u5df2\u7ecf\u5f88\u719f\u6089\uff0c\u4e0d\u5fc5\u591a\u8a00\uff0c\u552f\u4e00\u9700\u8981\u6ce8\u610f\u7684\u662f apc \u548c zend opcode \u5bf9\u7f13\u5b58\u952e\u7684\u9009\u62e9\u6709\u6240\u5dee\u5f02\uff1aapc \u9009\u62e9\u7684\u662f\u6587\u4ef6\u7684 inode\uff0czend opcode \u9009\u62e9\u7684\u662f\u6587\u4ef6\u7684 path\u3002<\/p>\n<p>\u518d\u804a\u804a realpath cache\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u7f13\u51b2\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\u7684 IO \u64cd\u4f5c\uff0c\u5927\u591a\u6570\u65f6\u5019\u5b83\u5bf9\u6211\u4eec\u800c\u8a00\u662f\u900f\u660e\u7684\uff0c\u4ee5\u81f3\u4e8e\u5f88\u591a\u4eba\u90fd\u4e0d\u77e5\u9053\u5b83\u7684\u5b58\u5728\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f realpath cache \u662f\u8fdb\u7a0b\u7ea7\u522b\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6bcf\u4e00\u4e2a php-fpm \u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u72ec\u7acb\u7684 realpath cache\u3002<\/p>\n<p>\u76f8\u5173\u7684\u6280\u672f\u7ec6\u8282\u7279\u522b\u7410\u788e\uff0c\u5efa\u8bae\u5927\u5bb6\u4ed4\u7ec6\u9605\u8bfb\u5982\u4e0b\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"http:\/\/jpauli.github.io\/2014\/06\/30\/realpath-cache.html\" target=\"_blank\">realpath_cache<\/a><\/li>\n<li><a href=\"http:\/\/jpauli.github.io\/2015\/03\/05\/opcache.html\" target=\"_blank\">PHP\u2019s OPCache extension review<\/a><\/li>\n<li><a href=\"https:\/\/codeascraft.com\/2013\/07\/01\/atomic-deploys-at-etsy\/\" target=\"_blank\">Atomic deploys at Etsy<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/zendtech\/ZendOptimizerPlus\/issues\/126\" target=\"_blank\">Cache invalidation for scripts in symlinked folders<\/a><\/li>\n<\/ul>\n<p>\u5728\u91c7\u7528\u8f6f\u94fe\u63a5\u53d1\u5e03\u4ee3\u7801\u7684\u65f6\u5019\uff0c\u901a\u5e38\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u95ee\u9898\u591a\u534a\u662f\u65b0\u4ee3\u7801\u4e0d\u751f\u6548\uff01\u4e0d\u7ba1\u662f\u5f00\u542f\u4e86\u00a0<a href=\"http:\/\/php.net\/manual\/en\/apc.configuration.php#ini.apc.stat\" target=\"_blank\">apc.stat<\/a> \u6216\u8005\u00a0<a href=\"http:\/\/php.net\/manual\/en\/opcache.configuration.php#ini.opcache.validate-timestamps\" target=\"_blank\">opcache.validate_timestamps<\/a>\u00a0\u914d\u7f6e\uff0c\u8fd8\u662f\u8c03\u7528\u4e86\u00a0<a href=\"http:\/\/php.net\/manual\/en\/function.apc-clear-cache.php\" target=\"_blank\">apc_clear_cache<\/a> \u6216\u8005\u00a0<a href=\"http:\/\/php.net\/manual\/en\/function.opcache-reset.php\" target=\"_blank\">opcache_reset<\/a>\u00a0\u65b9\u6cd5\uff0c\u5747\u65e0\u6548\uff0c\u91cd\u542f php-fpm \u81ea\u7136\u662f\u80fd\u591f\u89e3\u51b3\u95ee\u9898\uff0c\u4e0d\u8fc7\u5bf9\u811a\u672c\u8bed\u8a00\u6765\u8bf4\u91cd\u542f\u592a\u91cd\u4e86\uff01\u96be\u9053\u9664\u4e86\u91cd\u542f\u5c31\u6ca1\u6709\u522b\u7684\u529e\u6cd5\u4e86\u4e48\uff1f<\/p>\n<p>\u4e8b\u5b9e\u4e0a\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0\u8fd9\u6837\u7684\u95ee\u9898\uff0c\u4e3b\u8981\u662f\u56e0\u4e3a opcode cache \u662f\u901a\u8fc7 realpath cache \u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\uff0c\u5373\u4fbf\u8f6f\u94fe\u63a5\u5df2\u7ecf\u6307\u5411\u4e86\u65b0\u4f4d\u7f6e\uff0c\u4f46\u662f\u5982\u679c realpath cache \u91cc\u8fd8\u4fdd\u5b58\u7740\u65e7\u6570\u636e\u7684\u8bdd\uff0copcode cache \u4f9d\u7136\u65e0\u6cd5\u77e5\u9053\u65b0\u4ee3\u7801\u7684\u5b58\u5728\uff0c\u7f3a\u7701\u60c5\u51b5\u4e0b\uff0c<a href=\"http:\/\/php.net\/manual\/en\/ini.core.php#ini.realpath-cache-ttl\" target=\"_blank\">realpath_cache_ttl<\/a> \u7f13\u5b58\u6709\u6548\u671f\u662f\u4e24\u5206\u949f\uff0c\u8fd9\u610f\u5473\u7740\u53d1\u5e03\u4ee3\u7801\u540e\uff0c\u53ef\u80fd\u8981\u4e24\u5206\u949f\u624d\u80fd\u751f\u6548\u3002\u4e3a\u4e86\u8ba9\u53d1\u5e03\u5c3d\u5feb\u751f\u6548\uff0c\u9700\u8981\u4ee5\u8fdb\u7a0b\u4e3a\u5355\u4f4d\u6e05\u9664 realpath cache\uff1a<\/p>\n<pre>&lt;?php\r\n\r\n$key = 'php.pid_' . getmypid();\r\n\r\nif (($rev = apc_fetch($key)) != DEPLOY_VERSION) {\r\n    if($rev &lt; DEPLOY_VERSION) {\r\n        apc_store($key, DEPLOY_VERSION);\r\n    }\r\n    \r\n    clearstatcache(true);\r\n}\r\n\r\n?&gt;<\/pre>\n<p>\u5982\u6b64\u5728 apc \u73af\u5883\u4e0b\u57fa\u672c\u5c31\u80fd\u5de5\u4f5c\u4e86\uff0c\u4f46\u662f\u5728 zend opcode \u73af\u5883\u4e0b\u8fd8\u53ef\u80fd\u6709<a href=\"http:\/\/git.php.net\/?p=php-src.git;a=commit;h=16e95d91378591042c1bf4bd40dead3ef9ae975a\">\u95ee\u9898<\/a>\u3002\u56e0\u4e3a\u5728\u7f3a\u7701\u60c5\u51b5\u4e0b <a href=\"http:\/\/php.net\/manual\/en\/opcache.configuration.php#ini.opcache.revalidate-path\">opcache.revalidate_path<\/a> \u662f\u5173\u95ed\u7684\uff0c\u6b64\u65f6\u4f1a\u7f13\u5b58\u7b26\u53f7\u94fe\u63a5\u7684\u503c\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5373\u4fbf\u8f6f\u94fe\u63a5\u6307\u5411\u4fee\u6539\u4e86\uff0c\u4e5f\u6c38\u8fdc\u65e0\u6cd5\u751f\u6548\uff0c\u6240\u4ee5\u5728\u4f7f\u7528 zend opcode \u7684\u65f6\u5019\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u8f6f\u94fe\u63a5\uff0c\u89c6\u60c5\u51b5\u6700\u597d\u628a\u00a0opcache.revalidate_path \u6fc0\u6d3b\u3002<\/p>\n<p>\u5206\u6790\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e0d\u59a8\u53cd\u601d\u4e00\u4e0b\uff1a\u5728 PHP \u4e2d\u539f\u5b50\u53d1\u5e03\u4e4b\u6240\u4ee5\u662f\u4e00\u4e2a\u68d8\u624b\u7684\u95ee\u9898\uff0c\u5f52\u6839\u7ed3\u5e95\u662f\u56e0\u4e3a\u8f6f\u94fe\u63a5\u548c\u7f13\u5b58\u4e4b\u95f4\u7684\u7684\u77db\u76fe\u3002\u4e0d\u7ba1\u662f opcode cache \u8fd8\u662f realpath cache\uff0c\u90fd\u662f PHP \u56fa\u6709\u7684\u7f13\u5b58\u7279\u6027\uff0c\u57fa\u4e8e\u5ba2\u89c2\u9700\u8981\u65e0\u6cd5\u7ed5\u5f00\uff0c\u5982\u6b64\u8bf4\u6765\u662f\u5426\u6709\u529e\u6cd5\u7ed5\u5f00\u8f6f\u94fe\u63a5\uff0c\u4f7f\u5176\u6210\u4e3a\u9a6c\u5947\u8bfa\u9632\u7ebf\u5462\uff1f\u7b54\u6848\u662f nginx \u7684 <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_core_module.html#var_realpath_root\" target=\"_blank\">$realpath_root<\/a>\uff1a<\/p>\n<pre>fastcgi_param SCRIPT_FILENAME $realpath_root $fastcgi_script_name;\r\nfastcgi_param DOCUMENT_ROOT $realpath_root;<\/pre>\n<p>\u6709\u4e86 $realpath_root\uff0c\u5373\u4fbf DOCUMENT_ROOT \u76ee\u5f55\u4e2d\u542b\u6709\u8f6f\u94fe\u63a5\uff0cnginx \u4e5f\u4f1a\u628a\u8f6f\u94fe\u63a5\u6307\u5411\u7684\u771f\u6b63\u7684\u8def\u5f84\u53d1\u7ed9 PHP\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9 PHP \u800c\u8a00\uff0c\u8f6f\u94fe\u63a5\u5df2\u7ecf\u4e0d\u5b58\u5728\u4e86\uff01\u4e0d\u8fc7\u4f5c\u4e3a\u4ee3\u4ef7\uff0c\u6bcf\u4e00\u6b21\u8bf7\u6c42\uff0cnginx \u90fd\u8981\u901a\u8fc7\u76f8\u5bf9\u6602\u8d35\u7684 IO \u64cd\u4f5c\u83b7\u53d6 $realpath_root \u7684\u503c\uff0c\u901a\u8fc7 strace \u547d\u4ee4\u6211\u4eec\u80fd\u76d1\u63a7\u8fd9\u4e00\u8fc7\u7a0b\uff0c\u4e0b\u56fe\u4ece current \u5230 foo \u7684\u8fc7\u7a0b\uff1a<\/p>\n<div id=\"attachment_519\" class=\"wp-caption alignnone\">\n<p><a href=\"http:\/\/www.zhuyanbin.com\/wp-content\/uploads\/2016\/05\/1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-237\" src=\"http:\/\/www.zhuyanbin.com\/wp-content\/uploads\/2016\/05\/1.jpg\" alt=\"\" width=\"622\" height=\"135\" srcset=\"https:\/\/www.yanbin888.com\/wp-content\/uploads\/2016\/05\/1.jpg 622w, https:\/\/www.yanbin888.com\/wp-content\/uploads\/2016\/05\/1-300x65.jpg 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">realpath<\/p>\n<\/div>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u538b\u6d4b\u53d1\u73b0\u4f7f\u7528 $realpath_root \u540e\uff0c\u6027\u80fd\u4e0b\u964d\u4e86\u5927\u7ea6 5% \u5de6\u53f3\uff0c\u4e0d\u8fc7\u660e\u773c\u4eba\u4e00\u4e0b\u5c31\u80fd\u53d1\u73b0\uff0c\u867d\u7136 $realpath_root \u5bfc\u81f4\u4e86 lstat \u548c readlink \u64cd\u4f5c\uff0c\u4f46\u662f lstat \u64cd\u4f5c\u7684\u6b21\u6570\u662f\u548c\u76ee\u5f55\u6df1\u5ea6\u6210\u6b63\u6bd4\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u76ee\u5f55\u8d8a\u6df1\uff0c\u6267\u884c\u7684 lstat \u6b21\u6570\u8d8a\u591a\uff0c\u6027\u80fd\u4e0b\u964d\u4e5f\u5c31\u8d8a\u5927\u3002\u5982\u679c\u80fd\u591f\u964d\u4f4e\u53d1\u5e03\u76ee\u5f55\u7684\u6df1\u5ea6\uff0c\u90a3\u4e48\u53ef\u4ee5\u9884\u8ba1\u6027\u80fd\u4e0b\u964d\u80fd\u591f\u63a7\u5236\u5728 1% \u5de6\u53f3\u3002<\/p>\n<p>\u7ed3\u5c3e\u4ecb\u7ecd\u4e00\u4e0b\u00a0<a href=\"http:\/\/deployer.org\/\" target=\"_blank\">Deployer<\/a>\uff0c\u5b83\u662f PHP \u4e2d\u505a\u5f97\u6bd4\u8f83\u597d\u7684\u5de5\u5177\uff0c\u6709\u5f88\u591a\u7279\u8272\uff0c\u6bd4\u5982\u652f\u6301\u5e76\u884c\u53d1\u5e03\uff0c\u5177\u4f53\u6f14\u793a\u5982\u4e0b\u56fe\uff0c\u5de6\u8fb9\u662f\u4e32\u884c\uff0c\u53f3\u8fb9\u662f\u5e76\u884c\uff0c\u4f7f\u7528\u300cvvv\u300d\u80fd\u5f97\u5230\u66f4\u8be6\u7ec6\u4fe1\u606f\uff1a<\/p>\n<div id=\"attachment_516\" class=\"wp-caption alignnone\">\n<p><a href=\"http:\/\/www.zhuyanbin.com\/wp-content\/uploads\/2016\/05\/2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-238\" src=\"http:\/\/www.zhuyanbin.com\/wp-content\/uploads\/2016\/05\/2.jpg\" alt=\"\" width=\"550\" height=\"780\" srcset=\"https:\/\/www.yanbin888.com\/wp-content\/uploads\/2016\/05\/2.jpg 550w, https:\/\/www.yanbin888.com\/wp-content\/uploads\/2016\/05\/2-212x300.jpg 212w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">deploy<\/p>\n<\/div>\n<p>\u4e0d\u8fc7 Deployer \u5728\u539f\u5b50\u53d1\u5e03\u4e0a\u6709\u4e00\u70b9\u7455\u75b5\uff0c\u5177\u4f53\u89c1 deploy:release \u4ee3\u7801\uff1a<\/p>\n<pre>&lt;?php\r\n\r\nrun(\"cd {{deploy_path}} &amp;&amp; if [ -h release ]; then rm release; fi\");\r\nrun(\"ln -s $releasePath {{deploy_path}}\/release\");\r\n\r\n?&gt;<\/pre>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u5207\u6362\u8f6f\u94fe\u63a5\u7684\u65f6\u5019\uff0c\u5b83\u662f\u5148\u5220\u9664\u518d\u521b\u5efa\uff0c\u662f\u4e00\u4e2a\u4e24\u6b65\u64cd\u4f5c\uff0c\u7406\u8bba\u4e0a\u5982\u679c\u6709\u8bf7\u6c42\u5728\u8fd9\u4e24\u6b65\u4e2d\u95f4\u8fdb\u5165\u7684\u8bdd\uff0c\u90a3\u4e48\u5c06\u4f1a\u51fa\u73b0\u627e\u4e0d\u5230\u6587\u4ef6\u7684\u9519\u8bef\u3002<\/p>\n<p>\u95ee\u9898\u5230\u8fd9\u91cc\uff0c\u5927\u90e8\u5206\u4eba\u4f1a\u89c9\u5f97\u4f7f\u7528\u300cln -sfn\u300d\u5c31\u597d\u4e86\uff0c\u5b9e\u9645\u4e0a\u4e5f\u662f\u9519\u8bef\u7684\uff1a<\/p>\n<pre>shell&gt; strace ln -sfn releases\/foo current\r\nsymlink(\"releases\/foo\", \"current\")      = -1 EEXIST (File exists)\r\nunlink(\"current\")                       = 0\r\nsymlink(\"releases\/foo\", \"current\")      = 0<\/pre>\n<p>\u901a\u8fc7 strace \u6211\u4eec\u80fd\u6e05\u6670\u7684\u770b\u5230\uff0c\u867d\u7136\u8868\u9762\u4e0a\u4f7f\u7528\u300cln -sfn\u300d\u662f\u4e00\u6b65\u64cd\u4f5c\uff0c\u4f46\u662f\u5185\u90e8\u4f9d\u7136\u662f\u6309\u7167\u5148\u5220\u9664\u518d\u521b\u5efa\u7684\u903b\u8f91\u6267\u884c\u7684\uff0c\u5b9e\u9645\u4e0a\u8fd9\u91cc\u5e94\u8be5\u642d\u914d\u4f7f\u7528\u300cln &amp; mv\u300d\uff1a<\/p>\n<pre>shell&gt; ln -sfn releases\/foo current.tmp\r\nshell&gt; mv -fT current.tmp current<\/pre>\n<p>\u5148\u901a\u8fc7 ln \u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u7684\u8f6f\u94fe\u63a5\uff0c\u518d\u901a\u8fc7 mv \u5b9e\u73b0\u539f\u5b50\u64cd\u4f5c\uff0c\u6b64\u65f6\u5982\u679c\u4f7f\u7528 strace \u76d1\u63a7\uff0c\u4f1a\u53d1\u73b0 mv \u7684\u300cT\u300d\u9009\u9879\u5b9e\u9645\u4e0a\u4ec5\u4ec5\u6267\u884c\u4e86\u4e00\u4e2a rename \u64cd\u4f5c\uff0c\u6240\u4ee5\u662f\u539f\u5b50\u7684\u3002<\/p>\n<p>link:\u00a0http:\/\/huoding.com\/2016\/05\/27\/515<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51e0\u4e4e\u6bcf\u4e00\u4e2a PHP \u7a0b\u5e8f\u5458\u90fd\u53d1\u5e03\u8fc7\u4ee3\u7801\uff0c\u53ef\u80fd\u662f\u901a\u8fc7 ftp \u6216\u8005 rsync \u540c\u6b65\u7684\uff0c\u4e5f\u53ef\u80fd\u662f\u901a\u8fc7 svn \u6216 <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.yanbin888.com\/?p=196\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[22],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=196"}],"version-history":[{"count":4,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions\/240"}],"wp:attachment":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}