Skip to content

Commit

Permalink
プロビジョニング書き直し
Browse files Browse the repository at this point in the history
  • Loading branch information
ucan-lab committed May 25, 2018
1 parent 1149f52 commit caf2caa
Show file tree
Hide file tree
Showing 30 changed files with 1,162 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store
.vagrant
package.box
Vagrantfile
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@ URL | http://192.168.99.99
MySQLユーザー | vagrant
MySQLパスワード | MySQL5.7

# リンク

- [Vagrant](https://www.vagrantup.com)
- [VirtualBox](https://www.virtualbox.org)
- [Macの初期設定参考リンク](https://github.com/ucan-lab/tips/issues/3)

# プラグイン
# バージョン

```
$ vagrant plugin install vagrant-share vagrant-vbguest
$ os
macOS High Sierra 10.13.4
$ vagrant --version
Vagrant 2.1.1
$ VBoxManage --version
5.2.12r122591
$ git --version
git version 2.17.0
```

# 環境構築

```
$ git clone https://github.com/ucan-lab/vagrant-laravel55
$ cd vagrant-laravel55
$ cp Vagrantfile.example Vagrantfile
$ vagrant up
```

# リンク

- [Vagrant](https://www.vagrantup.com)
- [VirtualBox](https://www.virtualbox.org)
- [Macの初期設定参考リンク](https://github.com/ucan-lab/tips/issues/3)
62 changes: 2 additions & 60 deletions provision/bootstrap.sh → provision/centos/7/_base.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash -eu

echo -------------------------------------------------
echo
echo 設定
echo
echo -------------------------------------------------

PROVISION=/vagrant/provision

echo -------------------------------------------------
echo
echo yum 高速化設定
Expand All @@ -26,7 +18,7 @@ EOS

echo -------------------------------------------------
echo
echo 基本設定
echo OS更新等
echo
echo -------------------------------------------------

Expand All @@ -36,7 +28,7 @@ yum -y groupinstall "Base" "Development tools" "Japanese Support"

echo -------------------------------------------------
echo
echo 便利ツール
echo ユーティリティー
echo
echo -------------------------------------------------

Expand Down Expand Up @@ -81,47 +73,6 @@ sed -i 's/apply_updates = no/apply_updates = yes/' /etc/yum/yum-cron.conf
systemctl start yum-cron
systemctl enable yum-cron

echo -------------------------------------------------
echo
echo Git
echo
echo -------------------------------------------------

yum -y remove git
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install git2u

yum -y install yum-utils
yum-config-manager --disable ius

echo -------------------------------------------------
echo
echo PHP
echo
echo -------------------------------------------------

# source $PROVISION/php71.sh
source $PROVISION/php72.sh

echo -------------------------------------------------
echo
echo MySQL
echo
echo -------------------------------------------------

source $PROVISION/mysql57.sh

echo -------------------------------------------------
echo
echo Nodejs8.x, yarn
echo
echo -------------------------------------------------

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum -y install nodejs
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum -y install yarn

echo -------------------------------------------------
echo
echo chrony NTP設定
Expand All @@ -131,12 +82,3 @@ echo -------------------------------------------------
yum -y install chrony
systemctl start chronyd
systemctl enable chronyd

echo -------------------------------------------------
echo
echo クリア
echo
echo -------------------------------------------------

yum clean all
history -c
20 changes: 20 additions & 0 deletions provision/centos/7/_git2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
echo -------------------------------------------------
echo
echo Git2
echo
echo -------------------------------------------------

yum -y remove git
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install git2u

yum -y install yum-utils
yum-config-manager --disable ius

echo -------------------------------------------------
echo
echo Git Version
echo
echo -------------------------------------------------

git --version
11 changes: 11 additions & 0 deletions provision/centos/7/_heroku.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo -------------------------------------------------
echo
echo heroku-cli
echo
echo -------------------------------------------------

wget https://cli-assets.heroku.com/heroku-cli/channels/stable/heroku-cli-linux-x64.tar.gz -O heroku.tar.gz
mkdir -p /usr/local/lib/heroku
tar --strip-components 1 -zxvf heroku.tar.gz -C /usr/local/lib/heroku 1>/dev/null
ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku
rm -f heroku.tar.gz
75 changes: 75 additions & 0 deletions provision/centos/7/_mysql56.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash -eu

echo -------------------------------------------------
echo
echo MySQL5.6
echo
echo -------------------------------------------------

yum -y install https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum -y install yum-utils
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
yum -y install mysql-community-server mysql-community-devel

echo -------------------------------------------------
echo
echo MySQL 設定
echo
echo -------------------------------------------------

mkdir -p /var/log/mysql
chown -R mysql:mysql /var/log/mysql

ln -sf $PROVISION/config/mysql56/my.cnf /etc/my.cnf -S .org

echo -------------------------------------------------
echo
echo MySQL 起動、自動起動
echo
echo -------------------------------------------------

systemctl start mysqld
systemctl enable mysqld

echo -------------------------------------------------
echo
echo MySQL 初期設定
echo
echo -------------------------------------------------

# rootユーザーパスワード設定
NEW_PASSWORD=MySQL5.6
mysqladmin -u root password $NEW_PASSWORD
# anonymasユーザー削除
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.user WHERE User='';"
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
# testデータベース削除
mysql -u root -p$NEW_PASSWORD -e "DROP DATABASE IF EXISTS test;"
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"
# vagrantユーザー作成
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED BY '$NEW_PASSWORD'"
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'127.0.0.1' IDENTIFIED BY '$NEW_PASSWORD'"
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'192.168.%' IDENTIFIED BY '$NEW_PASSWORD'"
# 権限反映
mysql -u root -p$NEW_PASSWORD -e "FLUSH PRIVILEGES;"

echo -------------------------------------------------
echo
echo MySQL ログイン設定
echo
echo -------------------------------------------------

cp $PROVISION/config/mysql56/.mylogin.root.cnf /root/.mylogin.cnf
cp $PROVISION/config/mysql56/.mylogin.vagrant.cnf /home/vagrant/.mylogin.cnf
chmod 600 /root/.mylogin.cnf
chmod 600 /home/vagrant/.mylogin.cnf
chown vagrant:vagrant /home/vagrant/.mylogin.cnf

echo -------------------------------------------------
echo
echo MySQL Version
echo
echo -------------------------------------------------

mysql --version
24 changes: 17 additions & 7 deletions provision/mysql57.sh → provision/centos/7/_mysql57.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ echo
echo -------------------------------------------------

mv /etc/my.cnf /etc/my.cnf.org
cp $PROVISION/dev/etc/my57.cnf /etc/my.cnf
cp $BASE_DIR/config/mysql57/my.cnf /etc/my.cnf
mkdir -p /var/log/mysql
chown -R mysql:mysql /var/log/mysql
systemctl start mysqld
Expand All @@ -33,21 +33,31 @@ NEW_PASSWORD=MySQL5.7
# rootパスワード変更
mysqladmin -p${OLD_PASSWORD} password ${NEW_PASSWORD}
# リモートからのrootユーザでのログインの禁止
mysql -u root -p"$NEW_PASSWORD" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')"
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')"
# anonymousの削除
mysql -u root -p"$NEW_PASSWORD" -e "DELETE FROM mysql.user WHERE User=''"
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.user WHERE User=''"
# testデータベースの削除
mysql -u root -p"$NEW_PASSWORD" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'"
mysql -u root -p$NEW_PASSWORD -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'"
# vagrantユーザーの作成
mysql -u root -p"$NEW_PASSWORD" -e "GRANT ALL PRIVILEGES ON *.* TO vagrant@localhost IDENTIFIED BY '$NEW_PASSWORD'"
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED BY '$NEW_PASSWORD'"
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'127.0.0.1' IDENTIFIED BY '$NEW_PASSWORD'"
mysql -u root -p$NEW_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'192.168.%' IDENTIFIED BY '$NEW_PASSWORD'"
# 権限設定の反映
mysql -u root -p"$NEW_PASSWORD" -e "FLUSH PRIVILEGES"
mysql -u root -p$NEW_PASSWORD -e "FLUSH PRIVILEGES"

echo -------------------------------------------------
echo
echo MySQL ログイン設定
echo
echo -------------------------------------------------

cp $PROVISION/dev/root/.mylogin.cnf /root/.mylogin.cnf
cp $BASE_DIR/config/root/.mylogin.cnf /root/.mylogin.cnf
chmod 600 ~/.mylogin.cnf

echo -------------------------------------------------
echo
echo MySQL Version
echo
echo -------------------------------------------------

mysql --version
24 changes: 24 additions & 0 deletions provision/centos/7/_nodejs8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
echo -------------------------------------------------
echo
echo Nodejs8.x, yarn
echo
echo -------------------------------------------------

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum -y install nodejs

echo -------------------------------------------------
echo
echo Node Version
echo
echo -------------------------------------------------

node --version

echo -------------------------------------------------
echo
echo npm Version
echo
echo -------------------------------------------------

npm --version
18 changes: 17 additions & 1 deletion provision/php71.sh → provision/centos/7/_php71.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,23 @@ echo
echo -------------------------------------------------

mv /etc/php.ini /etc/php.ini.org
cp $PROVISION/dev/etc/php71.ini /etc/php.ini
cp $BASE_DIR/config/php71/php.ini /etc/php.ini
mkdir -p /var/log/php
chown -R 777 /var/log/php
systemctl restart httpd

echo -------------------------------------------------
echo
echo PHP Version
echo
echo -------------------------------------------------

php --version

echo -------------------------------------------------
echo
echo Composer Version
echo
echo -------------------------------------------------

composer --version
18 changes: 17 additions & 1 deletion provision/php72.sh → provision/centos/7/_php72.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,23 @@ echo
echo -------------------------------------------------

mv /etc/php.ini /etc/php.ini.org
cp $PROVISION/dev/etc/php72.ini /etc/php.ini
cp $BASE_DIR/config/php72/php.ini /etc/php.ini
mkdir -p /var/log/php
chown -R 777 /var/log/php
systemctl restart httpd

echo -------------------------------------------------
echo
echo PHP Version
echo
echo -------------------------------------------------

php --version

echo -------------------------------------------------
echo
echo Composer Version
echo
echo -------------------------------------------------

composer --version
Loading

0 comments on commit caf2caa

Please sign in to comment.