LoginSignup
2
3

More than 5 years have passed since last update.

vagrantでWordPressのアップデートをする

Posted at

vagrant上にWordPressを入れてはまったのでメモ。

環境

ホスト:MacOSX 10.10.5(14F27)
Vagrant 1.8.1
VirtualBox 5.0.20
ゲスト:CentOS 7.0 x64

ポイント

WordPressを管理画面からアップデートするためには、WPのインストールディレクトリにApacheの権限が権限がないとダメ!

vagrantとホストのディレクトリ共有設定(やらかしver)

Apacheは/var/www/htmlを見にいく

ゲストの/vagrantが同期される
ので、手っ取り早くシンボリックリンクにしてしまう目論見

vagrant

$ cd /var/www
$ sudo rm -r html

ホスト
ホストから実体ファイルを操作するディレクトリ

$ mkdir ~/Vagrant/html

vagrant
シンボリックリンク作成

$ sudo ln -s /vagrant/html /var/www/html

これで、ホストのhtml以下にWPを置いて、vagrant側から見ることはできるようになった。

WordPressのアップデートができないよん

WPの管理画面から、WPのアップデート実行しようとして
サーバのFTP情報を要求される

権限がない。
vagrant側の /var/www/html の権限が
vagrant:vagrant になっている。

$ chown -R apache:apache html

_人人人人人人_
> 変わらない<
 ̄YYYYYY ̄

Vagrantfileで権限設定する

vagrantの共有ディレクトリに権限設定をする場合、Vagrantfileで指定する。

vagrant
シンボリックリンクを削除

[vagrant@localhost ~]$ sudo unlink /var/www/html 

ホスト
一旦先ほどの/vagrant/htmlは破棄。
別ディレクトリを共有対象にして、オプションでオーナーとグループを設定。

Vagrantfile
config.vm.synced_folder "/Users/xxx/Desktop/work/hoge/html", "/var/www/html", id: "vagrant-root", :nfs => false,
    :owner => "apache",
    :group => "apache",
    :mount_options => ["dmode=775,fmode=664"]

$vagrant reloadして、ホストの共有ディレクトリにWPのファイルを置く。

vagrant

[root@localhost www]# ls -al
合計 4
drwxr-xr-x   4 root   root     31  5月 26 00:51 .
drwxr-xr-x. 21 root   root   4096  5月 26 00:51 ..
drwxr-xr-x   2 root   root      6  5月 12 19:28 cgi-bin
drwxrwxr-x   1 apache apache  170  5月 25 22:59 html

ばっちり。

WPのアップデートもできました。

とりあえずここまで。


参考

http://qiita.com/tiwu_official/items/f135e6b6fbbe3ec6aa54
http://www.sandalot.com/wordpress%E6%9B%B4%E6%96%B0%E3%81%A7ftp%E5%85%A5%E5%8A%9B%E7%94%BB%E9%9D%A2%E3%81%8C%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AE%E5%AF%BE%E5%87%A6%E6%B3%95/
http://bulblub.com/2013/10/24/setup_vagrant_synced-folders/
https://www.vagrantup.com/docs/synced-folders/basic_usage.html
http://qiita.com/tbpgr/items/67125ea883409ae5fd51

2
3
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
2
3