Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Debian10; Installing MySQL and WordPress

1.Installing MySQL

1.1 Download and install the MySQL package

The MySQL team provides the official MySQL PPA for Debian Linux. When you download and install the package on your Debian system, the PPA file will be added to your system. To enable the PPA, run the following command

# wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
# dpkg -i mysql-apt-config_0.8.14-1_all.deb

In this case, we will select MySQL 5.7 and install it on our Debian system. If you have selected a specific version and need to change the configuration, use the following command

# dpkg-reconfigure mysql-apt-config

During the installation of the MySQL apt config package, you will be asked to select the MySQL version to install. Select the MySQL 8.0 or 5.7 option and install it on your system

1.2 Installing MySQL on Debian 10

# apt update
# apt install mysql-server

During the installation process, you will be prompted to enter the root password that you want to set as default. Enter a secure password and confirm the same password window. This will be the MySQL root user password required to login to the MySQL server.
You will be asked to re-enter the same password in the next window.

Configure security settings for MySQL server.
There is a tool called mysql_secure_installtion that can be used to configure security-related settings for the MySQL server.
When you run it, it will ask you a series of questions to configure some security settings. First, you will be asked if you want to use the password validation plugin as shown below. Password validation means that you can check the password strength of users for MySQL and restrict them to accept 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. You can set this condition with the following question.
If you like, enter y and press Enter.

# systemctl restart mysql.service
# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN 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 plugin?Press y|Y for Yes, any other key for No:y
If you choose “y” for the above question, you will then be asked for the level of password validation: LOW, MEDIUM, or STRONG.
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 filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:1
The content of each level is as follows: LOW Minimum 8 characters
MEDIUM At least 8 characters, always including numbers, upper and lower case letters, and special symbols
STRONG Minimum of 8 characters, including numbers, upper and lower case letters, and special symbols, with a restriction that strings of 4 or more characters must not match words in the dictionary file.
To select LOW, enter 0 and press Enter; for MEDIUM and STRONG, enter 1 and 2, respectively, and press Enter. Then, enter the password twice that actually satisfies the level. This is the password for the root user.

Please set the password for root here.
New password:
Re-enter new password:
When you enter a password twice, a score from 0 to 100 will be assigned to the password you entered, and you will be asked to confirm that it is correct. The higher the security level, the higher the score.
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :y
Note that the password you set when you create a user for MySQL must meet the security level you set here. Next, you will be asked if you want to remove the anonymous test user that MySQL sets by default. If you are sure, type y and press Enter.
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
You will be asked to confirm that you want to prohibit remote root login. In this case, type y and press Enter.
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
To confirm that you want to delete the “test” database, which is usually created by default by MySQL and is accessible to any user, type y and press Enter.
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
Confirm that you want to reload to reflect the settings you have made so far.
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
Finally, the security settings you have made up to this point will be displayed, and if you see the message “All done!
(…以上省略…)
– 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!

LOW Minimum of 8 characters
MEDIUM minimum of 8 characters, must contain numbers, uppercase and lowercase letters, and special symbols
STRONG Minimum of 8 characters, must contain numbers, upper and lower case letters, and special symbols, and no more than 4 characters must match a word in the dictionary file.
That’s it. In the future, if you want to log in to MySQL as root user, you can use the following command.

# mysql -u root -p

1.3 Checking the operation of MySQL

# mysql -u root -p
パスワード:
Database creation
mysql>create database test_Work;mysql> use test_Work;
Database changed
Table creation
mysql> create table addrbook (name varchar(50),tel varchar(50), email varchar(50));
Query OK,0 rows affected (0.01 sec)
record creation
mysql> insert into addrbook (name,tel,email) values (‘Taro.Tanaka’,’090-1234-5678′,’taro@hoge.com’);
Query OK,1 row affected (0.00 sec)mysql> select * from addrbook;
+—————+—————+——————-+
| name | telno | email |
+—————+—————+——————-+
| Taro.Tanaka | 090-1234-5678 | taro@hoge.com |
+—————+—————+——————-+
1 rows in set (0.00 sec)mysql> drop database test_Work;
Query OK, 1 row affected (0.34 sec)mysql> exit
Bye

2.Wordpress installation

2.1 Create a database for Word Press.

# mysql -u root -p

Enter password: ←Enter the root password for MySQL (not shown on the screen)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 Source distribution
Copyright (c) 2000, 2018, 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 database wp_hoge;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;

+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| wp_hoge |
+——————–+
4 rows in set (0.00 sec)

Create user <hoge> and password <hogehoge> for database wp_hoge
mysql> GRANT ALL PRIVILEGES ON wp_hoge.* TO ‘hoge’@’localhost’ identified by ‘hogehoge’;
Query OK, 0 rows affected (0.04 sec)
mysql> exit
Bye

2.2 Word Press Installation

①Download and extract WordPress

# cd /var/www/html/hoge.com
# wget http://ja.wordpress.org/latest-ja.tar.gz
# tar xvf latest-ja.tar.gz
Rewrite the wp-config settings, username and password to the ones you just put into MySQL.

# cd wordpress/
# cp wp-config-sample.php wp-config.php
# vi wp-config.php//

//** MySQL Configuration – This information should be obtained from your hosting provider. ** //
/** Database name for WordPress */
define(‘DB_NAME’, ‘wp_hoge’);
/** MySQL database user name */
define(‘DB_USER’, ‘hoge’);
/** Password for MySQL database */
define(‘DB_PASSWORD’, ‘hogehoge’);
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’);

Move the expanded contents under /var/www/html/hoge.com

# cd /var/www/html/hoge.com
# mv wordpress/* .

After confirming that the files have been moved, delete the wordpress directory and the downloaded latest-ja.tar.gz.

# cd /var/www/html/hoge.com
# rm -R -f wordpress
# rm latest-ja.tar.gz

Make apache the owner of the wordpress directory.

# chown -R www-data:www-data /var/www/html/hoge.com

③Access from a browser
Go to http://hoge.com/.

Debian: “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 installed php and mysql on your Debian server, but when installing 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. Check if the library related items are installed, and if not, install the php library related items.

# apt -y install php7.3-gd php7.3-mbstring

Installing the MYSQL module
WordPress requires the PHP MYSQL module, if you do not have it installed, install it.

# apt -y install php7.3 php7.3-mysql libapache2-mod-php7.3 php7.3-mysql

Restart Apache after the installation is complete.

Go to http://<domain name>/ 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 Password

Click on “Install WordPress”.
Make sure you remember your username and password as they are required to access the wordpress admin panel.

タイトルとURLをコピーしました