{"id":45024,"date":"2024-10-06T19:54:15","date_gmt":"2024-10-06T11:54:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45024\/"},"modified":"2024-10-06T19:54:15","modified_gmt":"2024-10-06T11:54:15","slug":"rhel%e3%80%81centos-%e4%b8%ad%e5%ae%89%e8%a3%9d-drupal-8-%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45024\/","title":{"rendered":"RHEL\u3001CentOS \u4e2d\u5b89\u88dd Drupal 8 \u5177\u9ad4\u6b65\u9a5f"},"content":{"rendered":"<h1 id=\"%e5%9c%a8-rhel-%e5%92%8c-centos-%e4%b8%ad%e5%ae%89%e8%a3%9d-drupal-8-%e7%9a%84%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f-XKJxMNVLwR\">\u5728 RHEL \u548c CentOS \u4e2d\u5b89\u88dd Drupal 8 \u7684\u5177\u9ad4\u6b65\u9a5f<\/h1>\n<p>Drupal \u662f\u4e00\u500b\u5f37\u5927\u7684\u5167\u5bb9\u7ba1\u7406\u7cfb\u7d71\uff08CMS\uff09\uff0c\u5ee3\u6cdb\u7528\u65bc\u5efa\u7acb\u5404\u7a2e\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 RHEL\uff08Red Hat Enterprise Linux\uff09\u548c CentOS \u7cfb\u7d71\u4e0a\u5b89\u88dd Drupal 8 \u7684\u5177\u9ad4\u6b65\u9a5f\u3002\u9019\u4e9b\u6b65\u9a5f\u9069\u5408\u5e0c\u671b\u5728\u81ea\u5df1\u7684\u4f3a\u670d\u5668\u4e0a\u904b\u884c Drupal \u7684\u958b\u767c\u8005\u548c\u7cfb\u7d71\u7ba1\u7406\u54e1\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-XKJxMNVLwR\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u5df2\u7d93\u5b89\u88dd\u4e86\u4ee5\u4e0b\u8edf\u9ad4\uff1a<\/p>\n<ul>\n<li>Apache \u6216 Nginx \u7db2\u9801\u4f3a\u670d\u5668<\/li>\n<li>PHP 7.0 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>MySQL 5.7 \u6216 MariaDB 10.0 \u4ee5\u4e0a\u7248\u672c<\/li>\n<li>Composer\uff08PHP \u7684\u4f9d\u8cf4\u7ba1\u7406\u5de5\u5177\uff09<\/li>\n<\/ul>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\u9019\u4e9b\u4f9d\u8cf4\uff1a<\/p>\n<pre><code>sudo yum install httpd php php-mysqlnd php-xml php-mbstring php-json php-zip php-gd\nsudo yum install mariadb-server\nsudo systemctl start mariadb\nsudo systemctl enable mariadb<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-mysql-%e6%95%b8%e6%93%9a%e5%ba%ab-XKJxMNVLwR\">\u914d\u7f6e MySQL \u6578\u64da\u5eab<\/h2>\n<p>\u5728\u5b89\u88dd Drupal \u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u6578\u64da\u5eab\u548c\u7528\u6236\u3002\u8acb\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\uff1a<\/p>\n<pre><code>mysql_secure_installation<\/code><\/pre>\n<p>\u9019\u500b\u547d\u4ee4\u5c07\u5f15\u5c0e\u60a8\u8a2d\u7f6e MySQL \u7684\u5b89\u5168\u6027\uff0c\u5305\u62ec\u8a2d\u7f6e root \u5bc6\u78bc\u548c\u522a\u9664\u533f\u540d\u7528\u6236\u7b49\u3002\u63a5\u4e0b\u4f86\uff0c\u767b\u9304 MySQL \u4e26\u5275\u5efa\u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>mysql -u root -p\nCREATE DATABASE drupaldb;\nCREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';\nGRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-composer-XKJxMNVLwR\">\u5b89\u88dd Composer<\/h2>\n<p>Composer \u662f PHP \u7684\u4f9d\u8cf4\u7ba1\u7406\u5de5\u5177\uff0cDrupal 8 \u9700\u8981\u5b83\u4f86\u5b89\u88dd\u548c\u7ba1\u7406\u4f9d\u8cf4\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Composer\uff1a<\/p>\n<pre><code>curl -sS https:\/\/getcomposer.org\/installer | php\nsudo mv composer.phar \/usr\/local\/bin\/composer<\/code><\/pre>\n<h2 id=\"%e4%b8%8b%e8%bc%89-drupal-8-XKJxMNVLwR\">\u4e0b\u8f09 Drupal 8<\/h2>\n<p>\u4f7f\u7528 Composer \u4e0b\u8f09 Drupal 8 \u7684\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<pre><code>composer create-project drupal\/recommended-project:^8.0 drupal<\/code><\/pre>\n<p>\u9019\u5c07\u5728\u7576\u524d\u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b\u540d\u70ba drupal \u7684\u6587\u4ef6\u593e\uff0c\u4e26\u4e0b\u8f09\u6240\u6709\u5fc5\u8981\u7684\u6587\u4ef6\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-apache-%e4%bc%ba%e6%9c%8d%e5%99%a8-XKJxMNVLwR\">\u914d\u7f6e Apache \u4f3a\u670d\u5668<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e Apache \u4f3a\u670d\u5668\u4ee5\u652f\u6301 Drupal\u3002\u5275\u5efa\u4e00\u500b\u65b0\u7684\u865b\u64ec\u4e3b\u6a5f\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/httpd\/conf.d\/drupal.conf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    DocumentRoot \"\/path\/to\/drupal\/web\"\n    ServerName your_domain.com\n\n    &lt;Directory \"\/path\/to\/drupal\/web\"&gt;\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>\u8acb\u78ba\u4fdd\u5c07 &#8220;\/path\/to\/drupal\/web&#8221; \u66ff\u63db\u70ba\u5be6\u969b\u7684 Drupal \u5b89\u88dd\u8def\u5f91\uff0c\u4e26\u5c07 &#8220;your_domain.com&#8221; \u66ff\u63db\u70ba\u60a8\u7684\u57df\u540d\u3002<\/p>\n<h2 id=\"%e5%95%9f%e7%94%a8-mod_rewrite-%e6%a8%a1%e7%b5%84-XKJxMNVLwR\">\u555f\u7528 mod_rewrite \u6a21\u7d44<\/h2>\n<p>Drupal \u9700\u8981 Apache \u7684 mod_rewrite \u6a21\u7d44\u4f86\u6b63\u78ba\u904b\u884c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u7528\u5b83\uff1a<\/p>\n<pre><code>sudo a2enmod rewrite\nsudo systemctl restart httpd<\/code><\/pre>\n<h2 id=\"%e5%ae%8c%e6%88%90%e5%ae%89%e8%a3%9d-XKJxMNVLwR\">\u5b8c\u6210\u5b89\u88dd<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u700f\u89bd\u5668\u8a2a\u554f\u60a8\u7684\u57df\u540d\uff0c\u958b\u59cb Drupal \u7684\u5b89\u88dd\u904e\u7a0b\u3002\u6309\u7167\u5c4f\u5e55\u4e0a\u7684\u6307\u793a\u5b8c\u6210\u5b89\u88dd\uff0c\u4e26\u4f7f\u7528\u4e4b\u524d\u5275\u5efa\u7684\u6578\u64da\u5eab\u548c\u7528\u6236\u9032\u884c\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-XKJxMNVLwR\">\u7e3d\u7d50<\/h2>\n<p>\u5728 RHEL \u548c CentOS \u4e0a\u5b89\u88dd Drupal 8 \u7684\u904e\u7a0b\u76f8\u5c0d\u7c21\u55ae\uff0c\u53ea\u9700\u9075\u5faa\u4e0a\u8ff0\u6b65\u9a5f\u5373\u53ef\u6210\u529f\u90e8\u7f72\u3002\u7121\u8ad6\u60a8\u662f\u958b\u767c\u8005\u9084\u662f\u7cfb\u7d71\u7ba1\u7406\u54e1\uff0c\u9019\u4e9b\u6b65\u9a5f\u90fd\u80fd\u5e6b\u52a9\u60a8\u5728\u81ea\u5df1\u7684\u4f3a\u670d\u5668\u4e0a\u904b\u884c Drupal\u3002\u82e5\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\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\u7a69\u5b9a\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u64f4\u5c55\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88dd Drupal 8 \u5728 RHEL \u548c CentOS \u7684\u5177\u9ad4\u6b65\u9a5f\uff0c\u6db5\u84cb\u74b0\u5883\u914d\u7f6e\u3001\u4f9d\u8cf4\u5b89\u88dd\u53ca\u8a2d\u7f6e\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-45024","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45024","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=45024"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45024\/revisions"}],"predecessor-version":[{"id":45025,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45024\/revisions\/45025"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}