iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 22
0
自我挑戰組

30天學 LAMP 安裝系列 第 22

Day22 RHEL 8 安裝 LAMP 環境

  • 分享至 

  • xImage
  •  

前言

預計使用 RHEL 8 內建的 BaseOS 和 AppStream 兩個 Yum 源。

看一下可安裝的軟體有哪些?

$ sudo yum module list
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                                                     2.3 kB/s | 4.5 kB     00:01
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                                        2.9 kB/s | 4.0 kB     00:01
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Name                         Stream               Profiles                                         Summary
389-ds                       1.4                                                                   389 Directory Server (base)
ant                          1.10 [d]             common [d]                                       Java build tool
container-tools              1.0                  common [d]                                       Common tools and dependencies for container runtimes
container-tools              rhel8 [d][e]         common [d]                                       Common tools and dependencies for container runtimes
freeradius                   3.0 [d]              server [d]                                       High-performance and highly configurable free RADIUS server
gimp                         2.8 [d]              common [d], devel                                gimp module
go-toolset                   rhel8 [d]            common [d]                                       Go
httpd                        2.4 [d]              common [d], devel, minimal                       Apache HTTP Server
idm                          DL1                  common [d], adtrust, client, dns, server         The Red Hat Enterprise Linux Identity Management system module
idm                          client [d]           common [d]                                       RHEL IdM long term support client module
inkscape                     0.92.3 [d]           common [d]                                       Vector-based drawing program using SVG
javapackages-runtime         201801 [d]           common [d]                                       Basic runtime utilities to support Java applications
libselinux-python            2.8                  common                                           Python 2 bindings for libselinux
llvm-toolset                 rhel8 [d][e]         common [d]                                       LLVM
mailman                      2.1 [d]              common [d]                                       Electronic mail discussion and e-newsletter lists managing software
mariadb                      10.3 [d]             client, server [d], galera                       MariaDB Module
maven                        3.5 [d]              common [d]                                       Java project management and project comprehension tool
mercurial                    4.8 [d]              common [d]                                       Mercurial -- a distributed SCM
mod_auth_openidc             2.3                                                                   Apache module suporting OpenID Connect authentication
mysql                        8.0 [d]              client, server [d]                               MySQL Module
nginx                        1.14 [d]             common [d]                                       nginx webserver
nodejs                       10 [d]               common [d], development, minimal, s2i            Javascript runtime
parfait                      0.5                  common                                           Parfait Module
perl                         5.24                 common [d], minimal                              Practical Extraction and Report Language
perl                         5.26 [d]             common [d], minimal                              Practical Extraction and Report Language
perl-App-cpanminus           1.7044 [d]           common [d]                                       Get, unpack, build and install CPAN modules
perl-DBD-MySQL               4.046 [d]            common [d]                                       A MySQL interface for Perl
perl-DBD-Pg                  3.7 [d]              common [d]                                       A PostgreSQL interface for Perl
perl-DBD-SQLite              1.58 [d]             common [d]                                       SQLite DBI driver
perl-DBI                     1.641 [d]            common [d]                                       A database access API for Perl
perl-FCGI                    0.78 [d]             common [d]                                       FastCGI Perl bindings
perl-YAML                    1.24 [d]             common [d]                                       Perl parser for YAML
php                          7.2 [d]              common [d], devel, minimal                       PHP scripting language
pki-core                     10.6                                                                  PKI Core
pki-deps                     10.6                                                                  PKI Dependencies module
postgresql                   10 [d]               client, server [d]                               PostgreSQL server and client module
postgresql                   9.6                  client, server [d]                               PostgreSQL server and client module
python27                     2.7 [d]              common [d]                                       Python programming language, version 2.7
python36                     3.6 [d][e]           common [d], build                                Python programming language, version 3.6
redis                        5 [d]                common [d]                                       Redis persistent key-value database
rhn-tools                    1.0 [d]              common [d]                                       Red Hat Satellite 5 tools for RHEL
ruby                         2.5 [d]              common [d]                                       An interpreter of object-oriented scripting language
rust-toolset                 rhel8 [d]            common [d]                                       Rust
satellite-5-client           1.0 [d][e]           common [d], gui                                  Red Hat Satellite 5 client packages
scala                        2.10 [d]             common [d]                                       A hybrid functional/object-oriented language for the JVM
squid                        4 [d]                common [d]                                       Squid - Optimising Web Delivery
subversion                   1.10 [d]             common [d], server                               Apache Subversion
swig                         3.0 [d]              common [d], complete                             Connects C/C++/Objective C to some high-level programming languages
varnish                      6 [d]                common [d]                                       Varnish HTTP cache
virt                         rhel [d][e]          common [d]                                       Virtualization module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

預計安裝 Apache 2.4、MySQL 8.0、PHP 7.2。此版本跟 Apache、MySQL、PHP 官方網站版本相比較,雖不是穩定最新,但也是夠新了。

安裝 Apache

$ sudo yum -y install httpd

***** 啟動並且啟用 Apache *****
$ sudo systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

***** 開通本機防火牆 HTTP (TCP 80 port) 與 HTTPS (TCP 443 port) *****
$ sudo firewall-cmd --add-service=http --add-service=https
success
$ sudo firewall-cmd --add-service=http --add-service=https --permanent
success

安裝 MySQL

$ sudo yum -y module install mysql

***** 啟動並且啟用 MySQL *****
$ sudo systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

***** 查看 MySQL 狀態 *****
[doraemon@rhel8-gui ~]$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-09-22 15:36:38 CST; 29s ago
  Process: 4399 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 4273 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 4248 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 4357 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 24894)
   Memory: 538.1M
   CGroup: /system.slice/mysqld.service
           └─4357 /usr/libexec/mysqld --basedir=/usr

Sep 22 15:36:29 rhel8-gui.lab.example.com systemd[1]: Starting MySQL 8.0 database server...
Sep 22 15:36:29 rhel8-gui.lab.example.com mysql-prepare-db-dir[4273]: Initializing MySQL database
Sep 22 15:36:38 rhel8-gui.lab.example.com systemd[1]: Started MySQL 8.0 database server.

***** 調整 SELinux,允許 Apache 網路連線至資料庫
$ sudo setsebool -P httpd_can_network_connect_db on

***** 執行讓 MySQL 更安全的交談式 Script,與先前內容稍有異 *****
$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

安裝 PHP

***** 安裝模組的另外一種寫法,等同於 sudo yum -y module install php *****
$ sudo yum -y install @php

$ sudo yum -y install php-mysqlnd
$ sudo systemctl restart httpd

測試

登入 CentOS GUI Console,開啟 Firefox 瀏覽器,網址列輸入 http://localhost 或是 http://rhel8-gui.lab.example.com,即可看見 Apache 的預設頁面。

https://ithelp.ithome.com.tw/upload/images/20190922/20119707KlEeEc5nCK.png

切換到 /var/www/html/ 目錄下,編寫一個 PHP 測試頁面,檔名為 info.php。再重啟 Apache 服務。

$ sudo vim /var/www/html/info.php
$ cat /var/www/html/info.php
<?php phpinfo(); ?>
$ sudo systemctl start httpd

開啟 Firefox 瀏覽器,網址列輸入 http://localhost/info.php 或是 http://rhel8-gui.lab.example.com/info.php ,即可看見 PHP 相關資訊。

https://ithelp.ithome.com.tw/upload/images/20190922/20119707QHixOqsipM.png


上一篇
Day21 RHEL 8 圖形模式安裝後簡單設定 (2)
下一篇
Day23 RHEL 8 安裝 WordPress
系列文
30天學 LAMP 安裝33
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言