2017年11月19日日曜日

VagrantでownCloudとPostgreSQLをインストールした仮想マシン(Ubuntu16.04)を構築する

以下のVagrantfileを使用して、ownCloudとPostgreSQLをインストールした仮想マシンを構築する事ができます。
仮想マシンが構築された後、ブラウザからhttp://192.168.55.108/owncloud/にユーザadmin、パスワードadminでアクセスします。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604owncloud"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604owncloud"
     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
locale-gen ja_JP.UTF-8
localectl set-locale LANG=ja_JP.UTF-8
# update packages
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install postgresql
sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get -y install postgresql-9.6
echo "listen_addresses='*'" >> /etc/postgresql/9.5/main/postgresql.conf
echo "standard_conforming_strings=off" >> /etc/postgresql/9.5/main/postgresql.conf

echo "host    all         all         127.0.0.1/32          password" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host    all         all         192.168.1.0/24          password" >> /etc/postgresql/9.5/main/pg_hba.conf
echo "host    all         all         192.168.55.0/24          password" >> /etc/postgresql/9.5/main/pg_hba.conf

su - postgres << EOF
createdb -T template0 --locale=ja_JP.UTF-8 --encoding=UTF8 owncloud
psql -c "
alter user postgres with password 'postgres';
create user owncloud with password 'owncloud';
grant all privileges on database owncloud to owncloud;
"
EOF
echo "postgres:postgres" | chpasswd
systemctl restart postgresql.service
systemctl enable postgresql.service

# 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 apache2 libapache2-mod-php7.0 \
    php7.0-gd php7.0-json php7.0-pg php7.0-curl \
    php7.0-intl php7.0-mcrypt php-imagick \
    php7.0-zip php7.0-xml php7.0-mbstring

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-host localhost --database pgsql --database-name owncloud  --database-user owncloud --database-pass owncloud --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 件のコメント:

コメントを投稿