ArchLinux 2018.10.01: Install Tiny Tiny RSS for web base RSS reader

This article will installing Tiny Tiny RSS which is web base RSS reader.

1 Install Tiny Tiny RSS

The following script will install Tiny Tiny RSS.

  • MYSQL_PASSWD is root user's password of MySQL.
  • TT_RSS_PASSWD is ttrss user's password of MySQL.
  • TT_RSS_FQDN is a server machine's FQDN. Please change your server machine which will be installed Tiny Tiny RSS.
#!/bin/sh -e

[ -z "${MYSQL_PASSWD}" ] && MYSQL_PASSWD=mysql
[ -z "${TT_RSS_PASSWD}" ] && TT_RSS_PASSWD=ttrss
[ -z "${TT_RSS_FQDN}" ] && TT_RSS_FQDN=$(hostname -f)
TT_RSS_URL=https://${TT_RSS_FQDN}/tt-rss

mysql_install()
{
  sudo pacman -Sy --noconfirm mariadb

  # Install database.
  sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

  sudo systemctl enable mariadb
  sudo systemctl start mariadb

  # Password configuration.
  cat <<EOF | sudo mysql_secure_installation

y
${MYSQL_PASSWD}
${MYSQL_PASSWD}
n
y
y
y
EOF

  # Create user and database for tt-rss.
  cat <<EOF | sudo mysql -uroot -p${MYSQL_PASSWD}
CREATE DATABASE ttrss CHARACTER SET UTF8;
CREATE USER 'ttrss'@'localhost' IDENTIFIED BY '${TT_RSS_PASSWD}';
GRANT ALL PRIVILEGES ON ttrss.* TO 'ttrss'@'localhost';
EOF
}

php_install()
{
  # Enable PHP extension.
  sudo pacman -Sy --noconfirm php
  sudo sed -i /etc/php/php.ini \
       -e 's/^;extension=pdo_mysql/extension=pdo_mysql/g' \
       -e 's/^;extension=mysqli/extension=mysqli/g'
}

ttrss_install()
{
  sudo pacman -Sy --noconfirm tt-rss
  sudo sed -i /etc/webapps/tt-rss/config.php \
       -e "s;define('DB_TYPE', .*);define('DB_TYPE', \"mysql\");g" \
       -e "s;define('DB_USER', .*);define('DB_USER', \"ttrss\");g" \
       -e "s;define('DB_NAME', .*);define('DB_NAME', \"ttrss\");g" \
       -e "s;define('DB_PASS', .*);define('DB_PASS', \"${TT_RSS_PASSWD}\");g" \
       -e "s;define('SELF_URL_PATH', .*);define('SELF_URL_PATH', '${TT_RSS_URL}');g"

  # shellcheck disable=SC2002
  cat /usr/share/webapps/tt-rss/schema/ttrss_schema_mysql.sql | \
    sudo mysql -uttrss -p${TT_RSS_PASSWD} ttrss
}

apache_install()
{
  sudo pacman -Sy --noconfirm apache php-apache
  sudo systemctl enable httpd

  # PHP configuration.
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^LoadModule mpm_event_module/#LoadModule mpm_event_module/g' \
       -e 's/^#LoadModule mpm_prefork_module/LoadModule mpm_prefork_module/g'
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf
EOF

  # ssl configuration.
  # Country Name (2 letter code) [AU]:
  # State or Province Name (full name) [Some-State]:
  # Locality Name (eg, city) []:
  # Organization Name (eg, company) [Internet Widgits Pty Ltd]:
  # Organizational Unit Name (eg, section) []:
  # Common Name (e.g. server FQDN or YOUR name) []:
  # Email Address []:
  cat <<EOF | sudo openssl req -new -x509 -nodes -newkey rsa:4096 -days 1095 \
                   -keyout /etc/httpd/conf/server.key \
                   -out /etc/httpd/conf/server.crt
AU
Some-State
city
company
section
${WEBDAV_SERVER_FQDN}

EOF
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^#LoadModule ssl_module/LoadModule ssl_module/g' \
       -e 's/^#LoadModule socache_shmcb_module/LoadModule socache_shmcb_module/g'
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/httpd-ssl.conf
EOF

  # rewrite configuration.
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g'
  cat << EOF | sudo tee /etc/httpd/conf/extra/redirect-to-https.conf
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
EOF
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/redirect-to-https.conf
EOF

  cat << EOF | sudo tee /etc/httpd/conf/extra/tt-rss.conf
Alias /tt-rss /usr/share/webapps/tt-rss
<Directory /usr/share/webapps/tt-rss>
  AllowOverride All
  Options FollowSymlinks
  Require all granted
</Directory>
EOF
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/tt-rss.conf
EOF

  sudo systemctl restart httpd
}

ttrss_main()
{
  mysql_install
  php_install
  ttrss_install
  apache_install
}

ttrss_main

2 Access to Tiny Tiny RSS

Access to the following URL. Accept this page's certification to browser.

https://<server>/tt-rss

Login page of Tiny Tiny RSS is displayed. Login as admin user with setting "admin" to Login and "password" to Password.

0001_tt-rss.png