iT邦幫忙

第 11 屆 iThome 鐵人賽

0
自我挑戰組

30天學 LAMP 安裝系列 第 32

Day32 CentOS 7 透過 LNMP 一鍵安裝包安裝 LNMPA 架構

前言

其實,我的鐵人賽文章已經夠了。不過就在最後幾天,臉書好友突然丟了一個連結(https://lnmp.org/ )給我,並許願希望見到透過這個工具安裝。由於先前的安裝環境均被我砍了,於是我就仿照 Day06 的內容以 CentOS-7-x86_64-Minimal-1810.iso 執行最小安裝。

虛擬機器規格

  1. Guest OS 勾選 Linux,Version 選 CentOS 7 64-bit
  2. HDD: 40 GB,勾選 Store virtual disk as a single file
  3. Memory:4 GB
  4. CPU:4 核心
  5. 網路選擇 NAT
  6. CD/DVD 掛載 CentOS-7-x86_64-Minimal-1810.iso
  7. 其他要求:移除 USB Controller、Printer、Sound Card

軟體安裝計畫

  1. 使用 LNMP 一鍵安裝包安裝 LNMPA
  2. N:Nginx 網頁伺服器
  3. M:MySQL 資料庫伺服器
  4. P:PHP 網頁動態語言
  5. A:Apache 網頁伺服器
  6. LNMPA 使用 Nginx 作爲前端服務能夠更快更及時的靜態頁面、js、圖片等,當客戶端請求訪問動態頁面時由 Nginx 的反向代理給 Apache 處理,Apache 處理完再交予 Nginx 返回給客戶端。(參考資料:https://lnmp.org/lnmpa.html )

步驟

  1. 仿照 Day06 內容,以 Minimal 進行 CentOS 7 文字模式的基本安裝。

  2. 網路採 DHCP 取到的 IP 為 192.168.16.129/24、預設閘道與 DNS 為 192.168.16.2。

    https://ithelp.ithome.com.tw/upload/images/20191006/20119707HMAaXfc2Ae.png

  3. 安裝 net-tools、bash-completion、screen、wget 套件,前兩者是自己需要,後兩者為等會使用安裝包時需要。

     [doraemon@centos7-cli ~]$ sudo yum install net-tools bash-completion screen wget -y
    
  4. 更新現有軟體,然後重開機

     [doraemon@centos7-cli ~]$ sudo yum update -y
     [doraemon@centos7-cli ~]$ yum sudo yum clean all
     [doraemon@centos7-cli ~]$ sudo systemctl reboot
    
  5. 執行 screen 工具

     [doraemon@centos7-cli ~]$ screen -S lnmp
    
  6. 下載並且解壓縮

     [doraemon@centos7-cli ~]$ wget <http://soft.vpser.net/lnmp/lnmp1.6.tar.gz> -cO lnmp1.6.tar.gz
     [doraemon@centos7-cli ~]$ tar zxf lnmp1.6.tar.gz
     [doraemon@centos7-cli ~]$ cd lnmp1.6
     [doraemon@centos7-cli lnmp1.6]$ sudo ./install.sh lnmpa
    
  7. 選擇安裝資料庫 MySQL 8.0.13

     +------------------------------------------------------------------------+
     |          LNMP V1.6 for CentOS Linux Server, Written by Licess          |
     +------------------------------------------------------------------------+
     |        A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux       |
     +------------------------------------------------------------------------+
     |           For more information please visit <https://lnmp.org>           |
     +------------------------------------------------------------------------+
     You have 11 options for your DataBase install.
     1: Install MySQL 5.1.73
     2: Install MySQL 5.5.62 (Default)
     3: Install MySQL 5.6.44
     4: Install MySQL 5.7.26
     5: Install MySQL 8.0.13
     6: Install MariaDB 5.5.63
     7: Install MariaDB 10.0.38
     8: Install MariaDB 10.1.40
     9: Install MariaDB 10.2.24
     10: Install MariaDB 10.3.15
     0: DO NOT Install MySQL/MariaDB
     Enter your choice (1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or 0): 5
     You will install MySQL 8.0.13
     ===========================
     Please setup root password of MySQL.
     Please enter: password
     MySQL root password: password
     ===========================
     Do you want to enable or disable the InnoDB Storage Engine?
     Default enable,Enter your choice [Y/n]: Y
     You will enable the InnoDB Storage Engine
    
  8. 選擇安裝 PHP 7.3.6、選擇不安裝記憶體優化工具

     ===========================
     You have 9 options for your PHP install.
     1: Install PHP 5.2.17
     2: Install PHP 5.3.29
     3: Install PHP 5.4.45
     4: Install PHP 5.5.38
     5: Install PHP 5.6.40 (Default)
     6: Install PHP 7.0.33
     7: Install PHP 7.1.30
     8: Install PHP 7.2.19
     9: Install PHP 7.3.6
     Enter your choice (1, 2, 3, 4, 5, 6, 7, 8 or 9): 9
     You will install PHP 7.3.6
    
  9. 選擇不安裝記憶體優化工具、輸入管理者 Email

     ===========================
     You have 3 options for your Memory Allocator install.
     1: Don't install Memory Allocator. (Default)
     2: Install Jemalloc
     3: Install TCMalloc
     Enter your choice (1, 2 or 3): 1
     You will install not install Memory Allocator.
     ===========================
     Please enter Administrator Email Address: admin@lab.example.com
     ===========================
     Server Administrator Email: admin@lab.example.com
     ===========================
    
  10. 選擇安裝 Apache 2.4.39,接著就開始安裝

    ===========================
    You have 2 options for your Apache install.
    1: Install Apache 2.2.34
    2: Install Apache 2.4.39 (Default)
    Enter your choice (1 or 2): 2
    You will install Apache 2.4.39
    
    Press any key to install...or Press Ctrl+c to cancel
    
  11. 經過 33 分鐘的等待,結果如下(按 Ctrl + C 退出):

============================== Check install ==============================
Checking ...
Nginx: OK
MySQL: OK
PHP: OK
Apache: OK
Clean Web Server src directory...
+------------------------------------------------------------------------+
|          LNMP V1.6 for CentOS Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|           For more information please visit <https://lnmp.org>           |
+------------------------------------------------------------------------+
|    lnmp status manage: lnmp {start|stop|reload|restart|kill|status}    |
+------------------------------------------------------------------------+
|  phpMyAdmin: <http://IP/phpmyadmin/>                                     |
|  phpinfo: <http://IP/phpinfo.php>                                        |
|  Prober:  <http://IP/p.php>                                              |
+------------------------------------------------------------------------+
|  Add VirtualHost: lnmp vhost add                                       |
+------------------------------------------------------------------------+
|  Default directory: /home/wwwroot/default                              |
+------------------------------------------------------------------------+
|  MySQL/MariaDB root password: password                          |
+------------------------------------------------------------------------+
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              <https://lnmp.org>             |
+-------------------------------------------+
nginx (pid 68342) is running...
 SUCCESS! MySQL running (68914)
Apache is running.
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN     0      128    127.0.0.1:88                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:80                       *:*
LISTEN     0      128          *:22                       *:*
LISTEN     0      70        [::]:33060                 [::]:*
LISTEN     0      128       [::]:3306                  [::]:*
LISTEN     0      128       [::]:22                    [::]:*
Install lnmp takes 33 minutes.
Install lnmp V1.6 completed! enjoy it.
^C[doraemon@centos7-cli lnmp1.6]$
  1. 在其他台電腦,開啟瀏覽器,網址列輸入 http://192.168.16.129

https://ithelp.ithome.com.tw/upload/images/20191006/20119707DDNLifDwyj.png

  1. 網址列輸入 http://192.168.16.129/p.php

https://ithelp.ithome.com.tw/upload/images/20191006/20119707vdzpp8RpkH.png

  1. 網址列輸入 http://192.168.16.129/phpinfo.php

https://ithelp.ithome.com.tw/upload/images/20191006/201197070Jbesubs7M.png


上一篇
Day31 總結與心得
下一篇
Day33 一鍵安裝包安裝後繼續安裝 WordPress
系列文
30天學 LAMP 安裝33
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言