在这个文章, 我们展示了在 CentOS 7 上如何去下载、安装和利用基本配置来设置 LAMP 以及 Drupal 8。 -- Aaron Kili
本文导航-步骤 1:安装 Apache Web 做事器 …… 09%
-步骤 2: 安装 Apache PHP 支持 …… 22%

-步骤 3: 安装和配置 MariaDB 数据库 …… 33%
-步骤 4: 在 CentOS 中安装和配置 Drupal 8 …… 46%
编译自: http://www.tecmint.com/install-drupal-in-centos-rhel-fedora/作者: Aaron Kili
译者: imxieke
Drupal 是一个开源,灵巧,高度可拓展和安全的内容管理系统Content Management System(CMS),利用户轻松的创建网站。
它可以利用模块拓展,利用户将内容管理转换为强大的数字办理方案。
Drupal 运行在诸如 Apache、IIS、Lighttpd、Cherokee、Nginx 的 Web 做事器上,后端数据库可以利用 MySQL、MongoDB、MariaDB、PostgreSQL、MSSQL Server。
在这篇文章中, 我们会展示在 RHEL 7/6、CentOS 7/6 和 Fedora 20-25 发行版上利用 LAMP 架构,如何手动安装和配置 Drupal 8。
Drupal 需求:
Apache 2.x (推举)
PHP 5.5.9 或 更高 (推举 PHP 5.5)
MySQL 5.5.3 或 MariaDB 5.5.20 与 PHP 数据工具(PDO) 支持
安装过程中,我利用 drupal.tecmint.com 作为网站主机名,IP 地址为 192.168.0.104。你的环境大概与这些设置不同,因此请适当做出变动。
步骤 1:安装 Apache Web 做事器1、 首先我们从官方仓库开始安装 Apache Web 做事器。
# yum install httpd2、 安装完成后,做事开始是被禁用的,因此我们须要手动启动它,同时让它下次系统启动时自动启动,如下:
------------- 通过 SystemD - CentOS/RHEL 7 和 Fedora 22+ -------------------# systemctl start httpd
# systemctl enable httpd
------------- 通过 SysVInit - CentOS/RHEL 6 和 Fedora ----------------------
# service httpd start
# chkconfig --level 35 httpd on
3、 接下来,为了许可通过 HTTP 和 HTTPS 访问 Apache 做事,我们必须打开 HTTPD 守护进程正在监听的 80 和 443 端口,如下所示:
------------ 通过 Firewalld - CentOS/RHEL 7 and Fedora 22+ -------------# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload
------------ 通过 IPtables - CentOS/RHEL 6 and Fedora 22+ -------------
# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
# service iptables save
# service iptables restart
4、 现在验证 Apache 是否正常事情, 打开浏览器在地址栏中输入 http://server_IP, 输入你的做事器 IP 地址, 默认 Apache2 页面应涌现,如下面截图所示:
Apache 默认页面
步骤 2: 安装 Apache PHP 支持5、 接下来,安装 PHP 和 PHP 所需模块。
# yum install php php-mbstring php-gd php-xml php-pear php-fpm php-mysql php-pdo php-opcache主要: 如果你想要安装 PHP7, 你须要增加以下仓库:EPEL 和 Webtactic 才可以利用 yum 安装 PHP7.0:
------------- Install PHP 7 in CentOS/RHEL and Fedora -------------# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum install php70w php70w-opcache php70w-mbstring php70w-gd php70w-xml php70w-pear php70w-fpm php70w-mysql php70w-pdo
6、 接下来,要从浏览器得到关于 PHP 安装和配置完全信息,利用下面命令在 Apache 文档根目录 (/var/www/html) 创建一个 info.php 文件。
# echo \"大众<?php phpinfo(); ?>\公众 > /var/www/html/info.php然后重启 HTTPD 做事器 ,在浏览器地址栏输入 http://server_IP/info.php。
# systemctl restart httpd或
# service httpd restart
验证 PHP 信息
步骤 3: 安装和配置 MariaDB 数据库7、 请知晓, Red Hat Enterprise Linux/CentOS 7.0 从支持 MySQL 转为了 MariaDB 作为默认数据库管理系统。
要安装 MariaDB 数据库, 你须要添加 官方 MariaDB 库[1] 到 /etc/yum.repos.d/MariaDB.repo 中,如下所示。
[mariadb]name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
当仓库文件准备好后,你可以像这样安装 MariaDB:
# yum install mariadb-server mariadb8、 当 MariaDB 数据库安装完成,启动数据库的守护进程,同时使它能够不才次启动后自动启动。
------------- 通过 SystemD - CentOS/RHEL 7 and Fedora 22+ -------------# systemctl start mariadb
# systemctl enable mariadb
------------- 通过 SysVInit - CentOS/RHEL 6 and Fedora -------------
# service mysqld start
# chkconfig --level 35 mysqld on
9、 然后运行 mysql_secure_installation 脚本去保护数据库(设置 root 密码, 禁用远程登录,移除测试数据库并移除匿名用户),如下所示:
# mysql_secure_installationMySQL 安全安装
步骤 4: 在 CentOS 中安装和配置 Drupal 810、 这里我们利用 wget 命令[2] 下载最新版本 Drupal[3](例如 8.2.6),如果你没有安装 wget 和 gzip 包 ,请利用下面命令安装它们:
# yum install wget gzip# wget -c https://ftp.drupal.org/files/projects/drupal-8.2.6.tar.gz
11、 之后,解压 tar 文件[4] 并移动 Drupal 目录到 Apache 文档根目录(/var/www/html)。
# tar -zxvf drupal-8.2.6.tar.gz# mv drupal-8.2.6 /var/www/html/drupal
12、 然后,依据 /var/www/html/drupal/sites/default 目录下的示例设置文件 default.settings.php,创建设置文件 settings.php,然后给 Drupal 站点目录设置适当权限,包括子目录和文件,如下所示:
# cd /var/www/html/drupal/sites/default/# cp default.settings.php settings.php
# chown -R apache:apache /var/www/html/drupal/
13、 更主要的是在 /var/www/html/drupal/sites/ 目录设置 SElinux 规则,如下:
# chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/sites/14、 现在我们必须为 Drupal 站点去创建一个用于管理的数据库和用户。
# mysql -u root -pEnter password:
MySQL Shell
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> create database drupal;
Query OK, 1 row affected (0.00 sec)
MySQL [(none)]> create user ravi@localhost identified by 'tecmint123';
Query OK, 0 rows affected (0.00 sec)
MySQL [(none)]> grant all on drupal. to ravi@localhost;
Query OK, 0 rows affected (0.00 sec)
MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MySQL [(none)]> exit
Bye
15、 末了,打开地址: http://server_IP/drupal/ 开始网站的安装,选择你首选的安装措辞然后点击保存以连续。
Drupal 安装措辞
16、 下一步,选择安装配置文件,选择 Standard(标准),点击保存连续。
Drupal 安装配置文件
17、 在进行下一步之前查看并通过需求审查并启用 Clean URL。
验证 Drupal 需求
现在在你的 Apache 配置下启用 Clean URL 的 Drupal。
# vi /etc/httpd/conf/httpd.conf确保为默认根文档目录 /var/www/html 设置 AllowOverride All,如下图所示:
在 Drupal 中启用 Clean URL
18、 当你为 Drupal 启用 Clean URL,刷新页面从下面界面实行数据库配置,输入 Drupal 站点数据库名,数据库用户和数据库密码。
当填写完所有信息点击保存并连续。
Drupal 数据库配置
若上述设置精确,Drupal 站点安装该当完成了,如下图界面。
Drupal 安装
19、 接下来配置站点为下面的设置(利用适用你的情形的值):
站点名称 – TecMint Drupal Site
站点邮箱地址 – admin@tecmint.com[5]
用户名 – admin
密码 – ##########
用户的邮箱地址 – admin@tecmint.com[6]
默认国家 – India
默认时区 – UTC
设置适当的值后,点击保存并连续完成站点安装过程。
Drupal 站点配置
下图显示的是通过 LAMP 成功安装的 Drupal 8 站点。
Drupal 站点面板
现在你可以点击增加内容,创建示例网页内容。
选项: 有些人利用 MySQL 命令行管理数据库[7]不舒畅,可以从浏览器界面 安装 PHPMYAdmin 管理数据库[8]
浏览 Drupal 文档 : https://www.drupal.org/docs/8
就这样!
在这个文章, 我们展示了在 CentOS 7 上如何去下载、安装和利用基本配置来设置 LAMP 以及 Drupal 8。 欢迎就这个教程供应反馈,或供应给我们一些干系信息。
作者简介:
Aaron Kili 是 linux 和 F.O.S.S 爱好者,将成为 Linux 系统管理员,Web 开拓者,目前是 TecMint 的原创作者,热爱打算机事情,并且坚信知识共享。
via: http://www.tecmint.com/install-drupal-in-centos-rhel-fedora/
作者:Aaron Kili[9] 译者:imxieke 校正:jasminepeng
本文由 LCTT 原创编译,Linux中国 名誉推出
[1]: 官方 MariaDB 库 - https://downloads.mariadb.org/mariadb/repositories/#mirror=Fibergrid&distro=CentOS
[2]: wget 命令 - http://www.tecmint.com/10-wget-command-examples-in-linux/
[3]: 下载最新版本 Drupal - https://www.drupal.org/download
[4]: 解压 tar 文件 - http://www.tecmint.com/extract-tar-files-to-specific-or-different-directory-in-linux/
[5]: admin@tecmint.com - mailto:admin@tecmint.com
[6]: admin@tecmint.com - mailto:admin@tecmint.com
[7]: 利用 MySQL 命令行管理数据库 - http://www.tecmint.com/mysqladmin-commands-for-database-administration-in-linux/
[8]: 安装 PHPMYAdmin 管理数据库 - http://www.tecmint.com/install-phpmyadmin-rhel-centos-fedora-linux/
[9]: Aaron Kili - http://www.tecmint.com/author/aaronkili/