{"id":61,"date":"2018-03-15T20:11:12","date_gmt":"2018-03-15T12:11:12","guid":{"rendered":"http:\/\/blog.mrfai.cn\/?p=61"},"modified":"2020-06-06T16:37:41","modified_gmt":"2020-06-06T08:37:41","slug":"caddysserverphp%e7%8e%af%e5%a2%83%e7%9a%84%e9%85%8d%e7%bd%ae%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/blog.mrfai.cn\/index.php\/2018\/03\/15\/61\/","title":{"rendered":"CaddysServer+PHP\u73af\u5883\u7684\u914d\u7f6e\u6b65\u9aa4"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"\u524d\u8a00\"><span class=\"has-inline-color has-luminous-vivid-amber-color\">\u261e \u524d\u8a00<\/span><\/h1>\n\n\n\n<p>\u5728\u4e0a\u6587\u4e2d\u6211\u4eec\u521d\u5c1d\u4e86CaddyServer\u7684\u8fd0\u884c\u3002\u8fd9\u6b21\u6211\u4eec\u6765\u5c1d\u8bd5\u914d\u5408PHP\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u7f16\u8bd1\u5b89\u88c5PHP\u73af\u5883\"><span class=\"has-inline-color has-luminous-vivid-amber-color\">\u261e \u7f16\u8bd1\u5b89\u88c5PHP\u73af\u5883<\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e00\u3001\u4e0b\u8f7d\">\u4e00\u3001\u4e0b\u8f7d<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u4ee5CentOS 7.4\u4e3a\u4f8b\uff0c\u5b89\u88c5PHP\u7684\u8fd0\u884c\u73af\u5883\u3002\u53ef\u4ee5\u5148\u4ecePHP\u5b98\u7f51\u4e0b\u8f7d\u6e90\u7801\u5305\uff0c<a rel=\"noreferrer noopener\" href=\"http:\/\/php.net\/downloads.php\" target=\"_blank\">http:\/\/php.net\/downloads.php<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"790\" src=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-151217-1024x790.png\" alt=\"\" class=\"wp-image-62\" srcset=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-151217-1024x790.png 1024w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-151217-300x232.png 300w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-151217-768x593.png 768w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-151217.png 1219w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u91cc\u6211\u9009\u62e9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684PHP-7.2.3<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Download Command Line:\nwget http:\/\/cn.php.net\/distributions\/php-7.2.3.tar.gz<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e8c\u3001\u89e3\u538b\">\u4e8c\u3001\u89e3\u538b<\/h2>\n\n\n\n<p>\u5c06\u4e0b\u8f7d\u7684\u5305\uff0c\u89e3\u538b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -zxvf php-7.2.3.tar.gz<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e09\u3001\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\u4f9d\u8d56\">\u4e09\u3001\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\u4f9d\u8d56<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">yum -y install gcc\nyum -y install libxml2\nyum -y install libxml2-devel\nyum -y install openssl\nyum -y install openssl-devel\nyum -y install curl\nyum -y install curl-devel\nyum -y install libjpeg\nyum -y install libjpeg-devel\nyum -y install libpng\nyum -y install libpng-devel\nyum -y install freetype\nyum -y install freetype-devel\nyum -y install pcre\nyum -y install pcre-devel\nyum -y install libxslt\nyum -y install libxslt-devel\nyum -y install bzip2\nyum -y install bzip2-devel<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u56db\u3001\u7f16\u8bd1PHP\u6e90\u7801\u5305\">\u56db\u3001\u7f16\u8bd1PHP\u6e90\u7801\u5305<\/h2>\n\n\n\n<p>\u5148\u8fdb\u5165\u521a\u521a\u89e3\u538b\u7684PHP\u6e90\u7801\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd php-7.2.3<\/pre>\n\n\n\n<p>\u7136\u540e\u6267\u884c\u914d\u7f6e\u8bbe\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/configure --prefix=\/usr\/local\/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip<\/pre>\n\n\n\n<p>\u6700\u540e\u6267\u884c\u7f16\u8bd1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e94\u3001\u5b89\u88c5PHP\">\u4e94\u3001\u5b89\u88c5PHP<\/h2>\n\n\n\n<p>\u6267\u884c\u5b89\u88c5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make install<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u516d\u3001\u914d\u7f6e\u6587\u4ef6\u53ca\u53c2\u6570\">\u516d\u3001\u914d\u7f6e\u6587\u4ef6\u53ca\u53c2\u6570<\/h2>\n\n\n\n<p>php\u7684\u9ed8\u8ba4\u5b89\u88c5\u4f4d\u7f6e\u4e0a\u9762\u5df2\u7ecf\u6307\u5b9a\u4e3a\/usr\/local\/php\uff0c\u63a5\u4e0b\u6765\u521d\u59cb\u5316\u4e00\u4e9b\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cp php.ini-development \/usr\/local\/php\/lib\/php.ini\n\ncp \/usr\/local\/php\/etc\/php-fpm.conf.default \/usr\/local\/php\/etc\/php-fpm.conf\n\ncp sapi\/fpm\/php-fpm \/usr\/local\/bin<\/pre>\n\n\n\n<p>\u7136\u540e\u8bbe\u7f6ephp.ini\uff0c\u4f7f\u7528\uff1a vim \/usr\/local\/php\/lib\/php.ini \u6253\u5f00php\u914d\u7f6e\u6587\u4ef6\u627e\u5230cgi.fix_pathinfo\u914d\u7f6e\u9879\uff0c\u8fd9\u4e00\u9879\u9ed8\u8ba4\u88ab\u6ce8\u91ca\u5e76\u4e14\u503c\u4e3a1\uff0c\u6839\u636e\u5b98\u65b9\u6587\u6863\u7684\u8bf4\u660e\uff0c\u8fd9\u91cc\u4e3a\u4e86\u5f53\u6587\u4ef6\u4e0d\u5b58\u5728\u65f6\uff0c\u963b\u6b62Nginx\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u540e\u7aef\u7684PHP-FPM\u6a21\u5757\uff0c\u4ece\u800c\u907f\u514d\u6076\u610f\u811a\u672c\u6ce8\u5165\u7684\u653b\u51fb\uff0c\u6240\u4ee5\u6b64\u9879\u5e94\u8be5\u53bb\u6389\u6ce8\u91ca\u5e76\u8bbe\u7f6e\u4e3a0\u3002<br>\u8bbe\u7f6e\u5b8c\u6bd5\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"694\" src=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-155128-1024x694.png\" alt=\"\" class=\"wp-image-64\" srcset=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-155128-1024x694.png 1024w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-155128-300x203.png 300w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-155128-768x521.png 768w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180315-155128.png 1106w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u53e6\u5916\u6ce8\u610f\u4e00\u4e2a\u5730\u65b9\u5c31\u662fphp.ini\u914d\u7f6e\u6587\u4ef6\u7684\u4f4d\u7f6e\u53ef\u4ee5\u5728\u7f16\u8bd1\u524d\u914d\u7f6e\u53c2\u6570\u4e2d\u8bbe\u7f6e\uff0c\u7f16\u8bd1\u53c2\u6570\u53ef\u4ee5\u5199\u6210\uff1a\u2013with-config-file-path=\/usr\/local\/php \u8fd9\u6837\u7684\u8bddphp\u5c31\u56de\u53bb\u6307\u5b9a\u7684\u76ee\u5f55\u4e0b\u8bfb\u53d6php.ini\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u4e0d\u52a0\u8fd9\u4e2a\u53c2\u6570\u9ed8\u8ba4\u4f4d\u7f6e\u5c31\u662fphp\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684lib\u76ee\u5f55\uff0c\u5177\u4f53\u4e5f\u53ef\u4ee5\u5728phpinfo()\u8f93\u51fa\u754c\u9762\u67e5\u770b\uff0c\u5982\u679cphp.ini\u653e\u5230\u5176\u4ed6\u4f4d\u7f6e\uff0cphp\u8bfb\u53d6\u4e0d\u5230\uff0c\u90a3\u4e48\u6240\u6709\u7684\u914d\u7f6e\u4fee\u6539\u540e\u90fd\u662f\u4e0d\u751f\u6548\u7684\uff0c\u8fd9\u70b9\u8981\u6ce8\u610f\u3002<\/p>\n\n\n\n<p>\u8bbe\u7f6ephp-fpm\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cp sapi\/fpm\/init.d.php-fpm \/etc\/init.d\/php-fpm\n\nchmod +x \/etc\/init.d\/php-fpm\n\ncp \/usr\/local\/php\/etc\/php-fpm.d\/www.conf.default \/usr\/local\/php\/etc\/php-fpm.d\/www.conf<\/pre>\n\n\n\n<p>\u542f\u52a8php-fpm\uff0cphp-fpm \u53ef\u7528\u53c2\u6570 start|stop|force-quit|restart|reload|status<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service php-fpm start<\/pre>\n\n\n\n<p>\u81f3\u4e8e\uff0cPHP\u73af\u5883\u914d\u7f6e\u544a\u4e00\u6bb5\u843d\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u5b89\u88c5CaddyServer\"><span class=\"has-inline-color has-luminous-vivid-amber-color\">\u261e \u5b89\u88c5CaddyServer<\/span><\/h1>\n\n\n\n<p>\u7531\u4e8e\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u4e86CaddyServer\u7684\u5b89\u88c5\u6b65\u9aa4\uff0c\u8fd9\u6b21\u6211\u4eec\u7b80\u8981\u91cd\u65b0\u6267\u884c\u4e00\u4e0b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e00\u3001\u4e0b\u8f7dCaddy\">\u4e00\u3001\u4e0b\u8f7dCaddy<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">wget https:\/\/caddyserver.com\/download\/linux\/amd64?license=personal &amp;&amp; mv .\/amd64?license=personal .\/caddy.tar.gz<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u89e3\u538b<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -zxvf caddy.tar.gz<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u6dfb\u52a0\u5230\u7cfb\u7edfpath<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">mv .\/caddy \/usr\/bin<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u521b\u5efa\u76ee\u5f55<\/h2>\n\n\n\n<p>\u8be5\u76ee\u5f55\u7528\u4e8e\u4e3b\u8981\u653e\u7f51\u7ad9\u76f8\u5173\u6587\u4ef6\u3002<br>\u5efa\u8bae\u5728\/opt\u76ee\u5f55\u4e0b\u521b\u5efawwwroot\u76ee\u5f55\uff0c\u5e76\u4e14\u5728wwwroot\u521b\u5efa<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1\u3001\u914d\u7f6e\u6587\u4ef6Caddyfile<\/li><li>2\u3001\u7f51\u7ad9\u6839\u76ee\u5f55www<\/li><li>3\u3001\u65e5\u5fd7\u76ee\u5f55log<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"374\" height=\"283\" src=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-172154.png\" alt=\"\" class=\"wp-image-65\" srcset=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-172154.png 374w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-172154-300x227.png 300w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u914d\u7f6eCaddyServer\"><span class=\"has-inline-color has-luminous-vivid-amber-color\">\u261e \u914d\u7f6eCaddyServer<\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e00\u3001\u914d\u7f6eCaddy\">\u4e00\u3001\u914d\u7f6eCaddy<\/h2>\n\n\n\n<p>\u5728\u4e0a\u4e00\u6b65\u6211\u4eec\u521b\u5efa\u4e86\u76f8\u5e94\u7684\u76ee\u5f55\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u6240\u4ee5\u6211\u4eec\u5728\u914d\u7f6e\u6587\u4ef6CaddyServer\u4e2d\u5199\u914d\u7f6e\u5e76\u4fdd\u5b58\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">192.168.52.60:80 {\n   root \/opt\/wwwroot\/www\n   fastcgi \/ 127.0.0.1:9000 php {\n      index index.php\n   }\n   gzip\n   browse\n   log \/opt\/wwwroot\/log\/access.log\n   errors \/opt\/wwwroot\/log\/error.log\n}<\/pre>\n\n\n\n<p>\u7136\u540e\u5728www\u76ee\u5f55\u4e2d\u521b\u5efaindex.php\uff0c\u5e76\u4e14\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\u5e76\u4fdd\u5b58\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n   phpinfo();\n?><\/pre>\n\n\n\n<p>\u6700\u540e\u5728wwwroot\u76ee\u5f55\u4e2d\u542f\u52a8\u547d\u4ee4\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@VM_7_243_centos wwwroot]# caddy<\/pre>\n\n\n\n<p>caddy\u5df2\u7ecf\u542f\u52a8\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u6210\u529f\u89e3\u6790PHP\"><span class=\"has-inline-color has-luminous-vivid-amber-color\">\u261e \u6210\u529f\u89e3\u6790PHP<\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e00\u3001\u8bbf\u95ee\u8bd5\u8bd5\">\u4e00\u3001\u8bbf\u95ee\u8bd5\u8bd5<\/h2>\n\n\n\n<p>\u8fd9\u65f6\u53ea\u8981\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8f93\u5165192.168.52.60(\u4f60\u914d\u7f6e\u6587\u4ef6\u586b\u5199\u7684IP)\uff0c\u5c31\u53d1\u73b0PHP\u5df2\u88ab\u89e3\u6790\u5e76\u6210\u529f\u8bbf\u95ee\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"763\" src=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-173648-1024x763.png\" alt=\"\" class=\"wp-image-66\" srcset=\"https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-173648-1024x763.png 1024w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-173648-300x224.png 300w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-173648-768x572.png 768w, https:\/\/blog.mrfai.cn\/wp-content\/uploads\/2020\/06\/WX20180317-173648.png 1248w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u6210\u529f\u89e3\u6790PHP\u5e76\u8bbf\u95ee\u3002<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u261e \u524d\u8a00 \u5728\u4e0a\u6587\u4e2d\u6211\u4eec\u521d\u5c1d\u4e86CaddyServer&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/blog.mrfai.cn\/index.php\/2018\/03\/15\/61\/\">Continue reading<span class=\"screen-reader-text\">CaddysServer+PHP\u73af\u5883\u7684\u914d\u7f6e\u6b65\u9aa4<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3,8],"tags":[12,9,5],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-golang","category-linux","category-php","tag-caddyserver","tag-golang","tag-php","entry"],"_links":{"self":[{"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":1,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mrfai.cn\/index.php\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}