2018年5月16日水曜日

VagrantでBookStackとPercona Serverをインストールした仮想マシン(Debian Stretch/9.4)を構築する

BookStackはブック・ページといった単位で管理できるWikiソフトウェアです。

〇BookStackの画面

仮想マシン構築後、ブラウザからhttp://192.168.1.108/にアクセスします。

〇構築方法
以下のVagrantfileを使用してBookStackとPercona Serverをインストールした仮想マシン(Ubuntu16.04)を構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.4"
  config.vm.hostname = "db94bookstackpercona"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db94bookstackpercona"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.108", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.108", :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 apache2 
apt-get -y install php7.0 libapache2-mod-php7.0 apache2 php7.0-mbstring php7.0-pdo php7.0-mysqlnd php7.0-simplexml php7.0-mcrypt php7.0-gd php7.0-dom unzip

# install percona server
export DEBIAN_FRONTEND=noninteractive
echo "percona-server-server-5.7 percona-server-server/root_password password root" | sudo debconf-set-selections
echo "percona-server-server-5.7 percona-server-server/root_password_again password root" | sudo debconf-set-selections
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
apt-get update
apt-get -y install percona-server-server-5.7
mysql -uroot -e "CREATE DATABASE bookstack DEFAULT CHARACTER SET utf8mb4;"
mysql -uroot -e "CREATE USER bookstack@localhost IDENTIFIED BY 'bookstack';"
mysql -uroot -e "GRANT ALL PRIVILEGES ON bookstack.* TO 'bookstack'@'localhost';"
mysql -uroot -e "FLUSH PRIVILEGES;"

# install php
apt-get -y install apache2 libapache2-mod-php7.0 php7.0 php7.0-mysqlnd php7.0-pdo php7.0-mbstring php7.0-curl php7.0-mcrypt php7.0-xml php7.0-gd php7.0-zip php7.0-tidy unzip curl git

# install composer
curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

# install bookstack
cd /opt
git clone https://github.com/BookStackApp/BookStack.git --branch release --single-branch
cd /opt/BookStack
composer install

cp .env.example .env
#DB_HOST=localhost
sed -i -e 's/DB_DATABASE=database_database/DB_DATABASE=bookstack/' /opt/BookStack/.env
sed -i -e 's/DB_USERNAME=database_username/DB_USERNAME=bookstack/' /opt/BookStack/.env
sed -i -e 's/DB_PASSWORD=database_user_password/DB_PASSWORD=bookstack/' /opt/BookStack/.env
php artisan key:generate --force
php artisan migrate --force

chown -R www-data:www-data /opt/BookStack
cat << EOF > /etc/apache2/sites-available/bookstack.conf
<VirtualHost *:80>
    ServerName 192.168.1.108
    DocumentRoot /opt/BookStack/public
    <Directory /opt/BookStack/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF
a2enmod rewrite
a2ensite bookstack.conf
a2dissite 000-default.conf
systemctl restart apache2.service

echo 'access to http://192.168.1.108/'
echo 'default account : admin@admin.com/password'
SHELL
end


○関連情報
・BookStackに関する他の記事はこちらを参照してください。

0 件のコメント:

コメントを投稿