How to Install Zoneminder on Arch Linux

Zoneminder is an open-source video camera security application that supports multiple cameras, motion detection, and events triggered based on such detections. It's commonly used in home security systems, office security, etc. In this tutorial, we will learn how to install Zoneminder on Arch Linux.

Requirements

Before we begin, make sure that you have the following:

Step 1: Update System

Start by updating your Arch Linux system to the latest version.

sudo pacman -Syu

Step 2: Install Dependencies

Zoneminder requires a variety of dependencies to function correctly. Run the following command to install them:

sudo pacman -S apache mariadb php php-apache php-gd php-mysql php-intl ffmpeg libevent

Step 3: Configure the Web Server

Zoneminder requires a web server to run. In this tutorial, we will use Apache, a popular open-source web server.

To install Apache, run the following command:

sudo pacman -S apache

After installing Apache, enable and start it using the following command:

sudo systemctl enable httpd.service
sudo systemctl start httpd.service

Step 4: Install Zoneminder

There are two ways to install Zoneminder on Arch Linux. One is to install from the Arch User Repository (AUR), and the other is to compile from source.

A. Install from AUR

To install Zoneminder from AUR, you will need to install an AUR helper. Yay is a popular AUR helper for Arch Linux, so we will use it in our installation.

First, install Yay:

sudo pacman -S yay

Then, run the following command to install Zoneminder:

yay -S zoneminder

B. Compile from Source

To compile Zoneminder from source, you will need to download the source code from the official Zoneminder website. To download, use the following command:

wget https://github.com/ZoneMinder/zoneminder/archive/1.35.17.tar.gz

Then, extract the source code:

tar -xvf 1.35.17.tar.gz

Next, install the dependencies:

sudo pacman -S gcc make cmake pkg-config git

Navigate to the zoneminder-1.35.17 directory and run the following commands:

mkdir build
cd build
cmake ..
make
sudo make install

Step 5: Configure Zoneminder

After installation, you need to configure Zoneminder to start correctly.

Navigate to the Apache configuration directory:

cd /etc/httpd/conf

Edit the httpd.conf file using your favorite text editor:

sudo nano httpd.conf

Append the following lines at the end of the file:

LoadModule cgi_module modules/mod_cgi.so
LoadModule rewrite_module modules/mod_rewrite.so

<Directory "/usr/share/zoneminder/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Save and exit the file.

Initialize the database and start the MariaDB service using the following commands:

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service

Then, create a new database, user, and grant permissions using the following commands:

sudo mysql -u root
CREATE DATABASE zm;
CREATE USER 'zmuser'@'localhost' IDENTIFIED BY 'zmpass';
GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost';
FLUSH PRIVILEGES;
exit

Next, configure Zoneminder using the following command:

sudo cp /usr/share/zoneminder/conf/zm.conf.example /etc/zm.conf

Edit the zm.conf file:

sudo nano /etc/zm.conf

Find the following lines:

ZM_DB_USER=zmuser
ZM_DB_PASS=zmpass

And replace them with:

ZM_DB_USER=<your_database_username>
ZM_DB_PASS=<your_database_password>

Save and exit the file.

Change the ownership of the /etc/zm.conf file to www-data user and group:

sudo chown www-data:www-data /etc/zm.conf

Restart the Apache web server using the following command:

sudo systemctl restart httpd.service

Step 6: Access Zoneminder

After configuring Zoneminder, you can access it using a web browser. Open your web browser and navigate to http://localhost/zm/.

The default username and password are admin and admin respectively. After logging in, you can add cameras, configure motion detection, and set up alerts to receive notifications.

Congratulations! You have successfully installed Zoneminder on Arch Linux.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!