{"id":267876,"date":"2023-03-23T22:10:03","date_gmt":"2023-03-23T14:10:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/lsphjdjznqsc.html"},"modified":"2023-03-23T22:10:03","modified_gmt":"2023-03-23T14:10:03","slug":"lsphjdjznqsc","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lsphjdjznqsc.html","title":{"rendered":"Linux\u4e0aPHP\u73af\u5883\u642d\u5efa\u6307\u5357\uff0c\u8f7b\u677e\u6210\u529f\uff01"},"content":{"rendered":"

\u5728\u5f53\u4eca\u6570\u5b57\u5316\u65f6\u4ee3\uff0cPHP\u5df2\u7ecf\u6210\u4e3a\u4e86\u7f51\u7ad9\u5f00\u53d1\u7684\u91cd\u8981\u5de5\u5177\u3002\u4f46\u662f\uff0c\u60f3\u8981\u5728Linux<\/a>\u7cfb\u7edf<\/a>\u4e0b\u642d\u5efaPHP\u73af\u5883\u6709\u65f6\u4f1a\u8ba9\u4eba\u671b\u800c\u5374\u6b65\u3002\u4e0d\u8fc7\uff0c\u4e0d\u7528\u62c5\u5fc3\uff01\u672c\u6587\u5c06\u63d0\u4f9b\u4e00\u4e2a\u5168\u9762\u7684\u6307\u5357\uff0c\u5e2e\u52a9\u60a8\u5728Linux\u7cfb\u7edf\u4e0b\u6210\u529f\u642d\u5efaPHP\u73af\u5883\u3002<\/p>\n

1.\u5b89\u88c5Apache\u670d\u52a1\u5668<\/p>\n

\u9996\u5148\uff0c\u5728Linux\u670d\u52a1\u5668\u4e0a\u5b89\u88c5Apache\u670d\u52a1\u5668\u662f\u5fc5\u987b\u7684\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4<\/a>\u6765\u5b89\u88c5\uff1a<\/p>\n

\n

\nsudo apt-get update\nsudo apt-get install apache2\n<\/pre>\n<\/p>\n

2.\u5b89\u88c5MySQL\u6570\u636e\u5e93<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u9700\u8981\u5b89\u88c5MySQL\u6570\u636e\u5e93\u4ee5\u4fbf\u4e0ePHP\u8fdb\u884c\u96c6\u6210\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nsudo apt-get install mysql-server php-mysql\n<\/pre>\n<\/p>\n

linux\u642d\u5efaphp\u73af\u5883_php\u73af\u5883\u642d\u5efa linux_win7\u4e0b\u642d\u5efaphp\u73af\u5883<\/p>\n

3.\u5b89\u88c5PHP<\/p>\n

\u73b0\u5728\u53ef\u4ee5\u5b89\u88c5PHP\u4e86\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nsudo apt-get install php libapache2-mod-php php-mcrypt php-mysql\n<\/pre>\n<\/p>\n

4.\u6d4b\u8bd5PHP\u662f\u5426\u6b63\u5e38\u5de5\u4f5c<\/p>\n

\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u6d4b\u8bd5\u4e00\u4e0bPHP\u662f\u5426\u5df2\u7ecf\u6b63\u786e\u5730\u5b89\u88c5\u5e76\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684PHP\u811a\u672c\u6587\u4ef6\uff1a<\/p>\n

\n

\nsudo nano \/var\/www\/html\/info.php\n<\/pre>\n<\/p>\n

\u5728\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n

php\u73af\u5883\u642d\u5efa linux_win7\u4e0b\u642d\u5efaphp\u73af\u5883_linux\u642d\u5efaphp\u73af\u5883<\/p>\n

\n

php\n<?php\nphpinfo();\n?>\n<\/pre>\n<\/p>\n

\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u670d\u52a1\u5668IP\u5730\u5740\u6216\u57df\u540d\uff0c\u52a0\u4e0a“\/info.php”\u3002\u5982\u679c\u60a8\u770b\u5230\u6709\u5173PHP\u914d\u7f6e\u7684\u8be6\u7ec6\u4fe1\u606f\u67e5\u770b\u7cfb\u7edf\u7248\u672clinux\uff0c\u5219\u8868\u793a\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u4e86PHP\u3002<\/p>\n

5.\u914d\u7f6eApache\u670d\u52a1\u5668\u4ee5\u8fd0\u884cPHP\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cApache\u670d\u52a1\u5668\u53ef\u80fd\u65e0\u6cd5\u6b63\u786e\u5730\u5904\u7406PHP\u6587\u4ef6\u3002\u56e0\u6b64\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\u624d\u80fd\u4f7f\u5176\u6b63\u5e38\u5de5\u4f5c\u3002\u9996\u5148linux\u8bfe\u7a0b\uff0c\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u6253\u5f00Apache\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

\n

\nsudo nano \/etc\/apache2\/mods-enabled\/dir.conf\n<\/pre>\n<\/p>\n

\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6bb5\u79fb\u52a8\u5230\u7b2c\u4e00\u884c\uff08\u786e\u4fddindex.php\u51fa\u73b0\u5728\u5176\u4ed6\u6587\u4ef6\u4e4b\u524d\uff09\uff1a<\/p>\n

\n

php\n<IfModule mod_dir.c>\n    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm\n<\/IfModule>\n<\/pre>\n<\/p>\n

linux\u642d\u5efaphp\u73af\u5883_php\u73af\u5883\u642d\u5efa linux_win7\u4e0b\u642d\u5efaphp\u73af\u5883<\/p>\n

6.\u91cd\u542fApache\u670d\u52a1\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548<\/p>\n

\n

\nsudo systemctl restart apache2\n<\/pre>\n<\/p>\n

7.\u5b89\u88c5\u5176\u4ed6\u5fc5\u8981\u7684\u6269\u5c55\u548c\u5e93<\/p>\n

\u9664\u4e86\u4e0a\u8ff0\u6b65\u9aa4\u4e4b\u5916php\u73af\u5883\u642d\u5efa linux<\/strong>php\u73af\u5883\u642d\u5efa linux<\/strong>\uff0c\u8fd8\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u5fc5\u8981\u7684\u6269\u5c55\u548c\u5e93\u4ee5\u786e\u4fddPHP\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n

\n

\nsudo apt-get install curl libcurl3 libcurl3-dev zip unzip git\nsudo apt-get install php-curl php-json php-cgi php-gd php-mbstring php-xml php-xmlrpc \n<\/pre>\n<\/p>\n

8.\u4f7f\u7528Composer\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb<\/p>\n

Composer\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\u7684\u5de5\u5177\u3002\u5b83\u5141\u8bb8\u60a8\u8f7b\u677e\u5730\u7ba1\u7406\u548c\u66f4\u65b0\u9879\u76ee\u6240\u9700\u7684\u6240\u6709\u5e93\u548c\u6846\u67b6\u3002\u8981\u5b89\u88c5Composer\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\ncurl -sS  | sudo php ----install-dir=\/usr\/local\/bin --filename=composer\n<\/pre>\n<\/p>\n

9.\u5b89\u88c5Laravel\u6846\u67b6<\/p>\n

Laravel\u662f\u4e00\u4e2a\u6d41\u884c\u7684PHP\u6846\u67b6\uff0c\u5b83\u5141\u8bb8\u60a8\u8f7b\u677e\u5730\u6784\u5efa\u73b0\u4ee3Web\u5e94\u7528\u7a0b\u5e8f\u3002\u8981\u5b89\u88c5Laravel\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n

-\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\/var\/www\/html\u76ee\u5f55\u3002<\/p>\n

-\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u4e0b\u8f7dLaravel\u6846\u67b6\uff1a<\/p>\n

\n

\n    sudo composer create-project --prefer-dist laravel\/laravel blog "5.*"\n    <\/pre>\n<\/p>\n

10.\u6d4b\u8bd5Laravel\u662f\u5426\u6b63\u5e38\u5de5\u4f5c<\/p>\n

linux\u642d\u5efaphp\u73af\u5883_win7\u4e0b\u642d\u5efaphp\u73af\u5883_php\u73af\u5883\u642d\u5efa linux<\/p>\n

\u6700\u540e\u4e00\u6b65\u662f\u6d4b\u8bd5Laravel\u662f\u5426\u5df2\u7ecf\u6b63\u786e\u5730\u5b89\u88c5\u5e76\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684\u8def\u7531\u5668\uff1a<\/p>\n

\n

\nsudo nano \/var\/www\/html\/blog\/routes\/web.php\n<\/pre>\n<\/p>\n

\u5728\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n

\n

php\n<?php\nRoute::get('\/', function (){\n    return view('welcome');\n});\n?>\n<\/pre>\n<\/p>\n

\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u670d\u52a1\u5668IP\u5730\u5740\u6216\u57df\u540d\uff0c\u52a0\u4e0a“\/blog\/public”\u3002\u5982\u679c\u60a8\u770b\u5230Laravel\u6b22\u8fce\u9875\u9762\uff0c\u5219\u8868\u793a\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u4e86Laravel\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u5728Linux\u7cfb\u7edf\u4e0b\u642d\u5efaPHP\u73af\u5883\u6240\u9700\u7684\u6240\u6709\u6b65\u9aa4\u3002\u867d\u7136\u8fd9\u53ef\u80fd\u770b\u8d77\u6765\u5f88\u590d\u6742\uff0c\u4f46\u53ea\u8981\u60a8\u6309\u7167\u672c\u6587\u63d0\u4f9b\u7684\u6307\u5357\u9010\u6b65\u64cd\u4f5c\uff0c\u5c31\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u81ea\u5df1\u7684Web\u5e94\u7528\u7a0b\u5e8f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u672c\u6587\u5c06\u63d0\u4f9b\u4e00\u4e2a\u5168\u9762\u7684\u6307\u5357\uff0c\u5e2e\u52a9\u60a8\u5728Linux\u7cfb\u7edf\u4e0b\u6210\u529f\u642d\u5efaPHP\u73af\u5883\u3002\u5b83\u5141\u8bb8\u60a8\u8f7b\u677e\u5730\u7ba1\u7406\u548c\u66f4\u65b0\u9879\u76ee\u6240\u9700\u7684\u6240\u6709\u5e93\u548c\u6846\u67b6\u3002Laravel\u662f\u4e00\u4e2a\u6d41\u884c\u7684PHP\u6846\u67b6\uff0c\u5b83\u5141\u8bb8\u60a8\u8f7b\u677e\u5730\u6784\u5efa\u73b0\u4ee3Web\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0a\u5c31\u662f\u5728Linux\u7cfb\u7edf\u4e0b\u642d\u5efaPHP\u73af\u5883\u6240\u9700\u7684\u6240\u6709\u6b65\u9aa4\u3002\u867d\u7136\u8fd9\u53ef\u80fd\u770b\u8d77\u6765\u5f88\u590d\u6742\uff0c\u4f46\u53ea\u8981\u60a8\u6309\u7167\u672c\u6587\u63d0\u4f9b\u7684\u6307\u5357\u9010\u6b65\u64cd\u4f5c\uff0c\u5c31\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u81ea\u5df1\u7684Web\u5e94\u7528\u7a0b\u5e8f\uff01<\/p>\n","protected":false},"author":1,"featured_media":267877,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-267876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=267876"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267876\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/267877"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=267876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=267876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=267876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}