2018年6月13日水曜日

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

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

〇BookStackの画面

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

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

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.4"
  config.vm.hostname = "db94bookstackmariadb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db94bookstackmariadb"
     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 mariadb
echo "mariadb-server-10.3 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mariadb-server-10.3 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mariadb-server
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 件のコメント:

コメントを投稿