AlmaLinux8.3の利用: httpd, mysql, phpのインストール

June 2, 2021 – 6:26 am

AlmaLinux8.3上でhttpd, mysql, phpをインストールした。

インストール時のログをアップしておいた。

httpdインストール

  • httpd本体のインストール
    [root@server02 ~]# dnf install httpd httpd-tools
    Last metadata expiration check: 2:57:44 ago on Fri 28 May 2021 07:41:44 AM JST.
    Dependencies resolved.
    ===============================================================================================================
     Package                    Arch        Version                                           Repository      Size
    ===============================================================================================================
    Installing:
     httpd                      x86_64      2.4.37-39.module_el8.4.0+2174+b87b2deb.alma       appstream      1.4 M
     httpd-tools                x86_64      2.4.37-39.module_el8.4.0+2174+b87b2deb.alma       appstream      104 k
    Installing dependencies:
     almalinux-logos-httpd      noarch      84.4-1.el8                                        appstream       29 k
     apr                        x86_64      1.6.3-11.el8                                      appstream      124 k
     apr-util                   x86_64      1.6.1-6.el8                                       appstream      105 k
     httpd-filesystem           noarch      2.4.37-39.module_el8.4.0+2174+b87b2deb.alma       appstream       37 k
     mod_http2                  x86_64      1.15.7-3.module_el8.4.0+2112+b87b2deb             appstream      153 k
    Installing weak dependencies:
     apr-util-bdb               x86_64      1.6.1-6.el8                                       appstream       24 k
     apr-util-openssl           x86_64      1.6.1-6.el8                                       appstream       27 k
    Enabling module streams:
     httpd                                  2.4                                                                   
    
    Transaction Summary
    ===============================================================================================================
    Install  9 Packages
    
    Total download size: 2.0 M
    Installed size: 5.4 M
    Is this ok [y/N]: y
    (以下省略)
    
  • https化に必要な mod_ssl モジュールのインストール 
    [root@server02 ~]# dnf install mod_ssl
    Last metadata expiration check: 3:00:14 ago on Fri 28 May 2021 07:41:44 AM JST.
    Dependencies resolved.
    ===============================================================================================================
     Package         Architecture   Version                                                Repository         Size
    ===============================================================================================================
    Installing:
     mod_ssl         x86_64         1:2.4.37-39.module_el8.4.0+2174+b87b2deb.alma          appstream         133 k
    
    Transaction Summary
    ===============================================================================================================
    Install  1 Package
    
    Total download size: 133 k
    Installed size: 266 k
    Is this ok [y/N]:y
    (以下省略)
    
  • systemctl による httpd の活性化と状態の確認 
    [root@server02 ~]# systemctl start httpd
    [root@server02 ~]# systemctl enable httpd
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
    [root@server02 ~]# systemctl status httpd
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Fri 2021-05-28 10:43:20 JST; 37s ago
         Docs: man:httpd.service(8)
     Main PID: 2755 (httpd)
       Status: "Running, listening on: port 443, port 80"
        Tasks: 213 (limit: 99344)
       Memory: 39.5M
       CGroup: /system.slice/httpd.service
               ├─2755 /usr/sbin/httpd -DFOREGROUND
               ├─2757 /usr/sbin/httpd -DFOREGROUND
               ├─2758 /usr/sbin/httpd -DFOREGROUND
               ├─2759 /usr/sbin/httpd -DFOREGROUND
               └─2760 /usr/sbin/httpd -DFOREGROUND
    
    May 28 10:43:19 server02.yamasnet.com systemd[1]: Starting The Apache HTTP Server...
    May 28 10:43:20 server02.yamasnet.com systemd[1]: Started The Apache HTTP Server.
    May 28 10:43:21 server02.yamasnet.com httpd[2755]: Server configured, listening on: port 443, port 80
    

   
mysql インストール

  • mysql vers.8.0 のdnf インストール
    [root@server02 ~]# dnf module install mysql:8.0
    Last metadata expiration check: 0:07:14 ago on Fri 28 May 2021 10:43:59 AM JST.
    Dependencies resolved.
    =============================================================================================================================
     Package                            Architecture   Version                                           Repository         Size
    =============================================================================================================================
    Installing group/module packages:
     mysql-server                       x86_64         8.0.21-1.module_el8.3.0+2049+47abd494             appstream          22 M
    Installing dependencies:
     mariadb-connector-c-config         noarch         3.1.11-2.el8_3                                    appstream          14 k
     mecab                              x86_64         0.996-1.module_el8.3.0+2049+47abd494.9            appstream         392 k
     mysql                              x86_64         8.0.21-1.module_el8.3.0+2049+47abd494             appstream          12 M
     mysql-common                       x86_64         8.0.21-1.module_el8.3.0+2049+47abd494             appstream         146 k
     mysql-errmsg                       x86_64         8.0.21-1.module_el8.3.0+2049+47abd494             appstream         580 k
     perl-Carp                          noarch         1.42-396.el8                                      baseos             30 k
     perl-Data-Dumper                   x86_64         2.167-399.el8                                     baseos             58 k
     perl-Digest                        noarch         1.17-395.el8                                      baseos             27 k
     perl-Digest-MD5                    x86_64         2.55-396.el8                                      baseos             37 k
     perl-Encode                        x86_64         4:2.97-3.el8                                      baseos            1.5 M
     perl-Errno                         x86_64         1.28-419.el8                                      baseos             75 k
     perl-Exporter                      noarch         5.72-396.el8                                      baseos             34 k
     perl-File-Path                     noarch         2.15-2.el8                                        baseos             38 k
     perl-File-Temp                     noarch         0.230.600-1.el8                                   baseos             62 k
     perl-Getopt-Long                   noarch         1:2.50-4.el8                                      baseos             63 k
     perl-HTTP-Tiny                     noarch         0.074-1.el8                                       baseos             58 k
     perl-IO                            x86_64         1.38-419.el8                                      baseos            141 k
     perl-MIME-Base64                   x86_64         3.15-396.el8                                      baseos             30 k
     perl-Net-SSLeay                    x86_64         1.88-1.module_el8.3.0+2086+72f2d257               appstream         378 k
     perl-PathTools                     x86_64         3.74-1.el8                                        baseos             90 k
     perl-Pod-Escapes                   noarch         1:1.07-395.el8                                    baseos             20 k
     perl-Pod-Perldoc                   noarch         3.28-396.el8                                      baseos             86 k
     perl-Pod-Simple                    noarch         1:3.35-395.el8                                    baseos            213 k
     perl-Pod-Usage                     noarch         4:1.69-395.el8                                    baseos             34 k
     perl-Scalar-List-Utils             x86_64         3:1.49-2.el8                                      baseos             68 k
     perl-Socket                        x86_64         4:2.027-3.el8                                     baseos             59 k
     perl-Storable                      x86_64         1:3.11-3.el8                                      baseos             98 k
     perl-Term-ANSIColor                noarch         4.06-396.el8                                      baseos             46 k
     perl-Term-Cap                      noarch         1.17-395.el8                                      baseos             23 k
     perl-Text-ParseWords               noarch         3.30-395.el8                                      baseos             18 k
     perl-Text-Tabs+Wrap                noarch         2013.0523-395.el8                                 baseos             24 k
     perl-Time-Local                    noarch         1:1.280-1.el8                                     baseos             33 k
     perl-URI                           noarch         1.73-3.el8                                        baseos            116 k
     perl-Unicode-Normalize             x86_64         1.25-396.el8                                      baseos             82 k
     perl-constant                      noarch         1.33-396.el8                                      baseos             25 k
     perl-interpreter                   x86_64         4:5.26.3-419.el8                                  baseos            6.3 M
     perl-libnet                        noarch         3.11-3.el8                                        baseos            121 k
     perl-libs                          x86_64         4:5.26.3-419.el8                                  baseos            1.6 M
     perl-macros                        x86_64         4:5.26.3-419.el8                                  baseos             71 k
     perl-parent                        noarch         1:0.237-1.el8                                     baseos             20 k
     perl-podlators                     noarch         4.11-1.el8                                        baseos            118 k
     perl-threads                       x86_64         1:2.21-2.el8                                      baseos             61 k
     perl-threads-shared                x86_64         1.58-2.el8                                        baseos             47 k
     protobuf-lite                      x86_64         3.5.0-13.el8                                      appstream         148 k
    Installing weak dependencies:
     perl-IO-Socket-IP                  noarch         0.39-5.el8                                        baseos             47 k
     perl-IO-Socket-SSL                 noarch         2.066-4.module_el8.3.0+2086+72f2d257              appstream         297 k
     perl-Mozilla-CA                    noarch         20160104-7.module_el8.3.0+2091+9eecfe51           appstream          14 k
    Installing module profiles:
     mysql/server                                                                                                               
    Enabling module streams:
     mysql                                             8.0                                                                      
     perl                                              5.26                                                                     
     perl-IO-Socket-SSL                                2.066                                                                    
     perl-libwww-perl                                  6.34                                                                     
    
    Transaction Summary
    =============================================================================================================================
    Install  48 Packages
    
    Total download size: 48 M
    Installed size: 218 M
    Is this ok [y/N]: y
    
  • 設定ファイル mysql-server.cnfの編集
    [root@server02 ~]# vi /etc/my.cnf.d/mysql-server.cnf
    #
    # This group are read by MySQL server.
    # Use it for options that only the server (but not clients) should see
    #
    (省略)
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    log-error=/var/log/mysql/mysqld.log
    pid-file=/run/mysqld/mysqld.pid
    (以下の行を追記)
    character-set-server=utf8mb4
    
  • systemctl による mysqldの活性化と状態の確認
    [root@server02 ~]# systemctl enable --now mysqld
    Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
    [root@server02 ~]# 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 Fri 2021-05-28 11:07:17 JST; 28s ago
      Process: 5545 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
      Process: 5418 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
      Process: 5393 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
     Main PID: 5501 (mysqld)
       Status: "Server is operational"
        Tasks: 39 (limit: 99344)
       Memory: 431.4M
       CGroup: /system.slice/mysqld.service
               └─5501 /usr/libexec/mysqld --basedir=/usr
    
    May 28 11:06:27 server02.yamasnet.com systemd[1]: Starting MySQL 8.0 database server...
    May 28 11:06:27 server02.yamasnet.com mysql-prepare-db-dir[5418]: Initializing MySQL database
    May 28 11:07:17 server02.yamasnet.com systemd[1]: Started MySQL 8.0 database server.
    
  • mysql_secure_installationによりmysql-serverのインストール
    [root@server02 ~]# 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: 0
    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! 
    
  • userの設定と使用特権(priviledge)の付与
    [yukichi@server02 ~]$ mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 12
    Server version: 8.0.21 Source distribution
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
    Query OK, 0 rows affected (0.05 sec)
    
    mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> exit
    

PHPのインストール

  • dnfによるphp moduleの取得・確認
    root@server02 ~]# dnf module list php
    Last metadata expiration check: 0:33:08 ago on Fri 28 May 2021 10:43:59 AM JST.
    AlmaLinux 8 - AppStream
    Name                  Stream                  Profiles                                   Summary                               
    php                   7.2 [d]                 common [d], devel, minimal                 PHP scripting language                
    php                   7.3                     common [d], devel, minimal                 PHP scripting language                
    php                   7.4                     common [d], devel, minimal                 PHP scripting language                
    
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
    
  • php version7.4の dnfインストール
    [root@server02 ~]# dnf module install php:7.4
    Last metadata expiration check: 0:34:22 ago on Fri 28 May 2021 10:43:59 AM JST.
    Dependencies resolved.
    ===============================================================================================================================
     Package                    Architecture     Version                                                 Repository           Size
    ===============================================================================================================================
    Installing group/module packages:
     php-cli                    x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream           3.1 M
     php-common                 x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream           694 k
     php-fpm                    x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream           1.6 M
     php-json                   x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream            73 k
     php-mbstring               x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream           482 k
     php-xml                    x86_64           7.4.6-4.module_el8.3.0+2011+2eb69d76                    appstream           172 k
    Installing dependencies:
     libxslt                    x86_64           1.1.32-6.el8                                            baseos              248 k
     nginx-filesystem           noarch           1:1.14.1-9.module_el8.3.0+2165+af250afe.alma            appstream            23 k
     oniguruma                  x86_64           6.8.2-2.el8                                             appstream           187 k
    Installing module profiles:
     php/common                                                                                                                   
    Enabling module streams:
     nginx                                       1.14                                                                             
     php                                         7.4                                                                              
    
    Transaction Summary
    ===============================================================================================================================
    Install  9 Packages
    
    Total download size: 6.5 M
    Installed size: 28 M
    Is this ok [y/N]: y
    
    
  • php-mysqlnd モジュールの追加インストール
    [root@server02 ~]# dnf install php-mysqlnd
    Last metadata expiration check: 2:13:35 ago on Sat 29 May 2021 07:56:54 AM JST.
    Dependencies resolved.
    ======================================================================================================================
     Package                Architecture      Version                                          Repository            Size
    ======================================================================================================================
    Installing:
     php-mysqlnd            x86_64            7.4.6-4.module_el8.3.0+2011+2eb69d76             appstream            191 k
    Installing dependencies:
     php-pdo                x86_64            7.4.6-4.module_el8.3.0+2011+2eb69d76             appstream            121 k
    
    Transaction Summary
    ======================================================================================================================
    Install  2 Packages
    
    Total download size: 312 k
    Installed size: 642 k
    Is this ok [y/N]: y
    (以下省略)
    
  • /etc/php.ini を編集し、timezoneを日本時間にセット

    [root@server02 ~]# vi /etc/php.ini
    
    php.ini
      ・・・
    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone = Asia/Tokyo
    
  • systemctlで、モジュール php-fpmを活性化しhttpdをrestart、httpdの状態確認

    [root@server02 ~]# systemctl start php-fpm
    [root@server02 ~]# systemctl enable php-fpm
    Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
    
    [root@server02 ~]# systemctl restart httpd
    
    [root@server02 ~]# systemctl status httpd
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/httpd.service.d
               └─php-fpm.conf
       Active: active (running) since Tue 2021-06-01 17:03:47 JST; 1h 17min ago
         Docs: man:httpd.service(8)
      Process: 13143 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
     Main PID: 73616 (httpd)
       Status: "Total requests: 659; Idle/Busy workers 100/0;Requests/sec: 0.142; Bytes served/sec: 5.8KB/sec"
        Tasks: 278 (limit: 99344)
       Memory: 74.4M
       CGroup: /system.slice/httpd.service
               ├─73616 /usr/sbin/httpd -DFOREGROUND
               ├─73618 /usr/sbin/httpd -DFOREGROUND
               ├─73619 /usr/sbin/httpd -DFOREGROUND
               ├─73620 /usr/sbin/httpd -DFOREGROUND
               ├─73621 /usr/sbin/httpd -DFOREGROUND
               └─73833 /usr/sbin/httpd -DFOREGROUND
    
    Jun 01 17:03:46 server02.yamasnet.com systemd[1]: Starting The Apache HTTP Server...
    Jun 01 17:03:47 server02.yamasnet.com systemd[1]: Started The Apache HTTP Server.
    Jun 01 17:03:47 server02.yamasnet.com httpd[73616]: Server configured, listening on: port 443, port 80
    ~
    

Post a Comment