Troubleshooting Tiny Tiny RSS (tt-rss) Installation and Configuration Issues

As a dedicated user and contributor within the open-source community, revWhiteShadow of revWhiteShadow, a personal blog focused on technology and self-hosting, understands the frustrations that can arise during the installation and configuration of applications like Tiny Tiny RSS (tt-rss). This comprehensive guide addresses common challenges encountered during the tt-rss setup process, drawing upon practical experience and offering detailed solutions. We aim to provide a robust resource that supplements existing documentation and empowers users to successfully deploy and maintain their tt-rss instances.

Addressing the PHP-Legacy vs. PHP Conflict in tt-rss Installations

One recurring problem is the compatibility between tt-rss and different PHP versions, especially when systems already utilize php-legacy due to dependencies like Nextcloud. We acknowledge the challenges highlighted by users facing this predicament, where the browser might download a .php file instead of executing it, indicating a misconfiguration within the web server.

Understanding the Root Cause of Downloaded PHP Files

When a web server serves a PHP file for download instead of executing it, it signifies that the server is not properly configured to process PHP scripts. This typically stems from a missing or incorrect association between .php files and the PHP interpreter (e.g., php-fpm). The web server, in this case, Nginx, needs explicit instructions to pass PHP files to the PHP interpreter for execution.

Nginx Configuration for Proper PHP Processing

The crucial step in resolving this issue lies in configuring Nginx to correctly handle PHP files. A well-defined Nginx configuration block, specifically designed for FastCGI, is paramount. Here’s a breakdown of the necessary directives and considerations:

  • location ~ \.php$ Block: This block targets all files ending with the .php extension.
  • fastcgi_pass unix:/run/php/php7.4-fpm.sock; or fastcgi_pass 127.0.0.1:9000;: This directive specifies the address of the PHP FastCGI Process Manager (PHP-FPM). The address could be a Unix socket (recommended for performance and security) or a TCP socket. Crucially, the version number in the socket path (e.g., php7.4) must match the version of PHP installed on the system. If using php-legacy, ensure the correct socket is pointed to (e.g., check your distribution’s documentation for the php-legacy FPM socket path, it might be /run/php/php5.6-fpm.sock or similar). This socket might need to be installed as a separate package from php itself.
  • fastcgi_index index.php;: Defines the default file to use when a directory is requested (e.g., index.php within the tt-rss installation directory).
  • include fastcgi.conf;: Includes a standard FastCGI configuration file that defines common FastCGI parameters. This file is usually provided by the Nginx distribution and should be present in the Nginx configuration directory.
  • fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;: Sets the SCRIPT_FILENAME parameter, which tells PHP-FPM the full path to the PHP script being executed.
  • fastcgi_param PATH_INFO $fastcgi_path_info;: Allows passing extra path information to the script.
  • fastcgi_split_path_info ^(.+\.php)(/.+)$;: Splits the URI into the script filename and path information.
  • try_files $uri =404;: Checks if the requested URI corresponds to a file or directory and returns a 404 error if not found. This directive prevents unnecessary processing of non-existent files.

Example Nginx Configuration Snippet:

server {
    listen 80;
    server_name your_tt-rss_domain.com;
    root /var/www/tt-rss;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock; # Adjust the socket path if needed
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.ht {
        deny all;
    }

    # Optional: Protect data directory
    location /data {
        deny all;
        return 403;
    }
}

Important Considerations:

  • PHP-FPM Installation and Configuration: Ensure that PHP-FPM is installed and properly configured to listen on the specified socket or port. Verify that the PHP-FPM process is running. Consult your distribution’s documentation for specific instructions on installing and configuring PHP-FPM.
  • User Permissions: The Nginx user (typically www-data or nginx) must have read access to the PHP files and execute permissions within the tt-rss installation directory. This is a frequent cause of “Permission denied” errors.
  • Error Logs: Carefully examine the Nginx error logs (usually located in /var/log/nginx/error.log) and the PHP-FPM error logs for detailed information about any errors encountered during PHP processing. These logs are invaluable for diagnosing issues.
  • Restart Services: After making changes to the Nginx configuration, restart the Nginx service (e.g., sudo systemctl restart nginx). Similarly, restart the PHP-FPM service after modifying its configuration (e.g., sudo systemctl restart php7.4-fpm).
  • Security: Implement proper security measures, such as limiting access to sensitive directories and regularly updating PHP and Nginx.

Addressing Database Connection Issues During tt-rss Installation

During the installation of tt-rss, users often encounter difficulties connecting to the database, especially when using PostgreSQL (pgsql). The error message “a password is missing to access the pgsql database” indicates that the tt-rss installer cannot authenticate with the PostgreSQL server. This can arise due to several factors.

Troubleshooting PostgreSQL Authentication Failures

  1. Incorrect Database Credentials: Verify that the database username, password, and database name specified in the tt-rss configuration file (config.php) are accurate. Double-check for typos and ensure that the credentials match those configured in the PostgreSQL server.

  2. PostgreSQL User Permissions: Ensure that the specified PostgreSQL user has the necessary permissions to access the tt-rss database. The user must have at least the CONNECT and CREATE privileges on the database. You can grant these privileges using the psql command-line tool:

    -- Connect to the PostgreSQL server as the postgres user
    sudo -u postgres psql
    
    -- Grant privileges to the tt-rss user
    GRANT CONNECT ON DATABASE your_tt-rss_database TO your_tt-rss_user;
    GRANT CREATE ON DATABASE your_tt-rss_database TO your_tt-rss_user;
    
    -- Exit psql
    \q
    

    Replace your_tt-rss_database and your_tt-rss_user with the actual database name and username.

  3. pg_hba.conf Configuration: The pg_hba.conf file controls client authentication in PostgreSQL. This file specifies which clients are allowed to connect to the database and what authentication methods are required. Ensure that the pg_hba.conf file is configured to allow connections from the web server to the PostgreSQL server using the appropriate authentication method (e.g., md5, password, trust).

    • Location of pg_hba.conf: The location of the pg_hba.conf file varies depending on the PostgreSQL installation. It is typically located in the /etc/postgresql/<version>/main/ directory, where <version> is the PostgreSQL version number.

    • Example pg_hba.conf Entry:

      # Allow connections from the local machine using md5 authentication
      host    your_tt-rss_database  your_tt-rss_user  127.0.0.1/32  md5
      host    your_tt-rss_database  your_tt-rss_user  ::1/128       md5
      

      This entry allows connections from the local machine (IPv4 and IPv6) to the your_tt-rss_database database as the your_tt-rss_user user using md5 authentication.

    • Restart PostgreSQL: After modifying the pg_hba.conf file, restart the PostgreSQL service for the changes to take effect (e.g., sudo systemctl restart postgresql).

  4. Firewall Rules: Verify that the firewall is not blocking connections between the web server and the PostgreSQL server. Ensure that the firewall allows connections on the PostgreSQL port (default: 5432).

  5. Manual Database Creation: In some cases, the tt-rss installer may not be able to create the database automatically. Try creating the database manually using the psql command-line tool:

    -- Connect to the PostgreSQL server as the postgres user
    sudo -u postgres psql
    
    -- Create the tt-rss database
    CREATE DATABASE your_tt-rss_database WITH OWNER = your_tt-rss_user;
    
    -- Exit psql
    \q
    

    Replace your_tt-rss_database and your_tt-rss_user with the desired database name and username.

Resolving tt-rss Update Daemon Issues: “Permission Denied” Errors

The tt-rss update daemon is responsible for periodically fetching new articles from the configured feeds. A common error encountered during the daemon’s operation is a “Permission denied” error, specifically related to the lock/update.lock file.

Understanding the “Permission Denied” Error

This error indicates that the user running the tt-rss update daemon does not have the necessary permissions to create or modify the update.lock file in the lock/ directory. This file is used to prevent multiple instances of the update daemon from running simultaneously, which could lead to data corruption or other issues.

Troubleshooting Steps for Permission Issues

  1. Identify the User Running the Daemon: Determine which user account the tt-rss update daemon is running under. This can typically be found in the systemd service configuration file for tt-rss (e.g., /etc/systemd/system/tt-rss.service). Look for the User= directive in the [Service] section. If the directive is not present, the daemon is likely running as the default system user (usually root).

  2. Verify Directory Ownership and Permissions: Ensure that the lock/ directory and the update.lock file (if it exists) are owned by the user running the daemon and have the appropriate permissions.

    # Navigate to the tt-rss installation directory
    cd /usr/share/webapps/tt-rss/
    
    # Check the ownership and permissions of the lock/ directory
    ls -l lock/
    
    # Check the ownership and permissions of the update.lock file (if it exists)
    ls -l lock/update.lock
    

    The output should show that the owner of the directory and file is the user running the daemon and that the user has read and write permissions.

  3. Adjust Ownership and Permissions (if necessary): If the ownership or permissions are incorrect, adjust them using the chown and chmod commands.

    # Change the ownership of the lock/ directory and its contents to the correct user
    sudo chown -R your_tt-rss_user:your_tt-rss_group lock/
    
    # Set the permissions of the lock/ directory to allow the owner read, write, and execute permissions
    sudo chmod 775 lock/
    
    # Set the permissions of the update.lock file (if it exists) to allow the owner read and write permissions
    sudo chmod 664 lock/update.lock
    

    Replace your_tt-rss_user and your_tt-rss_group with the actual username and group of the user running the daemon.

  4. Remove Existing Lock Files: As suggested in the original post, removing the update_daemon.lock and update_daemon.stamp files can resolve the issue, especially if they were created during a previous failed installation attempt.

    # Remove the update_daemon.lock and update_daemon.stamp files
    sudo rm lock/update_daemon.lock lock/update_daemon.stamp
    
  5. Systemd Service Configuration: If the daemon is managed by systemd, ensure that the User= and Group= directives in the service file are correctly set to the appropriate user and group. After making changes to the service file, reload the systemd configuration and restart the tt-rss service.

    # Reload the systemd configuration
    sudo systemctl daemon-reload
    
    # Restart the tt-rss service
    sudo systemctl restart tt-rss
    
  6. SELinux/AppArmor: If SELinux or AppArmor is enabled on the system, these security modules may be interfering with the daemon’s ability to access the lock/ directory. Check the SELinux/AppArmor logs for any denied operations related to tt-rss and adjust the policies accordingly. This often involves creating custom SELinux/AppArmor policies to grant the daemon the necessary permissions. This step is advanced and requires a good understanding of SELinux/AppArmor.

The automatic installation process of tt-rss can sometimes fail due to various configuration issues. In such cases, the manual installation method provides greater control and visibility over the setup process.

Steps for Manual Installation

  1. Download and Extract tt-rss: Download the latest version of tt-rss from the official website or GitHub repository. Extract the archive to the desired installation directory (e.g., /var/www/tt-rss).

  2. Create the Configuration File: Copy the config.php-dist file to config.php and edit it to configure the database connection, website URL, and other settings.

    # Navigate to the tt-rss installation directory
    cd /var/www/tt-rss/
    
    # Copy the config.php-dist file to config.php
    cp config.php-dist config.php
    
    # Edit the config.php file
    nano config.php
    

    Pay close attention to the database settings:

    • DB_TYPE: Set to 'pgsql' for PostgreSQL.
    • DB_HOST: The hostname or IP address of the PostgreSQL server.
    • DB_NAME: The name of the tt-rss database.
    • DB_USER: The PostgreSQL username.
    • DB_PASS: The PostgreSQL password.
    • DB_PORT: The port number of the PostgreSQL server (default: 5432).

    Also, configure the following settings:

    • SELF_URL_PATH: The URL of your tt-rss installation (e.g., https://your_tt-rss_domain.com).
    • SINGLE_USER_MODE: Set to true if you want to use tt-rss in single-user mode.
    • SIMPLE_UPDATE_MODE: Set to true to use the simplified update method.
  3. Initialize the Database: After configuring the config.php file, initialize the database using the schema.sql file located in the tt-rss installation directory.

    # Connect to the PostgreSQL server as the tt-rss user
    psql -U your_tt-rss_user -d your_tt-rss_database
    
    # Execute the schema.sql file
    \i schema.sql
    
    # Exit psql
    \q
    

    Replace your_tt-rss_user and your_tt-rss_database with the actual username and database name.

  4. Configure Web Server: Configure your web server (e.g., Nginx) to serve the tt-rss files. Refer to the Nginx configuration example provided earlier in this guide.

  5. Set File Permissions: Ensure that the web server user has the necessary permissions to access the tt-rss files and directories.

  6. Access tt-rss in Your Browser: Open your web browser and navigate to the URL of your tt-rss installation. You should be able to log in with the default username (admin) and password (password). Remember to change the default password immediately after logging in.

By meticulously following these steps and adapting them to your specific environment, you can overcome common installation hurdles and enjoy the benefits of self-hosted RSS aggregation with Tiny Tiny RSS. We encourage contributions to the community knowledge base to further refine and expand upon these troubleshooting techniques.