環境構築記録Vagrant CentOS7 Apache2.4 PHP7 CakePHP2.7 MariaDB

環境構築記録Vagrant CentOS7 Apache2.4 PHP7 CakePHP2.7 MariaDB

Vagrant CentOS7 Apache MariaDBの環境構築をしたので手順を記録しておきます。何かの参考になれば何よりです。

vagrant-vbguest

Vagrantfileがあるディレクトリにて

$ vagrant plugin install vagrant-vbguest

VagrantBox(CentOS7)

$ vagrant init centos/7;

Vagrantfileを

config.vm.network "private_network", ip: "192.168.33.10"
 config.vm.synced_folder ".", "/vagrant", type: "virtualbox",
 :owner => "apache",
 :group => "apache",
 :mount_options => ["dmode=775,fmode=775"]

にして

$ vagrant up --provider virtualbox

参考

https://atlas.hashicorp.com/centos/boxes/7

Apache2.4

# yum install httpd

PHP7

# yum install epel-release
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd
# rpm -qa | grep php

php.iniの設定

# vi /etc/php.ini
expose_php = Off
date.timezone = 'Asia/Tokyo'
error_log = "/var/log/php/php_errors.log"

MariaDB

# yum install mariadb-server

MariaDBの設定は別に記載。

https://normalblog.net/system/mariadb-install-settings/

PHPとMySQLの連携

# yum install --enablerepo=remi,remi-php70 php-mysqlnd

ifconfig

yum -y install net-tools

ユーザ作成

# useradd ユーザ名

Vagrant共有ディレクトリで公開ディレクトリ設定

Vagrant外でVagrantfileがあるディレクトにsrcディレクトリを生成

# ln -fs /vagrant/src /home/user/src

Apache conf設定

<VirtualHost *:80>
    ServerName test.local
    DocumentRoot /home/user/src/test/app/webroot
    ErrorLog /home/hase_done/logs/eroor_log
    CustomLog /home/hase_done/logs/access_log combined

    <Directory /home/user/src/test/app/webroot>
        Options FollowSymlinks Includes
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

SELINUX無効化

vi /etc/sysconfig/selinux

SELINUX=enfocing

SELINUX=disabled

ブラウザ確認

ローカル開発環境の場合C:\Windows\System32\drivers\etc\hostsに以下記載

※macの場合は sudo vi /private/etc/hosts

192.168.33.10 test.local

【関連記事】VirtualBoxとVagrantの仮想環境構築まとめ

https://normalblog.net/system/vagrant_matome/

【簡易版】Vagrantを利用した仮想サーバ開発環境の立ち上げまでの7つの手順

という手順もまとめました。

https://normalblog.net/system/vagrant-up/

Comments

No comments yet. Why don’t you start the discussion?

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です