GitHub CodespacesでWordPress開発を始める

https://github.com/WordPress/WordPress

`Create codespaceを押す`
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/435735/736de2ca-70b3-de43-b1b6-35fdfd82fb55.png)



### mysqliのインストール

```bash
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_mysqli.gh-codespaces.sh | bash
```

<details><summary>必要なら追加でモジュールをインストール</summary>


```bash
# exif
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_exif.gh-codespaces.sh | bash
# imagick
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_imagick.gh-codespaces.sh | bash
# zip
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_zip.gh-codespaces.sh | bash
# gd
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_gd.gh-codespaces.sh | bash
# intl
curl -L https://gist.githubusercontent.com/GitHub30/0b8d548d0912ff4cc7b065e378904fd0/raw/install_intl.gh-codespaces.sh | bash
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/435735/e946a059-a8e5-b95e-68b1-d2b05f79b9b8.png)
</details>

### MySQLのインストール

```bash
sudo apt update \
  && sudo apt install -y mysql-server \
  && sudo service mysql start \
  && sudo service --status-all \
  && echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''" | sudo mysql \
  && echo 'CREATE DATABASE wordpress' | sudo mysql
```

### リバースプロキシの設定を`wp-load.php`と`wp-settings.php`の先頭に追加する

[https://ja.wordpress.org/support/article/faq-installation/#リバースプロキシを使用している場合には-wordpress-をど](https://ja.wordpress.org/support/article/faq-installation/#%e3%83%aa%e3%83%90%e3%83%bc%e3%82%b9%e3%83%97%e3%83%ad%e3%82%ad%e3%82%b7%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%a6%e3%81%84%e3%82%8b%e5%a0%b4%e5%90%88%e3%81%ab%e3%81%af-wordpress-%e3%82%92%e3%81%a9)

```php
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
	$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
	$_SERVER['HTTPS'] = 'on';
}
```

### サーバーを起動

```bash
php -S localhost:8000
```

WordPressをインストール

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/435735/2890c133-f68e-5cc0-61d0-3d536e1939d0.png)


### 引用

https://ja.wordpress.org/support/article/faq-installation/

https://qiita.com/katsura_tarou_a/items/a8e076116cf45d9c306b

https://www.aster-link.co.jp/posts/rp-server-to-wordpress/

https://www.en-pc.jp/blog/archives/984

https://www.google.com/search?q=wordpress+HTTP_X_FORWARDED_HOST

https://blog.blue.wirednet.jp/2020/05/01/400/aws-alb%E9%85%8D%E4%B8%8B%E3%81%ABwordpress%E3%82%92%E5%85%A5%E3%82%8C%E3%81%9F%E3%82%89%E7%B9%8B%E3%81%8C%E3%82%89%E3%81%AA%E3%81%84/

https://wordpress.org/documentation/article/administration-over-ssl/#using-a-reverse-proxy

http://nsb.homeip.net/wp/?p=24

https://github.com/docker-library/wordpress/issues/251#issuecomment-345687824

https://github.com/docker-library/wordpress/issues/251#issuecomment-345687824

https://wordpress.stackexchange.com/questions/222763/wp-config-dynamic-hostname-in-wp-home-and-wp-siteurl