VitualBoxにてWordPressを立ち上げた話

はじめに

今回は前回までに立てたVirualBoxのLAMP環境にてWordPressを立ち上げてみた件についてまとめていく。

wget コマンドをyumからインストール

wget を用いてWordPressをインストールするので、wgetをインストールする。

$ yum install wget

WordPressの設定

wgetを用いて公式からWordPress/tmp内にインストールする。

$ cd /tmp
$ wget wordpressのurl

ダウンロード | WordPress.org 日本語

ここから.tar.gzをダウンロードのリンクからURLを取得してくる。

wordpress/var/www/に解凍する

$ tar -xzvf WordPressのjarファイル -C /var/www/

WordPressをDocumentRootに適用する

バックアップを取った後にapacheの設定を書き換える

$ sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
$ sudo vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html" # 変更前
DocumentRoot "/var/www/wordpress" # 変更後

wordpressパーミッションapacheに変更する。

$ cd /var/www/
$ sudo chown apache:apache -R wordpress/

apacheの変更を反映する。

$ sudo systemctl restart httpd

wordpress用のdatabaseを作成する

$ mysql -u root -p 
mysql> create database wp_myblog;
mysql> create user 'kkzoo'@'localhost' identified with mysql_native_password by 'パスワード';
mysql> grant all privileges on wp_myblog.* to 'kkzoo'@'localhost';
mysql> flush privileges;

flush privilegesの権限反映はやらなくてもいいかもしれない。

ユーザ権限の確認・追加 - Qiita

WordPressを開く

ipアドレスを取得して、そのページをブラウザで開く。

$ ip addr

WordPressのWebページでの初期設定

データベースの初期設定は

  • データベース名 : wp_myblog
  • データベースにアクセスするユーザー名 : kkzoo
  • データベースのパスワード : 上記ユーザーのパスワード
  • メールアドレス : 自分のメールアドレス

これでインストールできたら完了。

終わりに

実際にLAMP環境で動かすものの例として、WordPressを簡易的に立ててみたが/var/www/配下にこのサーバーで動かすアプリを置き、apacheの設定をそのアプリに変更する点が肝なのかなと感じた。