{"id":42490,"date":"2024-10-03T15:16:32","date_gmt":"2024-10-03T07:16:32","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42490\/"},"modified":"2024-10-03T15:16:32","modified_gmt":"2024-10-03T07:16:32","slug":"centos-6-5-%e6%ba%90%e7%a2%bc%e7%b7%a8%e8%ad%af%e6%90%ad%e5%bb%ba-lnmp%ef%bc%88%e4%b8%89%e5%8f%b0%e7%8d%a8%e7%ab%8b%e4%b8%bb%e6%a9%9f%e5%af%a6%e7%8f%be%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42490\/","title":{"rendered":"CentOS 6.5 \u6e90\u78bc\u7de8\u8b6f\u642d\u5efa LNMP\uff08\u4e09\u53f0\u7368\u7acb\u4e3b\u6a5f\u5be6\u73fe\uff09"},"content":{"rendered":"<h1 id=\"centos-6-5-%e6%ba%90%e7%a2%bc%e7%b7%a8%e8%ad%af%e6%90%ad%e5%bb%ba-lnmp%ef%bc%88%e4%b8%89%e5%8f%b0%e7%8d%a8%e7%ab%8b%e4%b8%bb%e6%a9%9f%e5%af%a6%e7%8f%be%ef%bc%89-dHCiaLcewu\">CentOS 6.5 \u6e90\u78bc\u7de8\u8b6f\u642d\u5efa LNMP\uff08\u4e09\u53f0\u7368\u7acb\u4e3b\u6a5f\u5be6\u73fe\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cLNMP\uff08Linux, Nginx, MySQL, PHP\uff09\u67b6\u69cb\u56e0\u5176\u9ad8\u6548\u80fd\u548c\u9748\u6d3b\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 6.5 \u4e0a\u901a\u904e\u6e90\u78bc\u7de8\u8b6f\u7684\u65b9\u5f0f\u642d\u5efa LNMP \u74b0\u5883\uff0c\u4e26\u4e14\u4f7f\u7528\u4e09\u53f0\u7368\u7acb\u4e3b\u6a5f\u4f86\u5be6\u73fe\u9019\u4e00\u67b6\u69cb\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-dHCiaLcewu\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6e96\u5099\u4e09\u53f0\u7368\u7acb\u7684\u4e3b\u6a5f\uff0c\u5206\u5225\u7528\u65bc\uff1a<\/p>\n<ul>\n<li>\u4e3b\u6a5f\u4e00\uff1a\u4f5c\u70ba Nginx \u4f3a\u670d\u5668<\/li>\n<li>\u4e3b\u6a5f\u4e8c\uff1a\u4f5c\u70ba MySQL \u4f3a\u670d\u5668<\/li>\n<li>\u4e3b\u6a5f\u4e09\uff1a\u4f5c\u70ba PHP \u4f3a\u670d\u5668<\/li>\n<\/ul>\n<p>\u78ba\u4fdd\u9019\u4e09\u53f0\u4e3b\u6a5f\u90fd\u5df2\u5b89\u88dd CentOS 6.5\uff0c\u4e26\u4e14\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 SSH \u767b\u9304\u5230\u6bcf\u53f0\u4e3b\u6a5f\u9032\u884c\u5f8c\u7e8c\u64cd\u4f5c\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-dHCiaLcewu\">\u5b89\u88dd Nginx<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u5728\u4e3b\u6a5f\u4e00\u4e0a\u5b89\u88dd Nginx\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo yum install gcc pcre-devel zlib-devel make\ncd \/usr\/local\/src\nwget http:\/\/nginx.org\/download\/nginx-1.20.1.tar.gz\ntar -zxvf nginx-1.20.1.tar.gz\ncd nginx-1.20.1\n.\/configure\nmake\nsudo make install\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Nginx\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/nginx\/sbin\/nginx\n<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mysql-dHCiaLcewu\">\u5b89\u88dd MySQL<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5728\u4e3b\u6a5f\u4e8c\u4e0a\u5b89\u88dd MySQL\u3002\u9996\u5148\uff0c\u4e0b\u8f09 MySQL \u7684\u6e90\u78bc\uff1a<\/p>\n<pre><code>sudo yum install cmake ncurses-devel bison\ncd \/usr\/local\/src\nwget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.7\/mysql-5.7.34.tar.gz\ntar -zxvf mysql-5.7.34.tar.gz\ncd mysql-5.7.34\ncmake .\nmake\nsudo make install\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u521d\u59cb\u5316 MySQL \u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/mysql\/bin\/mysqld --initialize --user=mysql\nsudo \/usr\/local\/mysql\/bin\/mysqld_safe --user=mysql &amp;\n<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-dHCiaLcewu\">\u5b89\u88dd PHP<\/h2>\n<p>\u6700\u5f8c\uff0c\u5728\u4e3b\u6a5f\u4e09\u4e0a\u5b89\u88dd PHP\u3002\u9996\u5148\uff0c\u4e0b\u8f09 PHP \u7684\u6e90\u78bc\uff1a<\/p>\n<pre><code>sudo yum install libxml2-devel\ncd \/usr\/local\/src\nwget https:\/\/www.php.net\/distributions\/php-7.4.16.tar.gz\ntar -zxvf php-7.4.16.tar.gz\ncd php-7.4.16\n.\/configure --with-mysqli --with-pdo-mysql --with-nginx\nmake\nsudo make install\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 PHP-FPM\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/sbin\/php-fpm\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-%e8%88%87-php-dHCiaLcewu\">\u914d\u7f6e Nginx \u8207 PHP<\/h2>\n<p>\u5728 Nginx \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u9700\u8981\u8a2d\u7f6e PHP \u7684\u8655\u7406\u65b9\u5f0f\u3002\u7de8\u8f2f Nginx \u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/usr\/local\/nginx\/conf\/nginx.conf\n<\/code><\/pre>\n<p>\u5728 server \u5340\u584a\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>location ~ .php$ {\n    include fastcgi_params;\n    fastcgi_pass 127.0.0.1:9000;\n    fastcgi_index index.php;\n    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n}\n<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f Nginx \u4ee5\u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/nginx\/sbin\/nginx -s reload\n<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-lnmp-%e7%92%b0%e5%a2%83-dHCiaLcewu\">\u6e2c\u8a66 LNMP \u74b0\u5883<\/h2>\n<p>\u5728\u4e3b\u6a5f\u4e00\u7684\u7db2\u9801\u6839\u76ee\u9304\u4e2d\u5275\u5efa\u4e00\u500b PHP \u6e2c\u8a66\u6587\u4ef6\uff1a<\/p>\n<pre><code>echo &lt;?php phpinfo(); ?&gt; &gt; \/usr\/local\/nginx\/html\/info.php\n<\/code><\/pre>\n<p>\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f http:\/\/your_server_ip\/info.php\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230 PHP \u7684\u4fe1\u606f\u9801\u9762\uff0c\u9019\u8868\u793a LNMP \u74b0\u5883\u5df2\u6210\u529f\u642d\u5efa\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-dHCiaLcewu\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728 CentOS 6.5 \u4e0a\u901a\u904e\u6e90\u78bc\u7de8\u8b6f\u7684\u65b9\u5f0f\u642d\u5efa\u4e86 LNMP \u74b0\u5883\uff0c\u4e26\u4f7f\u7528\u4e09\u53f0\u7368\u7acb\u4e3b\u6a5f\u5be6\u73fe\u4e86\u5404\u500b\u7d44\u4ef6\u7684\u5206\u96e2\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6027\u80fd\uff0c\u9084\u589e\u5f37\u4e86\u7cfb\u7d71\u7684\u53ef\u64f4\u5c55\u6027\u548c\u5b89\u5168\u6027\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to compile and set up LNMP on CentOS 6.5 using three independent servers for optimal performance and scalability.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42490","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42490"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42490\/revisions"}],"predecessor-version":[{"id":42491,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42490\/revisions\/42491"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}