Contents
1. Install MySQL 8
1. Install
1 |
# apt -y install mysql-server-8.0 |
2. MySQL server security settings
Run the tool mysql_secure_installtion to configure security-related settings for your MySQL server.
When you run it, you will be asked a series of questions to help you configure your security settings.
You will first be asked if you want to use a password validation plugin, as shown below.
Password validation means that you can check the password strength of users for MySQL and restrict them to accepting only passwords that are secure enough.
For example, it should be at least a few characters long and always contain at least one symbol and one number.
Type y if you like and press Enter
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 |
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 (For example, this time set to LOW) Please set the password for root here. New password:xxxxxx(No display) Re-enter new password: xxxxxx(Re-entry No display) 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 password you have set above) |
2.Install WordPress
2.1 Create database
Create a database for Word Press(As an example, we will use the database name my_db)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# mysql -u root -p Enter password: (Enter the password you have set above) Create a dedicated database controlled by WordPress mysql> CREATE DATABASE my_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | wp_db | +--------------------+ 5 rows in set (0.00 sec) Set up an account and password to allow access to the database you have created mysql>CREATE USER '<Any user name>'@'%' IDENTIFIED WITH mysql_native_password BY '<password>'; Query OK, 0 rows affected (0.04 sec)Tells the database that <Any user> needs to have full access to the database mysql> GRANT ALL ON wp_db.* TO '<Any user name>'@'%'; Query OK, 0 rows affected (0.04 sec) mysql> exit Bye |
2.2 Download and install WordPress
①Download and extract
1 2 3 |
# cd /var/www/html/<FQDN> # wget http://ja.wordpress.org/latest-ja.tar.gz # tar xvf latest-ja.tar.gz |
②Editing the WordPress configuration file
1 2 3 |
# cd wordpress/ # cp wp-config-sample.php wp-config.php # vi wp-config.php |
Contents of wp-config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// ** MySQL settings - You can get this info from your web host * // /** The name of the database for WordPress */ define('DB_NAME', 'wp_db'); ←The name of the database created in "2.1 Database creation". /** MySQL database username */ define('DB_USER', '<Any user name>'); ←User name created in "2.1 Database creation". /** MySQL database password */ define('DB_PASSWORD', '<password>'); ←Password for the user created in "2.1 Database creation". /**Also, 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 3 4 |
# cd /var/www/html/<FQDN> # mv wordpress/* .After confirming the move, delete the wordpress directory and the downloaded latest-ja.tar.gz # rm -R -f wordpress # rm latest-ja.tar.gz |
1 |
# chown -R www-data:www-data /var/www/html/<FQDN> |
Go to http://<FQDN>/
If you succeed, the following WordPress installation information input screen will be displayed.
Your server's PHP does not seem to be able to use the MySQL extension required by WordPress." If you get the message
If you have php and mysql installed on your Ubuntu server, but when you install WordPress you get the message "Your server's PHP does not seem to be able to use the MySQL extension required by WordPress." Please check the following.
Make sure you have the library installed、
Install the php library if you haven't already done so.
1 |
# apt -y install php7.4-gd php7.4-mbstring |
Installing the MYSQL module
WordPress requires the MYSQL module in PHP.
Install the PHP MYSQL module if you haven't already done so.
1 |
# apt -y install php7.4 php7.4-mysql libapache2-mod-php7.4 php7.4-mysql |
After the installation is complete, restart Apache.
1 |
# systemctl restart apache2 |
Go to http://<FQDN>/ in your browser with your browser again
On the input screen below
- Site Title Any name
- Username Any name
- Password Any Password
- Your Email Admin E-mail Address
Click on "Install WordPress".
Make sure you remember your username and password as they are required to access the wordpress admin panel.