這幾天收到朋友的許願,希望能夠看到 phpMyAdmin 的安裝。其實 phpMyAdmin 不難,只是它並未收錄在 CentOS 內建的軟體庫,但只要 Extra Packages for Enterprise Linux (EPEL) 軟體庫有裝並且啟用,就可以用 yum 安裝了。(參考資料:https://docs.phpmyadmin.net/en/latest/setup.html#linux-distributions )
另外,先前使用 CentOS 的 Yum 源安裝 MariaDB,版本是 5.5.X,對照 MariaDB 網站,發現雖然都是穩定版本,但覺得版本有點舊,官方版本都已經來到 10.4 了(參考資料:https://downloads.mariadb.org/mariadb/+releases/ )。因此決定使用 MariaDB 官方的 Yum 源,再寫一篇。
因為 phpMyAdmin 是 Web 畫面,因此此次以 CentOS 7 的圖形模式下做操作。
跑更新並且安裝小工具
$ sudo yum update -y
$ sudo yum install bash-completion net-tools yum-utils epel-release vim wget policycoreutils-python -y
安裝 MariaDB
$ sudo curl -sS <https://downloads.mariadb.com/MariaDB/mariadb_repo_setup> | sudo bash
$ cat /etc/yum.repos.d/mariadb.repo
[mariadb-main]
name = MariaDB Server
baseurl = <https://downloads.mariadb.com/MariaDB/mariadb-10.4/yum/rhel/$releasever/$basearch>
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1
[mariadb-maxscale]
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
name = MariaDB MaxScale
baseurl = <https://downloads.mariadb.com/MaxScale/2.3/centos/$releasever/$basearch>
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 1
[mariadb-tools]
name = MariaDB Tools
baseurl = <https://downloads.mariadb.com/Tools/rhel/$releasever/$basearch>
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1
$ sudo yum-config-manager --enable mariadb
$ sudo yum --enablerepo=mariadb-main install mariadb-server MariaDB-client -y
$ mysql -V
mysql Ver 15.1 Distrib 10.4.8-MariaDB, for Linux (x86_64) using readline 5.1
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.4.8 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sat 2019-09-21 16:57:17 CST; 47s ago
Docs: man:mysqld(8)
<https://mariadb.com/kb/en/library/systemd/>
Main PID: 104997 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─104997 /usr/sbin/mysqld
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] InnoDB: 10.4.8 started; log sequence number 139827; transaction id 21
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] InnoDB: Buffer pool(s) load completed at 190921 16:57:17
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] Plugin 'FEEDBACK' is disabled.
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] Server socket created on IP: '::'.
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] Reading of all Master_info entries succeeded
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] Added new Master_info '' to hash table
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: 2019-09-21 16:57:17 0 [Note] /usr/sbin/mysqld: ready for connections.
Sep 21 16:57:17 centos7-gui.lab.example.com mysqld[104997]: Version: '10.4.8-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Sep 21 16:57:17 centos7-gui.lab.example.com systemd[1]: Started MariaDB 10.4.8 database server.
$ sudo mysql_secure_installation
安裝 Apache
$ sudo yum install httpd -y
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ sudo systemctl status httpd
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --reload
安裝 PHP
$ sudo yum localinstall <http://rpms.remirepo.net/enterprise/remi-release-7.rpm> -y
$ sudo yum-config-manager --enable remi-php73
$ sudo yum --enablerepo=remi-php73 install php php-mysqlnd -y
安裝 phpMyAdmin
$ sudo yum install phpmyadmin -y
$ sudo systemctl restart httpd
登入 CentOS GUI Console,開啟 Firefox 瀏覽器,網址列輸入 http://localhost/phpmyadmin
語言可切換為中文 Chinese Traditional
使用者名稱先輸入 root(此為 MuSQL 資料庫的 root 帳號,而不是作業系統的 root 帳號),再輸入 root 的密碼,即可登入。