2019年3月25日月曜日

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

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

〇Snipe-ITの画面


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

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804snipeitmariadb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804snipeitmariadb"
     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 update
apt-get -y install language-pack-ja
#sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo

# 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 mariadb-client
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.2 php7.2 php7.2-mysql php7.2-common php7.2-mbstring php7.2-curl php7.2-xml php7.2-gd php7.2-zip php7.2-ldap php7.2-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 件のコメント:

コメントを投稿