2018年2月25日日曜日

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

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

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604snipeit"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604snipeit"
     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
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
apt-get update
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
localectl set-keymap jp106
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install mysql
echo "mysql-server-5.7 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.7 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mysql-server-5.7
mysql -uroot -proot -e "CREATE DATABASE snipeit DEFAULT CHARACTER SET utf8mb4;"
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-mysqlnd php7.0-pdo php7.0-mbstring php7.0-curl php7.0-mcrypt 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
composer install --no-dev --prefer-source
composer dump-autoload

cp /opt/snipeit/.env.example /opt/snipeit/.env
sed -i -e "s#APP_URL=null#APP_URL=http://192.168.1.105/#" /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
php artisan migrate --force
php artisan key:generate --force
php artisan config:clear
php artisan config:cache

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.105
    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.105/'
SHELL
end

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


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


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


〇Snipe-ITの画面



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

0 件のコメント:

コメントを投稿