Operating System CentOS

How to Install Revive Adserver 6 on AlmaLinux 9 or Rocky Linux 9

Install Revive Adserver 6 on AlmaLinux 9 or Rocky Linux 9 with Apache, PHP-FPM and MySQL, run the web installer, secure the files and add the maintenance cron job.

Revive Adserver is a free, open-source ad server for managing and tracking banners on websites, in apps and in video players. This guide installs the current 6.0 series on AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9 with Apache, PHP-FPM and MySQL, then secures the installation and schedules its hourly maintenance job. CentOS 7 reached end of life in June 2024 and its PHP 5.4 cannot run any current Revive release, so use one of the RHEL 9 rebuilds instead.

Requirements

  • A server running AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9, and a user with sudo rights.
  • A host name pointing at the server, for example ads.example.com. Revive needs HTTPS with a valid certificate for its cookie-based features such as frequency capping and conversion tracking.
  • PHP 8.1 or later for Revive Adserver 6.0, with the intl, mbstring, mysqli (or pgsql), xml, zip and zlib extensions. curl, gd, opcache and openssl are recommended.
  • MySQL or PostgreSQL. This guide uses the MySQL 8.0 packages shipped with the distribution.

Step 1: Install Apache, PHP and MySQL

Update the system first:

sudo dnf update -y

The default PHP in RHEL 9 is 8.0, which is too old. Switch to the PHP 8.3 module stream and install PHP with the extensions Revive needs:

sudo dnf module reset php -y
sudo dnf module enable php:8.3 -y
sudo dnf install -y httpd php php-mysqlnd php-intl php-mbstring php-xml php-pecl-zip php-gd php-opcache

If dnf module list php does not offer 8.3 on your system, enable php:8.2 instead; both meet the requirement.

Install MySQL and start all three services. On RHEL 9, Apache runs PHP through PHP-FPM, so that service must be running too:

sudo dnf install -y mysql-server
sudo systemctl enable --now mysqld php-fpm httpd

Run the hardening script to set a root password policy and remove the test database:

sudo mysql_secure_installation

Step 2: Create the database

Revive wants a dedicated database and a user with all privileges on it; the installer refuses to continue otherwise. Open the MySQL shell:

sudo mysql

Create the database and user. Replace the password with a long random one:

CREATE DATABASE revive;
CREATE USER 'revive'@'localhost' IDENTIFIED BY 'replace-with-a-long-random-password';
GRANT ALL PRIVILEGES ON revive.* TO 'revive'@'localhost';
EXIT;

Step 3: Download Revive Adserver

Check the official download page for the current version number; at the time of writing it is 6.0.9. Download the archive and compare its SHA-256 hash with the one published on that page:

cd /tmp
curl -O https://download.revive-adserver.com/revive-adserver-6.0.9.tar.gz
sha256sum revive-adserver-6.0.9.tar.gz

Unpack it into a directory without a version number in its name, so later upgrades can reuse the same path:

sudo mkdir /var/www/revive
sudo tar -xzf revive-adserver-6.0.9.tar.gz -C /var/www/revive --strip-components=1

Step 4: Set permissions and SELinux contexts

The web server must be able to read everything, but it only needs write access to a handful of directories: var (including var/cache, var/plugins and var/templates_compiled), plugins, www/admin/plugins and www/images. Keep everything else owned by root:

cd /var/www/revive
sudo chown -R root:root .
sudo chown -R apache:apache var plugins www/admin/plugins www/images

SELinux is enforcing by default and blocks Apache from writing below /var/www regardless of file ownership. Label the same four directories as writable web content:

sudo dnf install -y policycoreutils-python-utils
for d in var plugins www/admin/plugins www/images; do
  sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/revive/$d(/.*)?"
done
sudo restorecon -R /var/www/revive

Step 5: Configure the Apache virtual host

Create /etc/httpd/conf.d/revive.conf:

sudo vi /etc/httpd/conf.d/revive.conf

Add the following. The DirectoryMatch block is the rule Revive recommends to keep library, configuration and cache folders unreachable from a browser; only the root and www/ stay public. The last block stops uploaded files in the banner folder from being executed as PHP.

<VirtualHost *:80>
    ServerName ads.example.com
    DocumentRoot /var/www/revive

    <Directory /var/www/revive>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    <DirectoryMatch "^/var/www/revive/(?!$|www/)">
        Require all denied
    </DirectoryMatch>

    <Directory /var/www/revive/www/images>
        <FilesMatch "\.php$">
            Require all denied
        </FilesMatch>
    </Directory>

    ErrorLog /var/log/httpd/revive-error_log
    CustomLog /var/log/httpd/revive-access_log combined
</VirtualHost>

Test the configuration, reload Apache and open the firewall:

sudo apachectl configtest
sudo systemctl reload httpd
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload

Add a TLS certificate before you start serving ads, for example with Certbot and Let's Encrypt. Decide on the final URL (HTTP or HTTPS) before running the installer, because delivery URLs are stored in the configuration.

Step 6: Run the web installer

Open https://ads.example.com/ in a browser and follow the wizard:

  1. Welcome: accept the licence.
  2. System check: the wizard checks PHP and the folder permissions. If something fails it lists the exact folders to fix; change only those and click Retry.
  3. Database: enter the database name revive, the user, its password and the host localhost. Leave the advanced fields at their defaults.
  4. Administrator: choose a user name, email address, password, language and time zone. Do not use admin or your email address as the user name, and do not reuse the database password.

The wizard then installs the bundled plugins, which can take a few minutes, and confirms that installation is complete.

Step 7: Lock the configuration and schedule maintenance

The installer writes its settings to files ending in conf.php inside var. Make them read-only for the web server once the setup is finished:

sudo chown root:root /var/www/revive/var/*.conf.php
sudo chmod 644 /var/www/revive/var/*.conf.php

If you later need to change global settings in the admin interface, temporarily give the file back to the apache user and lock it again afterwards.

Revive summarises statistics, activates and deactivates campaigns and recalculates delivery priorities in an hourly maintenance run. It can trigger that run from ad requests, but a scheduled job is more reliable. Edit the crontab of the apache user:

sudo crontab -u apache -e

Add one line. The last argument is the host name of the ad server itself, not of the sites that show the ads:

1 * * * * /usr/bin/php /var/www/revive/scripts/maintenance/maintenance.php ads.example.com

After the first full hour, log in as administrator and check the maintenance status under the Configuration menu.

Troubleshooting

  • The system check keeps reporting unwritable folders: the SELinux label is usually missing. Run ls -Zd /var/www/revive/var; it should show httpd_sys_rw_content_t.
  • Blank page or 503: check that PHP-FPM is running with systemctl status php-fpm and read /var/log/httpd/revive-error_log.
  • "Called via the command line, but had no host as a parameter": the cron line is missing the host name argument.

Frequently asked questions

Can I use MariaDB or PostgreSQL instead of MySQL?

PostgreSQL is officially supported; install the php-pgsql package instead of php-mysqlnd. The project's requirements page names MySQL and PostgreSQL only and does not mention MariaDB, so MySQL is the safer choice on a new server.

How do I upgrade to a newer Revive Adserver release?

Back up the database and the installation directory, then follow the upgrade instructions on the project's website for your version. Upgrades are published often and many of them fix security issues, so subscribe to the project's release announcements.

Why does the folder name have no version number?

Ad zones on your websites embed the ad server's URL. Keeping the path stable means invocation codes keep working after every upgrade.

Do I need Nginx rules as well?

Only if you serve Revive with Nginx instead of Apache. In that case the project recommends a location block that returns 403 for every path outside www/; see its installation and security articles.

Share story:

Continue reading other guides on How VPS.