{"id":43648,"date":"2024-10-06T01:51:41","date_gmt":"2024-10-05T17:51:41","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43648\/"},"modified":"2024-10-06T01:51:41","modified_gmt":"2024-10-05T17:51:41","slug":"centos-7-yum-%e5%ae%89%e8%a3%9d-lnmp-%e4%bb%a5%e5%8f%8a-lamp","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43648\/","title":{"rendered":"CentOS 7 yum \u5b89\u88dd LNMP \u4ee5\u53ca LAMP"},"content":{"rendered":"<h1 id=\"centos-7-yum-%e5%ae%89%e8%a3%9d-lnmp-%e4%bb%a5%e5%8f%8a-lamp-eCsIKtNcOm\">CentOS 7 yum \u5b89\u88dd LNMP \u4ee5\u53ca LAMP<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cLNMP\uff08Linux, Nginx, MySQL, PHP\uff09\u548c LAMP\uff08Linux, Apache, MySQL, PHP\uff09\u662f\u5169\u7a2e\u975e\u5e38\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\u67b6\u69cb\u3002\u9019\u5169\u7a2e\u67b6\u69cb\u5404\u6709\u5176\u7279\u9ede\uff0c\u9069\u5408\u4e0d\u540c\u7684\u61c9\u7528\u5834\u666f\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u4f7f\u7528 yum \u5b89\u88dd LNMP \u548c LAMP \u74b0\u5883\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81lnmp-%e7%92%b0%e5%a2%83%e5%ae%89%e8%a3%9d-eCsIKtNcOm\">\u4e00\u3001LNMP \u74b0\u5883\u5b89\u88dd<\/h2>\n<h3 id=\"1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-eCsIKtNcOm\">1. \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-nginx-eCsIKtNcOm\">2. \u5b89\u88dd Nginx<\/h3>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd Nginx\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install epel-release -y\nsudo yum install nginx -y<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e5%8b%95-nginx-eCsIKtNcOm\">3. \u555f\u52d5 Nginx<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Nginx \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<h3 id=\"4-%e5%ae%89%e8%a3%9d-mysql-eCsIKtNcOm\">4. \u5b89\u88dd MySQL<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd MySQL\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install mariadb-server -y<\/code><\/pre>\n<h3 id=\"5-%e5%95%9f%e5%8b%95-mysql-eCsIKtNcOm\">5. \u555f\u52d5 MySQL<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MySQL \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start mariadb\nsudo systemctl enable mariadb<\/code><\/pre>\n<h3 id=\"6-%e5%ae%89%e8%a3%9d-php-eCsIKtNcOm\">6. \u5b89\u88dd PHP<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd PHP \u53ca\u5176\u76f8\u95dc\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install php php-fpm php-mysql -y<\/code><\/pre>\n<h3 id=\"7-%e9%85%8d%e7%bd%ae-php-fpm-eCsIKtNcOm\">7. \u914d\u7f6e PHP-FPM<\/h3>\n<p>\u7de8\u8f2f PHP-FPM \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u78ba\u4fdd\u5176\u904b\u884c\u5728 Nginx \u4e0b\uff1a<\/p>\n<pre><code>sudo vi \/etc\/php-fpm.d\/www.conf<\/code><\/pre>\n<p>\u5c07\u4ee5\u4e0b\u884c\u7684 user \u548c group \u6539\u70ba nginx\uff1a<\/p>\n<pre><code>user = nginx\ngroup = nginx<\/code><\/pre>\n<h3 id=\"8-%e5%95%9f%e5%8b%95-php-fpm-eCsIKtNcOm\">8. \u555f\u52d5 PHP-FPM<\/h3>\n<p>\u555f\u52d5 PHP-FPM \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start php-fpm\nsudo systemctl enable php-fpm<\/code><\/pre>\n<h3 id=\"9-%e9%85%8d%e7%bd%ae-nginx-eCsIKtNcOm\">9. \u914d\u7f6e Nginx<\/h3>\n<p>\u7de8\u8f2f Nginx \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0 PHP \u652f\u6301\uff1a<\/p>\n<pre><code>sudo vi \/etc\/nginx\/conf.d\/default.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<h3 id=\"10-%e9%87%8d%e5%95%9f-nginx-eCsIKtNcOm\">10. \u91cd\u555f Nginx<\/h3>\n<p>\u6700\u5f8c\uff0c\u91cd\u555f Nginx \u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e4%ba%8c%e3%80%81lamp-%e7%92%b0%e5%a2%83%e5%ae%89%e8%a3%9d-eCsIKtNcOm\">\u4e8c\u3001LAMP \u74b0\u5883\u5b89\u88dd<\/h2>\n<h3 id=\"1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-eCsIKtNcOm\">1. \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-apache-eCsIKtNcOm\">2. \u5b89\u88dd Apache<\/h3>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd Apache\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install httpd -y<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e5%8b%95-apache-eCsIKtNcOm\">3. \u555f\u52d5 Apache<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Apache \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start httpd\nsudo systemctl enable httpd<\/code><\/pre>\n<h3 id=\"4-%e5%ae%89%e8%a3%9d-mysql-eCsIKtNcOm\">4. \u5b89\u88dd MySQL<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd MySQL\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install mariadb-server -y<\/code><\/pre>\n<h3 id=\"5-%e5%95%9f%e5%8b%95-mysql-eCsIKtNcOm\">5. \u555f\u52d5 MySQL<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MySQL \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start mariadb\nsudo systemctl enable mariadb<\/code><\/pre>\n<h3 id=\"6-%e5%ae%89%e8%a3%9d-php-eCsIKtNcOm\">6. \u5b89\u88dd PHP<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd PHP \u53ca\u5176\u76f8\u95dc\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install php php-mysql -y<\/code><\/pre>\n<h3 id=\"7-%e9%87%8d%e5%95%9f-apache-eCsIKtNcOm\">7. \u91cd\u555f Apache<\/h3>\n<p>\u6700\u5f8c\uff0c\u91cd\u555f Apache \u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-eCsIKtNcOm\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u4f7f\u7528 yum \u5b89\u88dd LNMP \u548c LAMP \u74b0\u5883\u3002\u9019\u5169\u7a2e\u67b6\u69cb\u5404\u6709\u5176\u512a\u52e2\uff0c\u6839\u64da\u5be6\u969b\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u67b6\u69cb\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u9069\u5408\u5404\u7a2e\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install LNMP and LAMP on CentOS 7 using yum, with step-by-step instructions for setting up a robust web server environment.<\/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-43648","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43648","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=43648"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43648\/revisions"}],"predecessor-version":[{"id":43649,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43648\/revisions\/43649"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}