{"id":42992,"date":"2024-10-04T12:21:32","date_gmt":"2024-10-04T04:21:32","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42992\/"},"modified":"2024-10-04T12:21:33","modified_gmt":"2024-10-04T04:21:33","slug":"centos-7-3-%e4%b8%8b%e9%85%8d%e7%bd%ae-apache2-4-mysql5-7-php7-1-8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42992\/","title":{"rendered":"CentOS 7.3 \u4e0b\u914d\u7f6e Apache2.4 + MySQL5.7 + PHP7.1.8"},"content":{"rendered":"<h1 id=\"centos-7-3-%e4%b8%8b%e9%85%8d%e7%bd%ae-apache-2-4-mysql-5-7-php-7-1-8-wJpyZkINFQ\">CentOS 7.3 \u4e0b\u914d\u7f6e Apache 2.4 + MySQL 5.7 + PHP 7.1.8<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cApache\u3001MySQL \u548c PHP\uff08\u901a\u5e38\u88ab\u7a31\u70ba LAMP \u5806\u758a\uff09\u662f\u6700\u53d7\u6b61\u8fce\u7684\u958b\u767c\u74b0\u5883\u4e4b\u4e00\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7.3 \u4e0a\u914d\u7f6e Apache 2.4\u3001MySQL 5.7 \u548c PHP 7.1.8\uff0c\u8b93\u60a8\u80fd\u5920\u5feb\u901f\u642d\u5efa\u4e00\u500b\u529f\u80fd\u5f37\u5927\u7684\u7db2\u7ad9\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-wJpyZkINFQ\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684 CentOS 7.3 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd EPEL\uff08Extra Packages for Enterprise Linux\uff09\u5eab\uff0c\u9019\u662f\u8a31\u591a\u984d\u5916\u8edf\u4ef6\u5305\u7684\u4f86\u6e90\uff1a<\/p>\n<pre><code>sudo yum install epel-release -y<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-apache-2-4-wJpyZkINFQ\">\u5b89\u88dd Apache 2.4<\/h2>\n<p>Apache \u662f\u4e00\u500b\u958b\u6e90\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5b89\u88dd\u904e\u7a0b\u975e\u5e38\u7c21\u55ae\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Apache\uff1a<\/p>\n<pre><code>sudo yum install httpd -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Apache \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start httpd\nsudo systemctl enable httpd<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u8a2a\u554f <a href=\"http:\/\/your_server_ip\" rel=\"nofollow\">http:\/\/your_server_ip<\/a> \u4f86\u6aa2\u67e5 Apache \u662f\u5426\u904b\u884c\u6b63\u5e38\u3002\u5982\u679c\u770b\u5230 Apache \u7684\u6e2c\u8a66\u9801\u9762\uff0c\u5247\u8868\u793a\u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mysql-5-7-wJpyZkINFQ\">\u5b89\u88dd MySQL 5.7<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u5c07\u5b89\u88dd MySQL\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u6dfb\u52a0 MySQL \u7684 Yum \u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo rpm -Uvh https:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-11.noarch.rpm<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MySQL\uff1a<\/p>\n<pre><code>sudo yum install mysql-community-server -y<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MySQL \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start mysqld\nsudo systemctl enable mysqld<\/code><\/pre>\n<p>\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0cMySQL \u6703\u81ea\u52d5\u751f\u6210\u4e00\u500b\u81e8\u6642\u5bc6\u78bc\uff0c\u60a8\u53ef\u4ee5\u5728 \/var\/log\/mysqld.log \u6587\u4ef6\u4e2d\u627e\u5230\u5b83\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u8a72\u5bc6\u78bc\uff1a<\/p>\n<pre><code>sudo grep 'temporary password' \/var\/log\/mysqld.log<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u8a72\u5bc6\u78bc\u767b\u9304 MySQL \u4e26\u9032\u884c\u521d\u59cb\u914d\u7f6e\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u767b\u9304\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u6539 root \u5bc6\u78bc\u4e26\u9032\u884c\u5b89\u5168\u914d\u7f6e\uff1a<\/p>\n<pre><code>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';\nmysql_secure_installation<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-7-1-8-wJpyZkINFQ\">\u5b89\u88dd PHP 7.1.8<\/h2>\n<p>\u6700\u5f8c\uff0c\u6211\u5011\u5c07\u5b89\u88dd PHP\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd PHP \u7684 Yum \u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo yum install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm -y<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u555f\u7528 PHP 7.1 \u7684\u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo yum-config-manager --enable remi-php71<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd PHP \u53ca\u5176\u5e38\u7528\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install php php-mysql php-gd php-xml php-mbstring -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<h2 id=\"%e6%b8%ac%e8%a9%a6-php-wJpyZkINFQ\">\u6e2c\u8a66 PHP<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fdd PHP \u6b63\u5e38\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 PHP \u6e2c\u8a66\u6587\u4ef6\u3002\u5728 \/var\/www\/html \u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b\u540d\u70ba info.php \u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>echo &lt;?php phpinfo(); ?&gt; &gt; \/var\/www\/html\/info.php<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u901a\u904e\u8a2a\u554f <a href=\"http:\/\/your_server_ip\/info.php\" rel=\"nofollow\">http:\/\/your_server_ip\/info.php<\/a> \u4f86\u67e5\u770b PHP \u7684\u914d\u7f6e\u4fe1\u606f\u3002\u5982\u679c\u60a8\u80fd\u770b\u5230 PHP \u4fe1\u606f\u9801\u9762\uff0c\u5247\u8868\u793a PHP \u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-wJpyZkINFQ\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728 CentOS 7.3 \u4e0a\u914d\u7f6e\u4e86 Apache 2.4\u3001MySQL 5.7 \u548c PHP 7.1.8\u3002\u9019\u500b LAMP \u5806\u758a\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u4e86\u7a69\u5b9a\u7684\u57fa\u790e\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to configure Apache 2.4, MySQL 5.7, and PHP 7.1.8 on CentOS 7.3 for a robust web development 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-42992","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42992","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=42992"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42992\/revisions"}],"predecessor-version":[{"id":42993,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42992\/revisions\/42993"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}