2019年3月25日月曜日

VagrantでSnipe-IT、MariaDBがインストールされた仮想マシン(Debian Stretch/9.5)を構築する

Snipe-ITを使用して、資産管理を行う事ができます。

〇Snipe-ITの画面


〇構築方法
以下のVagrantfileを使用して、Snipe-IT、MariaDBをインストールした仮想マシン(Debian Stretch/9.5)を構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.1.106/にアクセスして初期設定を行います。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.5"
  config.vm.hostname = "db95snipeitmariadb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db95snipeitmariadb"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.106", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.106", :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 mariadb
echo "mariadb-server-10.0 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mariadb-server-10.0 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mariadb-server
mysql -uroot -proot -e "CREATE DATABASE snipeit DEFAULT CHARACTER SET utf8;"
mysql -uroot -proot -e "CREATE USER snipeit@localhost IDENTIFIED BY 'snipeit';"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON snipeit.* TO 'snipeit'@'localhost';"
mysql -uroot -proot -e "FLUSH PRIVILEGES;"


# install php
apt-get -y install apache2 libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-common php7.0-mbstring php7.0-curl php7.0-xml php7.0-gd php7.0-zip php7.0-ldap php7.0-bcmath unzip curl git

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

mkdir -p /opt/snipeit
git clone https://github.com/snipe/snipe-it /opt/snipeit
cd /opt/snipeit

cp /opt/snipeit/.env.example /opt/snipeit/.env
sed -i -e "s#APP_URL=null#APP_URL=http://192.168.1.106/#" /opt/snipeit/.env
sed -i -e "s#APP_TIMEZONE='UTC'#APP_TIMEZONE='Asia/Tokyo'#" /opt/snipeit/.env
sed -i -e "s#APP_LOCALE=en#APP_LOCALE=ja#" /opt/snipeit/.env
sed -i -e "s#DB_DATABASE=null#DB_DATABASE=snipeit#" /opt/snipeit/.env
sed -i -e "s#DB_USERNAME=null#DB_USERNAME=snipeit#" /opt/snipeit/.env
sed -i -e "s#DB_PASSWORD=null#DB_PASSWORD=snipeit#" /opt/snipeit/.env
composer install --no-dev --prefer-source
php artisan key:generate --force
php artisan config:clear
php artisan config:cache
php artisan migrate --force
composer dump-autoload

chown -R www-data:www-data /opt/snipeit
chmod -R 755 /opt/snipeit/storage
chmod -R 755 /opt/snipeit/public/uploads
chmod -R 755 /opt/snipeit/bootstrap/cache

ln -s  /opt/snipeit/public /var/www/html
cat << EOF > /etc/apache2/sites-available/snipeit.conf
<VirtualHost *:80>
    ServerName 192.168.55.106
    DocumentRoot /opt/snipeit/public
    <Directory /opt/snipeit/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF
a2enmod rewrite
a2ensite snipeit.conf
a2dissite 000-default.conf
systemctl restart apache2.service

echo 'access http://192.168.1.106/'

SHELL
end

〇Snipt-ITの初期設定画面1


〇Snipt-ITの初期設定画面2


〇Snipt-ITの初期設定画面3



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

0 件のコメント:

コメントを投稿