{"id":225,"date":"2020-03-18T22:27:05","date_gmt":"2020-03-18T14:27:05","guid":{"rendered":"http:\/\/www.stusc.com\/?p=88"},"modified":"2020-03-18T22:27:05","modified_gmt":"2020-03-18T14:27:05","slug":"%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e5%ad%a6%e5%bb%ba%e7%ab%99%ef%bc%88%e5%9b%9b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.stusc.com\/?p=225","title":{"rendered":"\u4ece\u96f6\u5f00\u59cb\u5b66\u5efa\u7ad9\uff08\u56db\uff09"},"content":{"rendered":"\n<h5 class=\"has-text-align-right wp-block-heading\">\u2014\u2014\u57fa\u4e8eLNMP\u7684\u7f51\u7ad9\u5efa\u8bbe<\/h5>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>\u4e24\u5e74\u524d\uff0c\u6211\u5199\u8fc7\u4e00\u7bc7\u540d\u4e3a\u300a\u4ece\u96f6\u5f00\u59cb\u57fa\u4e8eCentOS7\u914d\u7f6ePHP\u5f00\u53d1\u73af\u5883\u300b\u7684\u5c0f\u6587\uff0c\u73b0\u5728\u65b0\u51a0\u671f\u95f4\u6362\u4e2a\u540d\u5b57\uff0c\u5c06\u5176\u6574\u7406\u4ee5\u5b58\u4e4b\u3002<\/em><\/p><\/blockquote>\n\n\n\n<h5 class=\"has-text-align-center wp-block-heading\">\u56db\u3001\u5b89\u88c5NGINX<\/h5>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5b89\u88c5Nginx\u6e90<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nyum install epel-release -y<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>\u5b89\u88c5Nginx\u670d\u52a1<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nyum install nginx -y<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>\u914d\u7f6eNginx\u670d\u52a1<\/li><\/ol>\n\n\n\n<p>\u4e3a\u4e86\u670d\u52a1\u80fd\u6b63\u5e38\u8fd0\u884c\u53ca\u4e2a\u4eba\u4e60\u60ef\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5bf9nginx\u670d\u52a1\u8fdb\u884c\u4e00\u4e9b\u5fc5\u8981\u7684\u914d\u7f6e\uff0c\u4e3b\u8981\u662f\u4fee\u6539\u4e3b\u76ee\u5f55\u53ca\u5bf9PHP\u7684\u652f\u6301\u3002<\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\n&nbsp;vi \/etc\/nginx\/nginx.conf<\/p>\n\n\n\n<p>\u5148\u4fee\u6539http\u5934\u90e8\u7684index\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Load modular configuration files from the \/etc\/nginx\/conf.d directory. See- http:\/\/nginx.org\/en\/docs\/ngx_core_module.html#include\n# for more information.\ninclude \/etc\/nginx\/conf.d\/*.conf;\n# index   index.php index.html index.htm\uff1b<\/code><\/pre>\n\n\n\n<p> \u6309\u52a8\u65b9\u5411\u952e\uff0c\u5148\u5c06\u5149\u6807\u79fb\u81f3index\u540e\u9762\uff0c\u518d\u6309[i]\u952e\uff0c\u8fdb\u5165\u63d2\u5165\u6a21\u5f0f\uff0c\u5728index.html\u524d\u952e\u5165index.php\uff0c\u7136\u540e\u4f9d\u6b21\u6309[Esc][:][w][q]\u952e\u540e\u56de\u8f66\u3002 <\/p>\n\n\n\n<p style=\"font-size:12px\" class=\"has-background has-very-light-gray-background-color\">vi\u662fLinux\u7cfb\u7edf\u4e2d\u975e\u5e38\u5f3a\u5927\u7684\u4e00\u4e2a\u5de5\u5177\u4e86\uff0c\u5b83\u7684\u4f7f\u7528\u65b9\u6cd5\u5b8c\u5168\u53ef\u4ee5\u53e6\u8d77\u4e00\u7bc7\u6587\u7ae0\uff0c\u672c\u6587\u53ea\u662f\u4f7f\u7528\u4e86\u6700\u7b80\u5355\u7684\u529f\u80fd\uff0c\u5e38\u7528\u64cd\u4f5c\u5982\u4e0b\uff0c\u540e\u6587\u4e0d\u518d\u8be6\u8ff0\u3002<br> \u6253\u5f00\u6587\u6863 vi [\u8def\u5f84]<br> \u7f16\u8f91\u6a21\u5f0f i<br> \u547d\u4ee4\u6a21\u5f0f Esc:<br> \u4fdd\u5b58\u9000\u51fa wq<br> \u76f4\u63a5\u9000\u51fa q!<\/p>\n\n\n\n<p> \u63a5\u4e0b\u6765\u4fee\u6539server\u5b57\u6bb5\u4e2d\u7684listen\u7aef\u53e3\uff08\u73b0\u5728\u7f51\u7edc\u8fd0\u8425\u5546\u5927\u89c4\u6a21\u5c0180\uff0c\u5982\u679c\u662f\u81ea\u5efa\u670d\u52a1\u5668\u5efa\u8bae\u4fee\u6539\u9ed8\u8ba4\u7aef\u53e31025- 65535\u4e4b\u95f4\uff09\u548croot\u4e3b\u76ee\u5f55\u53caindex\u7d22\u5f15\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n\n        listen       80;\n        listen       [::]:80 default_server;\n        server_name  localhost;\n        root         \/var\/www\/html;\n\n        # Load configuration files for the default server block.\n        include \/etc\/nginx\/default.d\/*.conf;\n       \n        location \/ {\n        #\u7701\u7565\u4e2d\u95f4N\u591a\u4ee3\u7801\u2026\u2026\n        }        \n\n       }<\/code><\/pre>\n\n\n\n<p> \u518d\u8c03\u6574 server\u4e2dlocation \/{}\u7684\u53c2\u6570 \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        location \/ {\n        root   \/var\/www\/html;\n        index  index.php index.html index.htm;\n        }\n\n        # redirect server error pages to the static page \/40x.html\n        #\n        error_page 404 \/404.html;\n            location = \/40x.html {\n        }<\/code><\/pre>\n\n\n\n<p> \u7136\u540e\u8c03\u6574 server\u4e2dlocation ~\\.php${}\u7684\u53c2\u6570 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location ~ \\.php$ {\nroot \t\/var\/www\/html;\nfastcgi_pass   127.0.0.1:9000;\nfastcgi_index  index.php;\nfastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\ninclude        fastcgi_params;\n}<\/code><\/pre>\n\n\n\n<p> \u4e0b\u9762\u6211\u4eec\u8981\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u653eHttp\u7684\u7aef\u53e3\uff08\u5982\u679c\u4f60\u4fee\u6539\u4e86\u7aef\u53e3\u53f7\uff0c\u8bf7\u5c06\u4e0b\u9762\u768480\u6539\u4e3a\u4f60\u81ea\u5b9a\u4e49\u7684\u7aef\u53e3\u53f7\uff09\uff0c\u5e76\u91cd\u542f\u9632\u706b\u5899\u3002 <\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl restart&nbsp; firewalld<\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nfirewall-cmd &#8211;zone=public &#8211;add-port=80\/tcp &#8211;permanent<\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nfirewall-cmd &#8211;zone=public &#8211;add-port=443\/tcp &#8211;permanent<\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo firewall-cmd &#8211;reload<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>\u914d\u7f6ephp-fpm\u670d\u52a1<\/li><\/ol>\n\n\n\n<p>\u8fd9\u91cc\u9700\u8981\u5c06php-fpm\u7684\u8fd0\u884c\u7528\u6237\u4fe1\u606f\u6539\u4e3anginx<\/p>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo vi \/etc\/php-fpm.d\/www.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; Unix user\/group of processes\n; Note: The user is mandatory. If the group is not set, the default user's group\n;       will be used.\n; RPM: apache Choosed to be able to access some dir as httpd\nuser = nginx\n; RPM: Keep a group allowed to write in log dir.\ngroup = nginx<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>\u542f\u52a8MySQL\u670d\u52a1<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\"> $sudo systemctl start mysqld <\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\"><li>\u542f\u52a8php-fpm\u670d\u52a1<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo systemctl start php-fpm<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\"><li>\u542f\u52a8Nginx\u670d\u52a1<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl start nginx<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"8\"><li>\u8bbe\u7f6eMySQL\u670d\u52a1\u81ea\u542f\u52a8\u9879<\/li><\/ol>\n\n\n\n<p class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl enable mysqld<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\"><li>\u8bbe\u7f6enginx\u670d\u52a1\u81ea\u542f\u52a8\u9879<\/li><\/ol>\n\n\n\n<p class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo systemctl enable nginx<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"10\"><li>\u8bbe\u7f6ephp-fpm\u670d\u52a1\u81ea\u542f\u52a8\u9879<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl enable php-fpm<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"11\"><li>\u91cd\u8f7d\u670d\u52a1\u914d\u7f6e<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl daemon-reload<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"12\"><li>\u67e5\u770b\u670d\u52a1\u72b6\u6001<\/li><\/ol>\n\n\n\n<p style=\"font-size:14px\" class=\"has-text-color has-background has-very-light-gray-color has-very-dark-gray-background-color\">$sudo\nsystemctl | grep running<strong><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2014\u2014\u57fa\u4e8eLNMP\u7684\u7f51\u7ad9\u5efa\u8bbe \u4e24\u5e74\u524d\uff0c\u6211\u5199\u8fc7\u4e00\u7bc7\u540d\u4e3a\u300a\u4ece\u96f6\u5f00\u59cb\u57fa\u4e8eCentOS7\u914d\u7f6ePHP\u5f00\u53d1\u73af\u5883\u300b\u7684&hellip; <a href=\"https:\/\/www.stusc.com\/?p=225\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u4ece\u96f6\u5f00\u59cb\u5b66\u5efa\u7ad9\uff08\u56db\uff09<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[30],"class_list":{"0":"post-225","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-tech","7":"tag-nginx","8":"h-entry","10":"h-as-article"},"_links":{"self":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=225"}],"version-history":[{"count":0,"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts\/225\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}