{"id":718,"date":"2021-06-25T10:53:15","date_gmt":"2021-06-25T09:53:15","guid":{"rendered":"http:\/\/blog.chen-hongyi.com\/?p=718"},"modified":"2021-06-26T13:25:22","modified_gmt":"2021-06-26T12:25:22","slug":"php%e7%9a%84%e8%bf%90%e8%a1%8c%e6%a8%a1%e5%bc%8f%ef%bc%9aapache-2-0-handler-%e5%88%b0-fpm","status":"publish","type":"post","link":"https:\/\/chen-hongyi.com\/?p=718","title":{"rendered":"PHP\u7684\u8fd0\u884c\u6a21\u5f0f\uff1aApache 2.0 Handler \u5230  FPM"},"content":{"rendered":"\n<p>\u957f\u4e45\u4ee5\u6765\uff0c\u6211\u4eec\u4e00\u76f4\u4f7f\u7528Apache\u4f5c\u4e3aWeb\u670d\u52a1\u5668\uff0c\u7528Apache2.0 Handler \u65b9\u5f0f\u6765\u8fd0\u884cPHP, \u4e5f\u5c31\u662fmod_php, \u628aPHP\u4e2d\u4f5c\u4e3aApache\u7684\u4e00\u4e2amodule\u7684\u6765\u8fd0\u884c\u3002\u5f53\u65f6\u7b97\u662f\u6bd4\u8f83\u5feb\u7684\u914d\u7f6e\u65b9\u5f0f\u3002\u4e0d\u8fc7\u8fd9\u90fd\u662f10\u591a\u5e74\u524d\u7684\u914d\u7f6e\u4e86\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u5e38\u7528\u7684\u642d\u914d\u662fnginx + PHP-FPM. \u8fd9\u79cd\u914d\u7f6e\u5728\u76ee\u524ddocker\u65f6\u4ee3\u663e\u5f97\u6bd4\u8f83\u5408\u9002\u3002web server\u9009\u7528nginx \u8fd0\u884c\u5728\u4e00\u4e2a\u5bb9\u5668\u5185. php \u4f5c\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u5bb9\u5668\u8fd0\u884c\uff0c\u901a\u5e38\u6253\u5f009000\u7aef\u53e3\u6765\u548cnginx\u901a\u8baf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5728PHP\u7aef\u7684dockerfile\u914d\u7f6e<\/strong><\/h2>\n\n\n\n<p> \u9009\u62e9 php:fpm-alpine \u7684\u955c\u50cf\u3002\u8bb0\u5f97\u6700\u540e\u8981expose 9000\u7aef\u53e3\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5728 Nginx \u6bb5\u7684\u914d\u7f6e<\/strong><\/h2>\n\n\n\n<p> \/etc\/nginx\/cond.d\/default.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>upstream php-upstream {\n    server php:9000\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\u914d\u7f6e\uff0c\u901a\u8fc7phpfinfo\u67e5\u770b\uff0c Server API\u5c31\u662f FPM\/FastCGI \u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9644\u5f55 1\uff1a php\u7684dockerfile\u5982\u4e0b<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"># newest PHP version\nFROM php:fpm-alpine\n\n# Add git\nRUN apk --update --no-cache add git\n\n# PostgreSQL\nRUN set -ex &amp;&amp; apk --no-cache add postgresql-dev\nRUN docker-php-ext-install pdo_mysql\n\nCOPY --from=composer \/usr\/bin\/composer \/usr\/bin\/composer\nRUN rm -rf \/var\/cache\/apk\/* &amp;&amp; rm -rf \/tmp\/*\n\nWORKDIR \/var\/www\n\nCMD composer -V; php-fpm\n\nEXPOSE 9000<\/pre>\n\n\n\n<p>\u6ce8\u610f\uff0c\u9700\u8981\u624b\u52a8\u7684\u542f\u52a8 php-fpm<\/p>\n\n\n\n<p><strong>\u9644\u5f552\uff1anginx\u7684Dockerfile:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FROM nginx:alpine\n\nWORKDIR \/var\/www\n\nADD nginx.conf \/etc\/nginx\nADD sites \/etc\/nginx\/sites-available\nADD conf.d \/etc\/nginx\/conf.d\n\nCMD [\"nginx\"]\n\nEXPOSE 80 443\n\n<\/pre>\n\n\n\n<p>\u9644\u5f553: Docker-compose.yml<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">version: '3'\n\nservices:\n\n  php:\n    build: .\/docker\/php\n    image: base-php:latest\n    volumes:\n      - .\/app:\/var\/www:cached\n\n  nginx:\n    build: .\/docker\/nginx\n    image: base-nginx:latest\n    volumes:\n      - .\/app:\/var\/www:cached\n      - .\/logs\/nginx:\/var\/log\/nginx:cached\n    ports: [80:80, 443:443]<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u957f\u4e45\u4ee5\u6765\uff0c\u6211\u4eec\u4e00\u76f4\u4f7f\u7528Apache\u4f5c\u4e3aWeb\u670d\u52a1\u5668\uff0c\u7528Apache2.0 Han &hellip; <a href=\"https:\/\/chen-hongyi.com\/?p=718\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-718","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=718"}],"version-history":[{"count":3,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions"}],"predecessor-version":[{"id":721,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions\/721"}],"wp:attachment":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}