{"id":43526,"date":"2024-10-05T20:46:37","date_gmt":"2024-10-05T12:46:37","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43526\/"},"modified":"2024-10-05T20:46:37","modified_gmt":"2024-10-05T12:46:37","slug":"centos-%e8%88%87-ubuntu-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e6%90%ad%e5%bb%ba-lamp-%e7%92%b0%e5%a2%83","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43526\/","title":{"rendered":"CentOS \u8207 Ubuntu \u4f7f\u7528\u547d\u4ee4\u642d\u5efa LAMP \u74b0\u5883"},"content":{"rendered":"<h1 id=\"centos-%e8%88%87-ubuntu-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e6%90%ad%e5%bb%ba-lamp-%e7%92%b0%e5%a2%83-CLEnnMRSWt\">CentOS \u8207 Ubuntu \u4f7f\u7528\u547d\u4ee4\u642d\u5efa LAMP \u74b0\u5883<\/h1>\n<p>LAMP \u74b0\u5883\u662f\u6307 Linux\u3001Apache\u3001MySQL \u548c PHP \u7684\u7d44\u5408\uff0c\u9019\u662f\u4e00\u500b\u975e\u5e38\u6d41\u884c\u7684\u958b\u767c\u548c\u90e8\u7f72\u5e73\u53f0\uff0c\u7279\u5225\u9069\u5408\u65bc\u7db2\u9801\u61c9\u7528\u7a0b\u5f0f\u7684\u958b\u767c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS \u548c Ubuntu \u7cfb\u7d71\u4e0a\u4f7f\u7528\u547d\u4ee4\u884c\u642d\u5efa LAMP \u74b0\u5883\u3002<\/p>\n<h2 id=\"%e5%9c%a8-centos-%e4%b8%8a%e6%90%ad%e5%bb%ba-lamp-%e7%92%b0%e5%a2%83-CLEnnMRSWt\">\u5728 CentOS \u4e0a\u642d\u5efa LAMP \u74b0\u5883<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-CLEnnMRSWt\">\u6b65\u9a5f 1: \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2-%e5%ae%89%e8%a3%9d-apache-CLEnnMRSWt\">\u6b65\u9a5f 2: \u5b89\u88dd Apache<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Apache \u7db2\u9801\u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo yum install httpd -y<\/code><\/pre>\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=\"%e6%ad%a5%e9%a9%9f-3-%e5%ae%89%e8%a3%9d-mysql-CLEnnMRSWt\">\u6b65\u9a5f 3: \u5b89\u88dd MySQL<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd MySQL \u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo yum install mariadb-server -y<\/code><\/pre>\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<p>\u7136\u5f8c\uff0c\u57f7\u884c\u5b89\u5168\u6027\u8173\u672c\u4ee5\u52a0\u5f37 MySQL \u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-4-%e5%ae%89%e8%a3%9d-php-CLEnnMRSWt\">\u6b65\u9a5f 4: \u5b89\u88dd PHP<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd PHP \u53ca\u5176\u5e38\u7528\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install php php-mysql -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f Apache \u4ee5\u4f7f PHP \u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-5-%e6%b8%ac%e8%a9%a6-lamp-%e7%92%b0%e5%a2%83-CLEnnMRSWt\">\u6b65\u9a5f 5: \u6e2c\u8a66 LAMP \u74b0\u5883<\/h3>\n<p>\u5728 \/var\/www\/html \u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b PHP \u6e2c\u8a66\u6587\u4ef6\uff1a<\/p>\n<pre><code>echo \"\" | sudo tee \/var\/www\/html\/info.php<\/code><\/pre>\n<p>\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f <code>http:\/\/your_server_ip\/info.php<\/code>\uff0c\u5982\u679c\u770b\u5230 PHP \u4fe1\u606f\u9801\u9762\uff0c\u5247\u8868\u793a LAMP \u74b0\u5883\u642d\u5efa\u6210\u529f\u3002<\/p>\n<h2 id=\"%e5%9c%a8-ubuntu-%e4%b8%8a%e6%90%ad%e5%bb%ba-lamp-%e7%92%b0%e5%a2%83-CLEnnMRSWt\">\u5728 Ubuntu \u4e0a\u642d\u5efa LAMP \u74b0\u5883<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-CLEnnMRSWt\">\u6b65\u9a5f 1: \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2-%e5%ae%89%e8%a3%9d-apache-CLEnnMRSWt\">\u6b65\u9a5f 2: \u5b89\u88dd Apache<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Apache \u7db2\u9801\u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo apt install apache2 -y<\/code><\/pre>\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 apache2\nsudo systemctl enable apache2<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-3-%e5%ae%89%e8%a3%9d-mysql-CLEnnMRSWt\">\u6b65\u9a5f 3: \u5b89\u88dd MySQL<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd MySQL \u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo apt install mysql-server -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u57f7\u884c\u5b89\u5168\u6027\u8173\u672c\u4ee5\u52a0\u5f37 MySQL \u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-4-%e5%ae%89%e8%a3%9d-php-CLEnnMRSWt\">\u6b65\u9a5f 4: \u5b89\u88dd PHP<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd PHP \u53ca\u5176\u5e38\u7528\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo apt install php libapache2-mod-php php-mysql -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f Apache \u4ee5\u4f7f PHP \u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-5-%e6%b8%ac%e8%a9%a6-lamp-%e7%92%b0%e5%a2%83-CLEnnMRSWt\">\u6b65\u9a5f 5: \u6e2c\u8a66 LAMP \u74b0\u5883<\/h3>\n<p>\u5728 \/var\/www\/html \u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b PHP \u6e2c\u8a66\u6587\u4ef6\uff1a<\/p>\n<pre><code>echo \"\" | sudo tee \/var\/www\/html\/info.php<\/code><\/pre>\n<p>\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f <code>http:\/\/your_server_ip\/info.php<\/code>\uff0c\u5982\u679c\u770b\u5230 PHP \u4fe1\u606f\u9801\u9762\uff0c\u5247\u8868\u793a LAMP \u74b0\u5883\u642d\u5efa\u6210\u529f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-CLEnnMRSWt\">\u7e3d\u7d50<\/h2>\n<p>\u7121\u8ad6\u662f\u5728 CentOS \u9084\u662f Ubuntu \u4e0a\uff0c\u642d\u5efa LAMP \u74b0\u5883\u7684\u904e\u7a0b\u90fd\u76f8\u5c0d\u7c21\u55ae\u3002\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u5feb\u901f\u8a2d\u7f6e\u4e00\u500b\u529f\u80fd\u9f4a\u5168\u7684\u4f3a\u670d\u5668\u74b0\u5883\uff0c\u9069\u5408\u958b\u767c\u548c\u90e8\u7f72\u5404\u985e\u7db2\u9801\u61c9\u7528\u7a0b\u5f0f\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS \u548c Ubuntu \u4e0a\u4f7f\u7528\u547d\u4ee4\u642d\u5efa LAMP \u74b0\u5883\uff0c\u5feb\u901f\u90e8\u7f72\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u7684\u5b8c\u6574\u6307\u5357\u3002<\/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-43526","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43526","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=43526"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43526\/revisions"}],"predecessor-version":[{"id":43527,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43526\/revisions\/43527"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}