{"id":18307,"date":"2024-11-18T17:03:54","date_gmt":"2024-11-18T09:03:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18307\/"},"modified":"2024-11-18T17:03:54","modified_gmt":"2024-11-18T09:03:54","slug":"docker%e6%80%8e%e4%b9%88%e5%ae%89%e8%a3%85php%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18307\/","title":{"rendered":"docker\u600e\u4e48\u5b89\u88c5php\u73af\u5883"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5728 docker \u4e2d\u5b89\u88c5 php \u73af\u5883\uff0c\u53ef\u4ee5\uff1a\u62c9\u53d6 php \u955c\u50cf\u6216\u6784\u5efa\u81ea\u5efa\u955c\u50cf\u3002\u8fd0\u884c docker \u5bb9\u5668\u3002\u5728\u5bb9\u5668\u4e2d\u5b89\u88c5 php \u6269\u5c55\u3002\u521b\u5efa php \u914d\u7f6e\u6587\u4ef6\u3002\u542f\u52a8 apache\u3002\u4f7f\u7528 php -v \u68c0\u67e5 php \u7248\u672c\uff0c\u5e76\u5728\u5bb9\u5668 ip \u5730\u5740\u4e0a\u8bbf\u95ee php \u9875\u9762\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/05\/2024060509451786995.jpg\" class=\"aligncenter\" title=\"docker\u600e\u4e48\u5b89\u88c5php\u73af\u5883\u63d2\u56fe\" alt=\"docker\u600e\u4e48\u5b89\u88c5php\u73af\u5883\u63d2\u56fe\" \/><\/p>\n<p><strong>Docker \u5b89\u88c5 PHP \u73af\u5883<\/strong><\/p>\n<p>\u8981\u5728 Docker \u4e2d\u5b89\u88c5 PHP \u73af\u5883\uff0c\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u521b\u5efa Docker \u955c\u50cf<\/strong><\/p>\n<pre># \u4f7f\u7528\u5b98\u65b9 PHP \u955c\u50cf\ndocker pull php:8.1-apache\n\n# \u6216\u4f7f\u7528\u81ea\u5efa\u955c\u50cf\ndocker build -t my-php-image .<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u8fd0\u884c Docker \u5bb9\u5668<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>docker run -it --name my-php-container my-php-image<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u5b89\u88c5 PHP \u6269\u5c55<\/strong><\/p>\n<p>\u8981\u5728\u5bb9\u5668\u4e2d\u5b89\u88c5 PHP \u6269\u5c55\uff0c\u53ef\u4ee5\u4f7f\u7528 pecl \u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u5b89\u88c5 MySQL \u6269\u5c55\uff1a<\/p>\n<pre>pecl install pdo_mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<p>\u5728\u5bb9\u5668\u4e2d\u521b\u5efa\u914d\u7f6e\u6587\u4ef6 \/etc\/php.ini\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre>memory_limit = 256M\nupload_max_filesize = 20M\nmax_execution_time = 30<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u542f\u52a8 Apache<\/strong><\/p>\n<p>\u5728\u5bb9\u5668\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 Apache\uff1a<\/p>\n<pre>\/usr\/sbin\/apache2ctl -D FOREGROUND<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<p>\u5728\u5bb9\u5668\u4e2d\u4f7f\u7528 php -v \u547d\u4ee4\u68c0\u67e5 PHP \u7248\u672c\uff1a<\/p>\n<pre>php -v<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5e94\u8be5\u4f1a\u663e\u793a\u5df2\u5b89\u88c5\u7684 PHP \u7248\u672c\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u8fd8\u53ef\u4ee5\u8bbf\u95ee\u5bb9\u5668\u7684 IP \u5730\u5740\u6765\u67e5\u770b PHP \u9875\u9762\u3002PHP \u9ed8\u8ba4\u76d1\u542c\u7aef\u53e3 80\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5b89\u88c5php\u73af\u5883\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u5728 docker \u4e2d\u5b89\u88c5 php \u73af\u5883\uff0c\u53ef\u4ee5\uff1a\u62c9\u53d6 php \u955c\u50cf\u6216\u6784\u5efa\u81ea\u5efa\u955c\u50cf\u3002\u8fd0\u884c docker \u5bb9\u5668\u3002\u5728\u5bb9\u5668\u4e2d\u5b89\u88c5 php \u6269\u5c55\u3002\u521b\u5efa php \u914d\u7f6e\u6587\u4ef6\u3002\u542f\u52a8 apache\u3002\u4f7f\u7528 php -v \u68c0\u67e5 php \u7248\u672c\uff0c\u5e76\u5728\u5bb9\u5668 ip \u5730\u5740\u4e0a\u8bbf\u95ee php \u9875\u9762\u3002 Docker \u5b89\u88c5 PHP \u73af\u5883 \u8981\u5728 Docker \u4e2d\u5b89\u88c5 PHP \u73af\u5883\uff0c\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u521b\u5efa Docker \u955c\u50cf # \u4f7f\u7528\u5b98\u65b9 PHP \u955c\u50cf docker pull php:8.1-apache # \u6216\u4f7f\u7528\u81ea\u5efa\u955c\u50cf docker build -t my-php-image . \u767b\u5f55\u540e\u590d\u5236 2. \u8fd0\u884c Docker \u5bb9\u5668 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18307","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18307"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18307\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}