2017年11月27日月曜日

VagrantでWallabagとMySQLをインストールした仮想マシン(CentOS7.4)を構築する

WallabagでPocketのようにブックマークした記事を読むことができます。
以下のVagrantfileを使用して、WallabagとMySQLをインストールした仮想マシンを構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.1.105/にアクセスします。
デフォルトユーザはwallabag、パスワードはwallabagです。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.hostname = "co74wallabag"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "co74wallabag"
     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
localectl set-locale LANG=ja_JP.UTF-8

# mysqlのインストール
sudo yum -y remove mariadb-libs
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum -y install yum-utils
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
yum -y install mysql mysql-devel mysql-server mysql-utilities
sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service

# change password and create users and databases.
chkconfig mysqld on
service mysqld start
export MYSQL_ROOTPWD='Root123#'
export MYSQL_PWD=`cat /var/log/mysqld.log | awk '/temporary password/ {print $NF}'`
mysql -uroot --connect-expired-password -e "SET PASSWORD = PASSWORD('$MYSQL_ROOTPWD');"
export MYSQL_PWD=$MYSQL_ROOTPWD
export MYSQL_ROOTPWD='root'
mysql -uroot --connect-expired-password -e "UNINSTALL PLUGIN validate_password;"
mysql -uroot --connect-expired-password -e "SET PASSWORD = PASSWORD('$MYSQL_ROOTPWD'); FLUSH PRIVILEGES;"
mysql -uroot -proot -e "CREATE DATABASE wallabag DEFAULT CHARACTER SET utf8;"
export MYSQL_PWD=$MYSQL_ROOTPWD

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
yum -y install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install --enablerepo=remi,remi-php71 httpd php php-devel php-mbstring php-pdo php-mysqlnd php-gd php-xml php-zip php-json php-zip php-tidy php-bcmath php-curl

# install wallabag
mkdir -p wallabag
cd ~/wallabag

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

cat << EOF > /opt/wallabag/app/config/parameters.yml
parameters:
    database_driver: pdo_mysql
    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
    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/httpd/conf.d/wallabag.conf
<VirtualHost *:80>
    ServerName 192.168.55.105
    DocumentRoot /opt/wallabag/web
    <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 apache:apache /opt/wallabag
ln -s  /opt/wallabag /var/www/html

systemctl restart httpd.service
echo 'access http://192.168.1.105/'
echo 'user:wallabag  password:wallabag'
SHELL
end

〇wallabagの画面



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

0 件のコメント:

コメントを投稿