2018年3月15日木曜日

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

selfossはPHP製のフィードリーダーです。
以下のVagrantfileを使用して、selfossとMariaDBがインストールされた仮想マシン(Debian Stretch/9.3)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/debian-9.3"
  config.vm.hostname = "db93selfossmariadb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "db93selfossmariadb"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :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 selfoss DEFAULT CHARACTER SET utf8;"
mysql -uroot -proot -e "CREATE USER selfoss@localhost IDENTIFIED BY 'selfoss';"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON selfoss.* TO 'selfoss'@'localhost';"
mysql -uroot -proot -e "FLUSH PRIVILEGES;"


# install selfoss
apt-get -y install apache2 apache2-bin libapache2-mod-php7.0 php7.0-mysql php7.0-mbstring php7.0-xml php7.0-gd unzip
mkdir -p /opt/selfoss
cd /opt/selfoss
wget https://github.com/SSilence/selfoss/releases/download/2.17/selfoss-2.17.zip
unzip selfoss-2.17.zip
cp defaults.ini config.ini
sed -i -e 's/db_type=sqlite/db_type=mysql/' config.ini
#db_host=localhost
#db_database=selfoss
sed -i -e 's/db_username=root/db_username=selfoss/' config.ini
sed -i -e 's/db_password=/db_password=selfoss/' config.ini
sed -i -e 's/db_port=/db_port=3306/' config.ini
echo '0,10,20,30,40,50 * * * * root /usr/bin/php /opt/selfoss/cliupdate.php' >> /etc/crontab
systemctl restart cron

chown -R www-data:www-data /opt/selfoss
ln -s  /opt/selfoss /var/www/html
cat << EOF >> /etc/apache2/apache2.conf
<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
EOF
a2enmod rewrite
service apache2 restart

echo 'access http://192.168.1.101/selfoss/'
echo 'sample feed: http://serverarekore.blogspot.com/feeds/posts/default'

SHELL
end

〇selfossの画面



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

0 件のコメント:

コメントを投稿