0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

shifter-static-local の使い方

Last updated at Posted at 2023-06-15

Shifter をローカルで使う shifter-static-local の使い方です。

Docker が動いていることを確認

$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: >
     Active: active (running) since Thu 2023-06-15 13:08:09 JST; 1h 41min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 1310 (dockerd)
      Tasks: 35
     Memory: 149.8M
        CPU: 2.880s

使ったバージョン

$ docker --version
Docker version 24.0.2, build cb74dfcd85

$ docker-compose --version
Docker Compose version 2.18.1

ダウンロードと実行

git clone https://github.com/digitalcube/shifter-static-local.git my-shifter-site
cd my-shifter-site
docker-compose up

ブラウザーでアクセス

次のエラーが表示されます。

Warning: mysqli_real_connect(): (HY000/1130): Host '172.18.0.3' is not allowed
 to connect to this MySQL server in /var/www/html/web/wp/wp-includes/class-wpdb.php
 on line 2019

local01.png

対策

MySQL に 
wordpress というデータベースを作成
'shifter'@'172.18.0.3' というユーザーを作成、パスワードは 'pass'
'shifter'@'172.18.0.3' に wordpress へのアクセス権を与える

データベースの作成

$ docker exec -it shifter-static-local-mysql-1 bash
bash-4.2# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 273
Server version: 5.7.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, 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 wordpress;
create user 'shifter'@'172.18.0.3' identified by 'pass';
grant all on wordpress.* to 'shifter'@'172.18.0.3';

確認

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

mysql> select user,host from mysql.user;
+---------------+------------+
| user          | host       |
+---------------+------------+
| shifter       | 172.18.0.3 |
| mysql.session | localhost  |
| mysql.sys     | localhost  |
| root          | localhost  |
+---------------+------------+
4 rows in set (0.00 sec)

mysql>

ブラウザーでワードプレスを使う

local02.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?