Contents
1. MySQL 8 Install
1. 1 Update package index
1 2 |
# apt update # apt upgrade |
Install necessary packages
1 |
# apt install -y software-properties-common apt-transport-https wget ca-certificates gnupg2 |
1.2 Import MySQL Community Repository
Import GPG keys
1 |
# wget -O- http://repo.mysql.com/RPM-GPG-KEY-mysql-2022 | gpg --dearmor | sudo tee /usr/share/keyrings/mysql.gpg |
Import Repository
1 |
# echo 'deb [signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/debian bullseye mysql-8.0' | tee /etc/apt/sources.list.d/mysql.list |
Perform APT update
1 |
# apt update |
1.3 MySQL Install
1 |
# apt install -y mysql-community-server |
aptpolicy installation
1 2 3 4 5 6 7 8 9 |
# apt policy mysql-community-server mysql-community-server: Installed: 8.0.31-1debian11 Candidate: 8.0.31-1debian11 Version table: *** 8.0.31-1debian11 500 500 http://repo.mysql.com/apt/debian bullseye/mysql-8.0 amd64 Packages 100 /var/lib/dpkg/status |
operation check
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# systemctl status mysql ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-10-11 17:13:30 JST; 10min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 6930 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 2300) Memory: 365.0M CPU: 4.135s CGroup: /system.slice/mysql.service mq6930 /usr/sbin/mysqld Oct 11 17:13:29 Lepard systemd[1]: Starting MySQL Community Server... Oct 11 17:13:30 Lepard systemd[1]: Started MySQL Community Server. |
Mysql version confirmation
1 2 |
# mysql --version mysql Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL) |
1.4. MySQL Server Security Settings
Run the tool mysql_secure_installation to configure security-related settings for the MySQL server.
Once executed, the tool will start several security settings in the form of questions. First, you will be asked if you want to use a plugin for password validation, as shown below. Password validation checks the strength of a user's password for MySQL and restricts it to only accepting passwords that are secure enough. For example, it must be at least as many characters long as the user's password and must contain at least one symbol and one number. You can set this requirement by asking the following questions
Type y and press Enter if you like
1 2 |
# systemctl restart mysql.service # mysql_secure_installation |
Installation Status
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
Securing the MySQL server deployment. Enter password for user root: ←root password Error: Access denied for user 'root'@'localhost' (using password: YES) root@debian:~# mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: 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 Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: ←New optional root password to be created Re-enter new password: ←Same root password again 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! |
1 2 |
# mysql -u root -p Enter password: (Enter the new password set above) |
2.Install WordPress
2.1 Database Creation
Create a database for Word Press (for example, in this case, the database name is "wp_db", the user name is "wp_user", and the password is "?Y123456y")
If you receive a message "Your password does not satisfy the current policy requirements" when creating an account, please make sure your password is at least 8 characters long and includes upper and lower case letters, numbers, symbols, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 8.0.29 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. 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 DATABASE wp_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 1 row affected, 2 warnings (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | wp_db | +--------------------+ 5 rows in set (0.00 sec) mysql>CREATE USER 'wp_user'@'%' IDENTIFIED WITH mysql_native_password BY '?Y123456y'; Query OK, 0 rows affected (0.00 sec) mysql>GRANT ALL ON wp_db.* TO 'wp_user'@'%'; Query OK, 0 rows affected (0.00 sec) mysql> exit; Bye |
2.2 WordPress Download and Installation
①Download and Deployment
1 2 3 |
# cd /var/www/html/<FQDN> # wget https://wordpress.org/latest.tar.gz # tar xvf latest.tar.gz |
1 2 3 |
# cd wordpress/ # cp wp-config-sample.php wp-config.php # vi wp-config.php |
Edit contents of wp-config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
<?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the installation. * You don't have to use the web site, you can copy this file to "wp-config.php" * and fill in the values. * * This file contains the following configurations: * * * Database settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */// ** Database settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wp_db' );/** Database username */ define( 'DB_USER', 'wp_user' ); /** Database password */ define( 'DB_PASSWORD', '?Y123456y' ); /** Database hostname */ define( 'DB_HOST', 'localhost' ); /** Database charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The database collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); /**#@+ * Authentication unique keys and salts. * * Change these to different unique phrases! You can generate these using * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}. * * You can change these at any point in time to invalidate all existing cookies. * This will force all users to have to log in again. * * @since 2.6.0 */ define( 'AUTH_KEY', 'put your unique phrase here' ); define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); define( 'NONCE_KEY', 'put your unique phrase here' ); define( 'AUTH_SALT', 'put your unique phrase here' ); define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); define( 'NONCE_SALT', 'put your unique phrase here' ); /**#@-*/ /** * WordPress database table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; /** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the documentation. * * @link https://wordpress.org/support/article/debugging-in-wordpress/ */ define( 'WP_DEBUG', false ); /* Add any custom values between this line and the "stop editing" line. */ /* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); } /** Sets up WordPress vars and included files. /*Add the following to the last line*/ /*If you do not do this, you will be asked for FTP connection information when you add the plugin.*/ define('FS_METHOD', 'direct'); |
1 2 |
# cd /var/www/html/<own domain name> # mv wordpress/* . |
1 2 3 |
# ls -l # rm -R -f wordpress # rm latest.tar.gz |
1 |
# chown -R www-data:www-data /var/www/html/<own domain name> |
Access http://<own domain name>/wp-admin.
If successful, the following WordPress installation information input screen will be output.
「Your PHP installation appears to be missing the MySQL extension which is required by WordPress.」When displayed
Install php library-related software if not already installed.
1 |
# apt -y install php7.4-gd php7.4-mbstring |
1 |
# apt -y install php7.4 php7.4-mysql libapache2-mod-php7.4 php7.4-mysql |
Restart Apache after installation is complete.
1 |
# systemctl restart apache2 |
again
Access http://<own domain name>/wp-admin.
On the following input screen
- Site Title Any name
- Username Any name
- Password Any password
- Your Email Administrator's email address
Enter the information and click "Install WordPress". Remember to enter your "username" and "password" as they are required to access the WordPress administration screen.