{"id":43358,"date":"2024-10-05T13:41:39","date_gmt":"2024-10-05T05:41:39","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43358\/"},"modified":"2024-10-05T13:41:40","modified_gmt":"2024-10-05T05:41:40","slug":"centos-7-%e6%ba%90%e7%a2%bc%e7%b7%a8%e8%ad%af%e5%ae%89%e8%a3%9d-php-5-6-%e5%92%8c-nginx-1-7-9-%e5%8f%8a-mysql%ef%bc%88%e6%90%ad%e5%bb%ba-lnmp-%e7%92%b0%e5%a2%83%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43358\/","title":{"rendered":"CentOS 7 \u6e90\u78bc\u7de8\u8b6f\u5b89\u88dd PHP 5.6 \u548c Nginx 1.7.9 \u53ca MySQL\uff08\u642d\u5efa LNMP \u74b0\u5883\uff09"},"content":{"rendered":"<h1 id=\"centos-7-%e6%ba%90%e7%a2%bc%e7%b7%a8%e8%ad%af%e5%ae%89%e8%a3%9d-php-5-6-%e5%92%8c-nginx-1-7-9-%e5%8f%8a-mysql%ef%bc%88%e6%90%ad%e5%bb%ba-lnmp-%e7%92%b0%e5%a2%83%ef%bc%89-PqsuPCESrs\">CentOS 7 \u6e90\u78bc\u7de8\u8b6f\u5b89\u88dd PHP 5.6 \u548c Nginx 1.7.9 \u53ca MySQL\uff08\u642d\u5efa LNMP \u74b0\u5883\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\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7 \u4e0a\u6e90\u78bc\u7de8\u8b6f\u5b89\u88dd PHP 5.6\u3001Nginx 1.7.9 \u548c MySQL\uff0c\u5f9e\u800c\u642d\u5efa\u4e00\u500b LNMP \u74b0\u5883\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-PqsuPCESrs\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd\u4e00\u4e9b\u5fc5\u8981\u7684\u4f9d\u8cf4\u5305\uff1a<\/p>\n<pre><code>sudo yum install -y gcc make autoconf bison flex libtool \n    libxml2-devel openssl-devel curl-devel \n    libjpeg-devel libpng-devel freetype-devel \n    gmp-devel mariadb-devel<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-PqsuPCESrs\">\u5b89\u88dd Nginx<\/h2>\n<p>\u9996\u5148\uff0c\u4e0b\u8f09 Nginx 1.7.9 \u7684\u6e90\u78bc\uff1a<\/p>\n<pre><code>wget http:\/\/nginx.org\/download\/nginx-1.7.9.tar.gz<\/code><\/pre>\n<p>\u89e3\u58d3\u7e2e\u4e0b\u8f09\u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar -zxvf nginx-1.7.9.tar.gz<\/code><\/pre>\n<p>\u9032\u5165\u89e3\u58d3\u5f8c\u7684\u76ee\u9304\uff1a<\/p>\n<pre><code>cd nginx-1.7.9<\/code><\/pre>\n<p>\u914d\u7f6e Nginx\uff0c\u7136\u5f8c\u7de8\u8b6f\u548c\u5b89\u88dd\uff1a<\/p>\n<pre><code>.\/configure --prefix=\/usr\/local\/nginx \n    --sbin-path=\/usr\/local\/nginx\/sbin\/nginx \n    --conf-path=\/usr\/local\/nginx\/conf\/nginx.conf \n    --error-log-path=\/usr\/local\/nginx\/logs\/error.log \n    --http-log-path=\/usr\/local\/nginx\/logs\/access.log \n    --with-http_ssl_module<\/code><\/pre>\n<pre><code>make &amp;&amp; sudo make install<\/code><\/pre>\n<p>\u555f\u52d5 Nginx\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/nginx\/sbin\/nginx<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mysql-PqsuPCESrs\">\u5b89\u88dd MySQL<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u4e0b\u8f09 MySQL \u7684\u6e90\u78bc\u3002\u9019\u88e1\u4ee5 MySQL 5.7 \u70ba\u4f8b\uff1a<\/p>\n<pre><code>wget https:\/\/dev.mysql.com\/get\/Downloads\/MySQL-5.7\/mysql-5.7.34.tar.gz<\/code><\/pre>\n<p>\u89e3\u58d3\u7e2e\u4e26\u9032\u5165\u76ee\u9304\uff1a<\/p>\n<pre><code>tar -zxvf mysql-5.7.34.tar.gz\ncd mysql-5.7.34<\/code><\/pre>\n<p>\u914d\u7f6e MySQL\uff0c\u7136\u5f8c\u7de8\u8b6f\u548c\u5b89\u88dd\uff1a<\/p>\n<pre><code>cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=.\/boost \n    -DCMAKE_INSTALL_PREFIX=\/usr\/local\/mysql<\/code><\/pre>\n<pre><code>make &amp;&amp; sudo make install<\/code><\/pre>\n<p>\u521d\u59cb\u5316 MySQL \u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/mysql\/bin\/mysqld --initialize --user=mysql<\/code><\/pre>\n<p>\u555f\u52d5 MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/mysql\/bin\/mysqld_safe --user=mysql &amp;<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-5-6-PqsuPCESrs\">\u5b89\u88dd PHP 5.6<\/h2>\n<p>\u4e0b\u8f09 PHP 5.6 \u7684\u6e90\u78bc\uff1a<\/p>\n<pre><code>wget https:\/\/www.php.net\/distributions\/php-5.6.40.tar.gz<\/code><\/pre>\n<p>\u89e3\u58d3\u7e2e\u4e26\u9032\u5165\u76ee\u9304\uff1a<\/p>\n<pre><code>tar -zxvf php-5.6.40.tar.gz\ncd php-5.6.40<\/code><\/pre>\n<p>\u914d\u7f6e PHP\uff0c\u7136\u5f8c\u7de8\u8b6f\u548c\u5b89\u88dd\uff1a<\/p>\n<pre><code>.\/configure --prefix=\/usr\/local\/php \n    --with-mysqli=\/usr\/local\/mysql\/bin\/mysql_config \n    --with-pdo-mysql=\/usr\/local\/mysql \n    --with-openssl \n    --enable-mbstring \n    --enable-soap \n    --enable-intl<\/code><\/pre>\n<pre><code>make &amp;&amp; sudo make install<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-%e8%88%87-php-PqsuPCESrs\">\u914d\u7f6e Nginx \u8207 PHP<\/h2>\n<p>\u7de8\u8f2f Nginx \u914d\u7f6e\u6587\u4ef6\u4ee5\u652f\u6301 PHP\uff1a<\/p>\n<pre><code>sudo vi \/usr\/local\/nginx\/conf\/nginx.conf<\/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}<\/code><\/pre>\n<p>\u91cd\u555f Nginx \u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo \/usr\/local\/nginx\/sbin\/nginx -s reload<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-PqsuPCESrs\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u6210\u529f\u5728 CentOS 7 \u4e0a\u6e90\u78bc\u7de8\u8b6f\u5b89\u88dd\u4e86 PHP 5.6\u3001Nginx 1.7.9 \u548c MySQL\uff0c\u642d\u5efa\u4e86\u4e00\u500b LNMP \u74b0\u5883\u3002\u9019\u6a23\u7684\u74b0\u5883\u4e0d\u50c5\u80fd\u5920\u652f\u6301\u5404\u7a2e Web \u61c9\u7528\uff0c\u9084\u80fd\u63d0\u4f9b\u9ad8\u6548\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u914d\u7f6e\u9078\u9805\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 install PHP 5.6, Nginx 1.7.9, and MySQL on CentOS 7 to set up a robust LNMP environment. Step-by-step guide included.<\/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-43358","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43358","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=43358"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43358\/revisions"}],"predecessor-version":[{"id":43359,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43358\/revisions\/43359"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}