2018年7月17日火曜日

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

selfossはPHP製のフィードリーダーです。

〇selfossの画面


〇構築方法
以下のVagrantfileを使用して、selfossとPostgreSQL10がインストールされた仮想マシン(Ubuntu18.04)を構築する事が出来ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804selfosspg10"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804selfosspg10"
     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 -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install postgresql
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get upgrade
apt-get -y install postgresql-10

echo "listen_addresses='*'" >> /etc/postgresql/10/main/postgresql.conf

#sed -i 's/host.*all.*all.*127.0.0.1/#host    all             all             127.0.0.1/g' /etc/postgresql/10/main/pg_hba.conf

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

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


# install selfoss
apt-get -y install apache2 apache2-bin libapache2-mod-php7.2 php7.2-pgsql php7.2-mbstring php7.2-xml php7.2-gd unzip
mkdir -p /opt/selfoss
cd /opt/selfoss
wget https://github.com/SSilence/selfoss/releases/download/2.18/selfoss-2.18.zip
unzip selfoss-2.18.zip
cp defaults.ini config.ini
sed -i -e 's/db_type=sqlite/db_type=pgsql/' 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=5432/' 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.105/selfoss/'
echo 'sample feed: http://serverarekore.blogspot.com/feeds/posts/default'
SHELL
end


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

0 件のコメント:

コメントを投稿