{"id":2943,"date":"2025-03-18T23:38:10","date_gmt":"2025-03-18T15:38:10","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=2943"},"modified":"2025-03-18T23:38:10","modified_gmt":"2025-03-18T15:38:10","slug":"php-%e5%ae%89%e8%a3%85%e4%b8%8e%e9%85%8d%e7%bd%ae%ef%bc%88%e8%af%a6%e7%bb%86%e6%8c%87%e5%8d%97%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/03\/18\/php-%e5%ae%89%e8%a3%85%e4%b8%8e%e9%85%8d%e7%bd%ae%ef%bc%88%e8%af%a6%e7%bb%86%e6%8c%87%e5%8d%97%ef%bc%89\/","title":{"rendered":"PHP \u5b89\u88c5\u4e0e\u914d\u7f6e\uff08\u8be6\u7ec6\u6307\u5357\uff09"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u5b89\u88c5\u524d\u9700\u8981\u8003\u8651\u7684\u4e8b\u9879<\/h2>\n\n\n\n<p>\u5728\u5b89\u88c5 PHP \u4e4b\u524d\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u56e0\u7d20\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1aWindows\u3001Linux\u3001macOS\u3001\u4e91\u8ba1\u7b97\u5e73\u53f0\u7b49\u3002<\/li>\n\n\n\n<li><strong>Web \u670d\u52a1\u5668<\/strong>\uff1aApache\u3001Nginx\u3001IIS \u8fd8\u662f\u5176\u4ed6\u670d\u52a1\u5668\uff1f<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u652f\u6301<\/strong>\uff1aMySQL\u3001PostgreSQL\u3001SQLite \u8fd8\u662f NoSQL\uff1f<\/li>\n\n\n\n<li><strong>PHP \u7248\u672c<\/strong>\uff1a\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7684 <strong>PHP 8.x<\/strong> \u7248\u672c\uff0c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002<\/li>\n\n\n\n<li><strong>\u6269\u5c55\u4e0e\u6a21\u5757<\/strong>\uff1a\u4f8b\u5982 <code>pdo_mysql<\/code>\uff08\u6570\u636e\u5e93\uff09\u3001<code>gd<\/code>\uff08\u56fe\u50cf\u5904\u7406\uff09\u3001<code>openssl<\/code>\uff08SSL\uff09\u3002<\/li>\n\n\n\n<li><strong>\u8fd0\u884c\u6a21\u5f0f<\/strong>\uff1a<\/li>\n\n\n\n<li><strong>CGI\/FastCGI<\/strong>\uff08\u9002\u7528\u4e8e Nginx\uff09<\/li>\n\n\n\n<li><strong>Apache \u6a21\u5757<\/strong>\uff08\u9002\u7528\u4e8e Apache\uff09<\/li>\n\n\n\n<li><strong>PHP-FPM<\/strong>\uff08FastCGI \u8fdb\u7a0b\u7ba1\u7406\u5668\uff0c\u9002\u7528\u4e8e\u9ad8\u5e76\u53d1\u573a\u666f\uff09<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u5728 Unix \u7cfb\u7edf\u4e0a\u5b89\u88c5 PHP<\/h2>\n\n\n\n<p>\u5728 <strong>Linux \u670d\u52a1\u5668<\/strong>\uff08\u5982 Ubuntu\u3001Debian\u3001CentOS\uff09\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528 <strong>\u5305\u7ba1\u7406\u5de5\u5177<\/strong> \u5b89\u88c5 PHP\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Ubuntu\/Debian\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install php php-cli php-fpm php-mysql php-curl php-gd php-mbstring php-xml unzip<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CentOS\/RHEL\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install epel-release -y\nsudo yum install php php-cli php-fpm php-mysqlnd php-curl php-gd php-mbstring php-xml unzip<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u914d\u7f6e PHP-FPM\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable php-fpm\nsudo systemctl start php-fpm<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9a8c\u8bc1 PHP \u7248\u672c\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>php -v<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. macOS \u7cfb\u7edf\u4e0b\u7684\u5b89\u88c5<\/h2>\n\n\n\n<p>macOS \u4e0a\u5efa\u8bae\u4f7f\u7528 <strong>Homebrew<\/strong> \u5b89\u88c5 PHP\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew update\nbrew install php<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u68c0\u67e5 PHP \u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php -v<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u914d\u7f6e PHP-FPM\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>brew services start php<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. Windows \u7cfb\u7edf\u4e0b\u7684\u5b89\u88c5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4f7f\u7528 XAMPP\uff08\u63a8\u8350\uff09<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0b\u8f7d XAMPP\uff1a<a href=\"https:\/\/www.apachefriends.org\/\">https:\/\/www.apachefriends.org\/<\/a><\/li>\n\n\n\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u52fe\u9009 <strong>Apache\u3001MySQL\u3001PHP<\/strong> \u7ec4\u4ef6\u3002<\/li>\n\n\n\n<li>\u542f\u52a8 XAMPP \u63a7\u5236\u9762\u677f\uff0c\u5f00\u542f <strong>Apache<\/strong> \u670d\u52a1\u3002<\/li>\n\n\n\n<li>\u5728 <code>C:\\xampp\\htdocs\\<\/code> \u76ee\u5f55\u4e0b\u521b\u5efa <code>index.php<\/code>\uff0c\u6d4b\u8bd5 PHP \u662f\u5426\u8fd0\u884c\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   &lt;?php\n   phpinfo();\n   ?&gt;<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>\u8bbf\u95ee <code>http:\/\/localhost\/index.php<\/code>\uff0c\u68c0\u67e5 PHP \u4fe1\u606f\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u624b\u52a8\u5b89\u88c5<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0b\u8f7d PHP\uff1a<a href=\"https:\/\/windows.php.net\/download\/\">https:\/\/windows.php.net\/download\/<\/a><\/li>\n\n\n\n<li>\u89e3\u538b ZIP \u6587\u4ef6\u5230 <code>C:\\php\\<\/code><\/li>\n\n\n\n<li>\u914d\u7f6e <code>php.ini<\/code>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06 <code>php.ini-development<\/code> \u590d\u5236\u5e76\u91cd\u547d\u540d\u4e3a <code>php.ini<\/code><\/li>\n\n\n\n<li>\u542f\u7528 <code>extension_dir<\/code> \u548c\u6240\u9700\u7684\u6269\u5c55\uff08\u5982 <code>extension=mysqli<\/code>\uff09<\/li>\n<\/ul>\n\n\n\n<p>4\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06 <code>C:\\php\\<\/code> \u6dfb\u52a0\u5230 <code>PATH<\/code><\/li>\n<\/ul>\n\n\n\n<p>5\u3001\u6d4b\u8bd5 PHP \u7248\u672c\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   php -v<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u4e91\u8ba1\u7b97\u5e73\u53f0\u4e0a\u7684\u5b89\u88c5<\/h2>\n\n\n\n<p>\u5728 <strong>\u4e91\u8ba1\u7b97\u5e73\u53f0<\/strong>\uff08\u5982 AWS\u3001Azure\u3001Google Cloud\uff09\u4e0a\uff0c\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <strong>Docker<\/strong> \u8fd0\u884c PHP\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  docker run -d -p 8080:80 php:8.2-apache<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5728 <strong>AWS EC2<\/strong> \u4e0a\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  sudo amazon-linux-extras enable php8.2\n  sudo yum install php php-cli php-fpm<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6. FastCGI \u8fdb\u7a0b\u7ba1\u7406\u5668\uff08FPM\uff09<\/h2>\n\n\n\n<p><strong>PHP-FPM\uff08FastCGI Process Manager\uff09<\/strong> \u662f\u7528\u4e8e <strong>\u9ad8\u5e76\u53d1<\/strong> \u573a\u666f\u7684 PHP \u8fd0\u884c\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e <strong>Nginx<\/strong>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u542f\u52a8 PHP-FPM\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start php-fpm<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u914d\u7f6e <code>www.conf<\/code>\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>listen = \/run\/php\/php8.2-fpm.sock<\/code><\/pre>\n\n\n\n<p>\u91cd\u542f PHP-FPM\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart php-fpm<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">7. PECL \u6269\u5c55\u5b89\u88c5<\/h2>\n\n\n\n<p>PHP \u6269\u5c55\u793e\u533a\u5e93\uff08PECL\uff09\u63d0\u4f9b\u4e86\u989d\u5916\u7684 PHP \u6269\u5c55\uff0c\u4f8b\u5982 Redis\u3001Memcached\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php-pear php-dev\nsudo pecl install redis<\/code><\/pre>\n\n\n\n<p>\u542f\u7528\u6269\u5c55\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>extension=redis.so<\/code><\/pre>\n\n\n\n<p>\u91cd\u542f PHP\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart php-fpm<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">8. Introduction to Composer<\/h2>\n\n\n\n<p><strong>Composer<\/strong> \u662f PHP \u7684\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\uff0c\u7c7b\u4f3c\u4e8e <code>npm<\/code>\uff08Node.js\uff09\u6216 <code>pip<\/code>\uff08Python\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5 Composer\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -sS https:\/\/getcomposer.org\/installer | php\nsudo mv composer.phar \/usr\/local\/bin\/composer<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9a8c\u8bc1\u5b89\u88c5\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>composer -V<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5 Laravel\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>composer create-project --prefer-dist laravel\/laravel my_app<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">9. \u8fd0\u884c\u65f6\u914d\u7f6e<\/h2>\n\n\n\n<p>PHP \u8fd0\u884c\u65f6\u914d\u7f6e\u6587\u4ef6 <strong>php.ini<\/strong> \u5f71\u54cd PHP \u7684\u6267\u884c\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php --ini<\/code><\/pre>\n\n\n\n<p>\u5e38\u89c1\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>memory_limit = 256M   ; PHP \u5141\u8bb8\u7684\u6700\u5927\u5185\u5b58\nupload_max_filesize = 50M  ; \u5141\u8bb8\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\npost_max_size = 50M    ; POST \u6570\u636e\u6700\u5927\u5927\u5c0f\nmax_execution_time = 30  ; \u811a\u672c\u6700\u5927\u6267\u884c\u65f6\u95f4\uff08\u79d2\uff09<\/code><\/pre>\n\n\n\n<p>\u91cd\u542f PHP \u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart php-fpm<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">10. \u8fdb\u4e00\u6b65\u5b66\u4e60<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PHP \u5b98\u65b9\u5b89\u88c5\u6307\u5357<\/strong>\uff1a<a href=\"https:\/\/www.php.net\/manual\/en\/install.php\">https:\/\/www.php.net\/manual\/en\/install.php<\/a><\/li>\n\n\n\n<li><strong>Composer \u5b98\u65b9\u6587\u6863<\/strong>\uff1a<a href=\"https:\/\/getcomposer.org\/doc\/\">https:\/\/getcomposer.org\/doc\/<\/a><\/li>\n\n\n\n<li><strong>PHP-FPM \u5b98\u65b9\u6587\u6863<\/strong>\uff1a<a href=\"https:\/\/www.php.net\/manual\/en\/install.fpm.php\">https:\/\/www.php.net\/manual\/en\/install.fpm.php<\/a><\/li>\n<\/ul>\n\n\n\n<p>\u66f4\u591aphp\u8be6\u7ec6\u5185\u5bb9\u8bf7\u5173\u6ce8\u5176\u4ed6\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5\u524d\u9700\u8981\u8003\u8651\u7684\u4e8b\u9879 \u5728\u5b89\u88c5 PHP \u4e4b\u524d\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u56e0\u7d20\uff1a 2. \u5728 Unix \u7cfb\u7edf\u4e0a\u5b89\u88c5  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[],"class_list":["post-2943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=2943"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2943\/revisions"}],"predecessor-version":[{"id":2945,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2943\/revisions\/2945"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/2944"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=2943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=2943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=2943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}