Last active
February 24, 2017 09:23
-
-
Save 1stMinos/e5706b1e1a4a15ee6cc184e3a3728e29 to your computer and use it in GitHub Desktop.
(試行錯誤中) Vagrant の設定パターン チートシート
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "My Config by rojiuratech" | |
service httpd restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "My Provision by rojiuratech" | |
echo "First yum repos update" | |
yum update | |
echo "import epel remi repos for php" | |
yum -y install epel-release | |
yum -y install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm | |
echo "import mysql rpm " | |
yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm | |
echo "install and set httpd" | |
yum -y install httpd | |
chkconfig httpd on | |
echo "install ntpd and set current local time JST" | |
yum -y install ntp | |
chkconfig ntpd on | |
echo "set current local time JST" | |
cp /etc/localtime /etc/localtime.org | |
cp /usr/share/zoneinfo/Japan /etc/localtime | |
cp /etc/sysconfig/clock /etc/sysconfig/clock.org | |
chmod 777 /etc/sysconfig/clock | |
sed -i -e 's/UTC/Asia\/Tokyo/g' /etc/sysconfig/clock | |
echo 'UTC=false' >> /etc/sysconfig/clock | |
sudo chmod 644 /etc/sysconfig/clock | |
echo "install PHP (ver 7.1)" | |
#pdoなどもインストールされるようだ? | |
yum -y install --enablerepo=remi-php71 php php-mbstring php-mysql php-devel php-gd php-intl | |
echo "install MySQL" | |
yum -y install mysql mysql-devel mysql-server mysql-utilitiess | |
echo "install Composer" | |
cd /home/vagrant | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
php composer-setup.php | |
mv composer.phar /usr/local/bin/composer | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "bento/centos-6.7" | |
config.vm.provider "virtualbox" do |v| | |
v.name = "Vagrant CentoOS for PHP7" | |
v.cpus = 2 | |
v.memory = 1024 | |
v.customize ["modifyvm", :id, "--vram","16"] | |
v.customize ["setextradata", :id, "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled", 0] | |
end | |
#ネットワーク設定。ローカル環境下で使うことを前提としている ipやbridgeの設定は環境に合わせて! | |
config.vm.network "public_network", ip: "192.168.1.234", bridge: 'en0: Wi-Fi (AirPort)' | |
#プロビジョンするときだけ 各種インストールなどの実行スクリプトを走らせる | |
config.vm.provision :shell, :path => "./provision-script/basic-provision.sh",:privileged => true | |
# config synced_folder でもこれ、 | |
config.vm.synced_folder "/Users/rojiutatech/Documents/workspace/vagrant_html" , "/var/www/html" , owner: "apache", group: "apache" | |
config.vm.synced_folder "/Users/rojiutatech/Documents/workspace/vagrant_cron" , "/var/www/cron" , owner: "apache", group: "apache" | |
config.vm.synced_folder "/Users/rojiutatech/Documents/workspace/vagrant_share" , "/home/vagrant" | |
#プロビジョン以外でも、設定的なスクリプトを走らせる | |
config.vm.provision :shell, run: "always" ,:path => "./provision-script/basic-config.sh",:privileged => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ディレクトリ図
[dir] (vagrant_data)
|-Vagrantfile
|-(provision-script)
|-basic-provision.sh
|-basic-config.sh
プロビジョン(boxから仮装マシンを生成する行為)時のみ実施し、
必要なソフトウェアをインストールや設定処理を記述する basic-provision.sh
vagrant up するたびに(仮装マシンを起動させるたびに)実施し、
必要な設定を実施する basic-config.sh