2018年4月8日日曜日

VagrantでWallabagとMariaDBがインストールされた仮想マシン(Ubuntu16.04)を構築する

Wallabagで気になったwebページをブックマークしておいて、後で読むことができます。
以下のVagrantfileを使用して、WallabagとMariaDBをインストールした仮想マシン(Ubuntu16.04)を構築できます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604wallabagmariadb"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604wallabagmariadb"
     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
# update packages
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 wallabag DEFAULT CHARACTER SET utf8mb4;"
mysql -uroot -proot -e "CREATE USER wallabag@localhost IDENTIFIED BY 'wallabag';"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON wallabag.* TO 'wallabag'@'localhost';"
mysql -uroot -proot -e "FLUSH PRIVILEGES;"

# install apache2 and php
apt-get -y install apache2 libapache2-mod-php7.0
apt-get -y install php7.0-gd php7.0-json php7.0-mysql php7.0-pdo php7.0-curl php7.0-mbstring
apt-get -y install php7.0-mcrypt php7.0-xml php7.0-zip php7.0-gd php7.0-tidy php7.0-bcmath

# install wallabag
mkdir -p wallabag
cd ~/wallabag

wget http://wllbg.org/latest-v2-package
tar xvfz latest-v2-package
mv wallabag-release-* /opt/wallabag


cat << EOF > /opt/wallabag/app/config/parameters.yml
parameters:
    database_driver: pdo_mysql
    database_driver_class: ~
    database_host: 127.0.0.1
    database_port: null
    database_name: wallabag
    database_user: wallabag
    database_password: wallabag
    database_path: null
    database_table_prefix: wallabag_
    database_socket: null
    database_charset: utf8
    domain_name: http://192.168.1.105
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: ovmpmAWXRCabNlMgzlzFXDYmCFfzGv
    twofactor_auth: true
    twofactor_sender: no-reply@wallabag.org
    fosuser_registration: true
    fosuser_confirmation: true
    from_email: no-reply@wallabag.org
    rss_limit: 50
    rabbitmq_host: localhost
    rabbitmq_port: 5672
    rabbitmq_user: guest
    rabbitmq_password: guest
    rabbitmq_prefetch_count: 10
    redis_scheme: tcp
    redis_host: localhost
    redis_port: 6379
    redis_path: null
    redis_password: null
    sites_credentials: {  }
EOF

cat << EOF > /etc/apache2/sites-available/wallabag.conf
<VirtualHost *:80>
    ServerName 192.168.1.105
    DocumentRoot /opt/wallabag/web
    ErrorLog /var/log/apache2/bag.local.error.log
    CustomLog /var/log/apache2/bag.local.access.log combined
    LogLevel warn
    <Directory /opt/wallabag/web>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
EOF
cd /opt/wallabag
php bin/console wallabag:install --env=prod -n
chown -R www-data:www-data /opt/wallabag
ln -s  /opt/wallabag /var/www/html

a2ensite wallabag.conf
a2dissite 000-default.conf
systemctl reload apache2.service
echo 'access http://192.168.1.105/'
echo 'user:wallabag  password:wallabag'
SHELL
end

〇Wallabagの画面


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

0 件のコメント:

コメントを投稿