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 5 years have passed since last update.

WordPressの制作環境をVagrantで

Posted at

WordPressの制作環境をVagrantで作ります。

Vagrant起ち上げ

以下の設定でvagrant up

Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

そしてvagrant ssh

必要なモジュールのインストールと設定

yum -y install httpd mysql-server php php-mysql
# サーバーとDBを常に起動させておく
service httpd start
chkconfig httpd on

service mysqld start
chkconfig mysqld on

※ 上記でmysqlが起動できないとき

yum -y install mariadb-server
service mariadb start
chkconfig mariadb on

したらいけた

ローカルのディレクトリを公開ディレクトリと同期させる

Vagrantはデフォルトでゲスト(vagrant sshした先のサーバー)の/vagrantディレクトリとホスト(ローカル)のVagrantを起動しているルートディレクトリが同期しています。

その機能をうまく使って/var/www/htmlで公開しているディレクトリとローカルのディレクトリを同期させちゃいましょう

ローカル側
mkdir html
vagrant側
ln -s -d /vagrant/html /var/www

詳しい説明は割愛しますが、これでローカルのhtmlディレクトリと公開している/var/www/htmlディレクトリが同期するようになりました。

DB作成

WordPress用に下記のように作ります。

DB名 mywordpress
ユーザー名 myuser
パス mypass

実行

mysql -u root
CREATE DATABASE mywordpress;

GRANT ALL PRIVILEGES ON mywordpress.* TO myuser@localhost IDENTIFIED BY 'mypass' WITH GRANT OPTION;

WordPressの設置

公式からとってきて,ローカルのhtmlフォルダに設置

http://localhost:8080/ にアクセスしたらセットアップ画面でてくるはず

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?