$ cd
$ cd Boxes
$ mkdir ubuntu-wordpress
$ cd ubuntu-wordpress
$ vagrant init bento/ubuntu-18.04
$ vagrant up
$ vagrant ssh
vagrant に ssh できるか確認。
一旦、vagrant から抜ける
$ exit
$ nvim Vagrantfile
下記のコメントアウトを外す
# config.vm.network "forwarded_port", guest: 80, host: 8080
↓
config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "private_network", ip: "192.168.33.10"
↓
config.vm.network "private_network", ip: "192.168.33.10"
コメントアウトを外したら、保存し、Vagrant をリロード。
$ vagrant reload
$ vagrant ssh
ルートユーザーに変更
$ sudo su -
$ timedatectl set-timezone Asia/Tokyo
$ apt update
$ apt install -y apache2
Apache を有効化
$ systemctl enable apache2
Apache のスタート
$ systemctl start apache2
localhost:8080 にアクセスすると Apache のスタートページが表示されるか確認。
$ apt install -y php7.2 php7.2-mysql
$ apt install -y mariadb-server mariadb-client
MariaDB 有効化
$ systemctl enable mariadb
MariaDB スタート
$ systemctl start mariadb
$ sudo mysql
データベースのアクセスできるか確認。Ctrl + C で終了。
$ cd /var/www/html
WordPress の最新バージョンをダウンロード
$ wget https://ja.wordpress.org/latest-ja.tar.gz
ダウンロードしたデータを展開
$ tar xvf latest-ja.tar.gz
権限の変更
$ chown -R www-data:www-data .
$ sudo mariadb
wordpress というテーブルを作成し、文字コードを UTF-8 に設定。
MariaDB [(none)]> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8;
作成した「wordpress」のテーブルのみに全権限を持つユーザーの作成 password は適宜設定。
GRANT ALL ON wordpress.* TO wordpress@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
$ cd /etc/apache2
設定ファイルのバックアップ
$ sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bk
設定ファイルの変更。(WordPress のデータがある場所へ)
$ sudo vi /etc/apache2/apache2.conf
保存する。
Apache の再起動
$ sudo systemctl restart apache2.service
下記の URL にアクセス
http://localhost:8080/
WordPress のインストール画面が表示されるか、確認。
下記の情報を記載し、インストールボタンをクリック
データベース名
wordpress
ユーザー名
wordpress
パスワード
password
下記を実行
$ sudo chgrp -R www-data /var/www/html/wordpress
$ sudo chmod g+w -R /var/www/html/wordpress
サイト情報を記入後、「wp-config.php」を作成。
$ cd /var/www/html/wordpress/
$ sudo vi wp-config.php
ブラウザに記載されている、「wp-config.php」の中身をそのまま貼り付け。
インストールを実行。
現時点では、プラグインのインストールができないため、下記を記載
$ sudo vi /var/www/html/wordpress/wp-config.php
/** プラグインダウンロード有効化 **/
define('FS_METHOD','direct');