2017年12月24日日曜日

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

ownCloudでdropboxのようにファイルを管理する事ができます。
以下のVagrantfileを使用して、ownCloudとMySQLがインストールされた仮想マシン(Debian Stretch/9.2)を構築する事ができます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.2"
  config.vm.hostname = "db92owncloud"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db92owncloud"
     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 mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-server_5.6.38-1debian9_amd64.deb-bundle.tar
tar xvf mysql-server_5.6.38-1debian9_amd64.deb-bundle.tar
echo "mysql-community-server mysql-community-server/root-pass password root" | sudo debconf-set-selections
echo "mysql-community-server mysql-community-server/re-root-pass password root" | sudo debconf-set-selections
apt-get -y install  libaio1 libnuma1 psmisc
dpkg -i mysql-common_5.6.38-1debian9_amd64.deb mysql-client_5.6.38-1debian9_amd64.deb mysql-community-client_5.6.38-1debian9_amd64.deb mysql-community-server_5.6.38-1debian9_amd64.deb

mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' identified by 'root';"

# install php
apt-get -y install apache2 libapache2-mod-php7.0 \
    php7.0-gd php7.0-json php7.0-mysql php7.0-curl \
    php7.0-intl php7.0-mcrypt php-imagick \
    php7.0-zip php7.0-xml php7.0-mbstring

# install owncloud
wget -nv https://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/Release.key -O Release.key
apt-key add - < Release.key
sh -c "echo 'deb http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/ /' > /etc/apt/sources.list.d/owncloud.list"
apt-get update
apt-get -y install owncloud-files
chown www-data:www-data /var/www/owncloud
cd /var/www/owncloud

sudo -u www-data sh -c "php occ maintenance:install --database mysql --database-name owncloud  --database-user root --database-pass root --admin-user admin --admin-pass admin"
sed -i -e "s/0 => 'localhost'/0 => '192.168.1.108', 1 => '192.168.55.108'/" /var/www/owncloud/config/config.php
sed -i -e "s/\\/\\/localhost/\\/\\/192.168.55.108/" /var/www/owncloud/config/config.php
ln -s /var/www/owncloud /var/www/html/

service apache2 restart

echo 'access http://192.168.55.108/owncloud/'
echo 'user: admin, password: admin'
SHELL
end

〇ownCloudの画面


0 件のコメント:

コメントを投稿