{"id":43300,"date":"2024-10-05T01:12:02","date_gmt":"2024-10-04T17:12:02","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43300\/"},"modified":"2024-10-05T01:12:02","modified_gmt":"2024-10-04T17:12:02","slug":"centos-7-%e4%b8%8b%e5%ae%89%e8%a3%9d%e9%85%8d%e7%bd%ae-php-7-%e8%b7%9f-lamp-%e5%8f%8a-mongodb-%e5%92%8c-redis","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43300\/","title":{"rendered":"CentOS 7 \u4e0b\u5b89\u88dd\u914d\u7f6e PHP 7 \u8ddf LAMP \u53ca MongoDB \u548c Redis"},"content":{"rendered":"<h1 id=\"centos-7-%e4%b8%8b%e5%ae%89%e8%a3%9d%e9%85%8d%e7%bd%ae-php-7-%e8%b7%9f-lamp-%e5%8f%8a-mongodb-%e5%92%8c-redis-chaCXUDaED\">CentOS 7 \u4e0b\u5b89\u88dd\u914d\u7f6e PHP 7 \u8ddf LAMP \u53ca MongoDB \u548c Redis<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cLAMP\uff08Linux, Apache, MySQL, PHP\uff09\u5806\u758a\u662f\u6700\u5e38\u898b\u7684\u7db2\u9801\u4f3a\u670d\u5668\u67b6\u69cb\u4e4b\u4e00\u3002\u96a8\u8457 PHP 7 \u7684\u63a8\u51fa\uff0c\u6027\u80fd\u548c\u6548\u7387\u6709\u4e86\u986f\u8457\u63d0\u5347\u3002\u6b64\u5916\uff0cMongoDB \u548c Redis \u4e5f\u6210\u70ba\u4e86\u6d41\u884c\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e PHP 7\u3001LAMP\u3001MongoDB \u548c Redis\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-lamp-%e7%92%b0%e5%a2%83-chaCXUDaED\">\u5b89\u88dd 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-chaCXUDaED\">\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-chaCXUDaED\">\u6b65\u9a5f 2: \u5b89\u88dd Apache<\/h3>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\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-php-7-chaCXUDaED\">\u6b65\u9a5f 3: \u5b89\u88dd PHP 7<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd PHP 7 \u53ca\u5176\u5e38\u7528\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install epel-release -y\nsudo yum install -y https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\nsudo yum install -y yum-utils\nsudo yum-config-manager --enable remi-php74\nsudo yum install php php-mysql php-mbstring php-xml php-json php-cli<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f Apache \u4ee5\u52a0\u8f09 PHP\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-4-%e6%b8%ac%e8%a9%a6-php-chaCXUDaED\">\u6b65\u9a5f 4: \u6e2c\u8a66 PHP<\/h3>\n<p>\u5728 \/var\/www\/html \u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b\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 <a href=\"http:\/\/your_server_ip\/info.php\" rel=\"nofollow\">http:\/\/your_server_ip\/info.php<\/a>\uff0c\u5982\u679c\u770b\u5230 PHP \u4fe1\u606f\u9801\u9762\uff0c\u5247\u8868\u793a PHP \u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mongodb-chaCXUDaED\">\u5b89\u88dd MongoDB<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1-%e6%b7%bb%e5%8a%a0-mongodb-%e5%ad%98%e5%84%b2%e5%ba%ab-chaCXUDaED\">\u6b65\u9a5f 1: \u6dfb\u52a0 MongoDB \u5b58\u5132\u5eab<\/h3>\n<p>\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b MongoDB \u5b58\u5132\u5eab\u6587\u4ef6\uff1a<\/p>\n<pre><code>echo \"[mongodb-org-4.4]\nname=MongoDB Repository\nbaseurl=https:\/\/repo.mongodb.org\/yum\/redhat\/7\/multilib\/mongodb-org\/4.4\/x86_64\/\ngpgcheck=1\nenabled=1\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-4.4.asc\" | sudo tee \/etc\/yum.repos.d\/mongodb-org-4.4.repo<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2-%e5%ae%89%e8%a3%9d-mongodb-chaCXUDaED\">\u6b65\u9a5f 2: \u5b89\u88dd MongoDB<\/h3>\n<pre><code>sudo yum install -y mongodb-org<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MongoDB \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start mongod\nsudo systemctl enable mongod<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-redis-chaCXUDaED\">\u5b89\u88dd Redis<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1-%e5%ae%89%e8%a3%9d-epel-%e5%ad%98%e5%84%b2%e5%ba%ab-chaCXUDaED\">\u6b65\u9a5f 1: \u5b89\u88dd EPEL \u5b58\u5132\u5eab<\/h3>\n<pre><code>sudo yum install epel-release -y<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2-%e5%ae%89%e8%a3%9d-redis-chaCXUDaED\">\u6b65\u9a5f 2: \u5b89\u88dd Redis<\/h3>\n<pre><code>sudo yum install redis -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Redis \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start redis\nsudo systemctl enable redis<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-chaCXUDaED\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u6211\u5011\u6210\u529f\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e\u4e86 PHP 7\u3001LAMP \u74b0\u5883\u3001MongoDB \u548c Redis\u3002\u9019\u4e9b\u6280\u8853\u7684\u7d50\u5408\u80fd\u5920\u70ba\u958b\u767c\u8005\u63d0\u4f9b\u5f37\u5927\u7684\u652f\u6301\uff0c\u7121\u8ad6\u662f\u69cb\u5efa\u52d5\u614b\u7db2\u7ad9\u9084\u662f\u9ad8\u6548\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002\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 install and configure PHP 7, LAMP stack, MongoDB, and Redis on CentOS 7 for a robust web development 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-43300","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43300","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=43300"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43300\/revisions"}],"predecessor-version":[{"id":43301,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43300\/revisions\/43301"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}