2017年12月23日土曜日

VagrantでOctoberCMSとMySQLをインストールした仮想マシン(Debian Stretch/9.2)を構築する

OctoberCMSはPHP製のCMSです。
以下のVagrantfileを使用して、OctoberCMSとMySQLがインストールされた仮想マシン(Debian Stretch/9.2)を構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.1.105/octobercms/install.phpにアクセスして初期設定を行います。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.2"
  config.vm.hostname = "db92octobercms"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db92octobercms"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
  config.vm.network "private_network", ip: "192.168.55.105", :netmask => "255.255.255.0"
  config.vm.network "public_network", ip:"192.168.1.105", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
apt-get -y install task-japanese
sed -i -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install mysql
wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb
export DEBIAN_FRONTEND=noninteractive
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7-dmr | sudo debconf-set-selections
dpkg -i mysql-apt-config_0.8.9-1_all.deb
apt-get update
apt-get -y install mysql-server
mysql -uroot -e "CREATE DATABASE octobercms DEFAULT CHARACTER SET utf8;"
mysql -uroot -e "CREATE USER octobercms@localhost IDENTIFIED BY 'octobercms';"
mysql -uroot -e "GRANT ALL PRIVILEGES ON octobercms.* TO 'octobercms'@'localhost';"
mysql -uroot -e "FLUSH PRIVILEGES;"

# install php
apt-get -y install apache2 libapache2-mod-php7.0
apt-get -y install php7.0-gd php7.0-json php7.0-mysql php7.0-pdo php7.0-curl php7.0-mbstring
apt-get -y install php7.0-mcrypt php7.0-xml php7.0-zip
# install octobercms
apt-get -y install unzip
wget -O install-master.zip http://octobercms.com/download
unzip install-master.zip
mv install-master /opt/octobercms
chown -R www-data:www-data /opt/octobercms
ln -s  /opt/octobercms /var/www/html
cat << EOF >> /etc/apache2/apache2.conf

        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

EOF
a2enmod rewrite
service apache2 restart
echo 'access http://192.168.1.105/octobercms/install.php'
echo 'db user:octobercms  password:octobercms  db:octobercms'
SHELL
end

〇初期設定画面1


〇初期設定画面2


〇初期設定画面3


〇初期設定画面4


〇初期設定画面5


〇初期設定画面6


〇管理者画面


〇OctoberCMSの画面


0 件のコメント:

コメントを投稿