Tag Archives: Debian

How to Install AWStats with Apache on Debian 12

AWStats (Advanced Web Statistics) is an open-source web analytics tool that analyzes and generates comprehensive reports about web server log files. It provides detailed information about various aspects of web traffic and visitor behavior on a website.

It’s important to note that AWStats relies on server log files, so it may not provide real-time data and requires proper configuration to work effectively.

In this tutorial, we will show you how to install AWStats on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to the latest version with the following command:

# apt update && apt upgrade

Step 2: Install Apache webserver

You can install it via apt package manager by executing the following command.

# apt install apache2

Verify the status of the Apache service using systemctl status command:

# systemctl status apache2

Output:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 928 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 933 (apache2)
      Tasks: 56 (limit: 2273)
     Memory: 11.2M
        CPU: 1.891s
     CGroup: /system.slice/apache2.service
             ├─933 /usr/sbin/apache2 -k start
             ├─934 /usr/sbin/apache2 -k start
             ├─935 /usr/sbin/apache2 -k start
             └─936 /usr/sbin/apache2 -k start

Step 3: Install AWStats

To install AWStats, you need to run the following command:

# apt install awstats

This command will start the installation process. It will resolve dependencies, run a transaction check, and install the necessary packages.

To get GeoIP information install the following Perl packages:

# apt install libgeo-ip-perl libgeo-ipfree-perl

Step 4: Configure AWStats

Once the installation routine is completed, edit the file awstats.conf as follows:

LogFile="/var/log/apache2/access.log"
LogFormat=1
SiteDomain="your-domain.com"
HostAliases=”www.your-domain.com your-domain.com”
DNSLookup=0
AllowFullYearView=3
LoadPlugin="tooltips"

Step 5: Configure Apache for AWStats

Open the Apache configuration file /etc/apache2/conf-available/awstats.conf :

# nano /etc/apache2/conf-available/awstats.conf

Paste the content as shown below:

Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Save and exit the configuration file.

To enable this conf run the command:

# ln -s /etc/apache2/conf-available/awstats.conf /etc/apache2/conf-enabled/awstats.conf

Then enable the "cgi" module in Apache:

# /usr/sbin/a2enmod cgi

To implement the changes, restart Apache webserver:

# systemctl restart apache2

To implement the changes, restart Apache webserver:

# systemctl restart apache2

You can see how the installation is progressing by pointing your web browser to:

# http://your-domain.com/cgi-bin/awstats.pl

The top line displays the time when statistics were updated. It probably reads ‘Never updated’. It is all right, you just have to manually run the first update.

# /usr/lib/cgi-bin/awstats.pl -config=your-domain.com -update

After it is done, if it is successful, with no errors, you should get some output like:

Create/Update database for config "/etc/awstats/awstats.conf" by AWStats version 7.8 (build 20200416)
From data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 4258
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 4258 new qualified records.

Step 6: Secure Your AWStats via .htaccess

A basic, simple way of restricting access is to set up a http password. Open your apache2 configuration file

# nano /etc/apache2/sites-available/your-domain.com.conf

Paste the content as shown below:

<Directory /usr/lib/cgi-bin/>
    Options +ExecCGI
    AddHandler cgi-script .cgi
    AuthType Basic
    AuthName 'Password Protected Area'
    AuthUserFile '/usr/lib/cgi-bin/.htpasswd'
    Require valid-user
</Directory>

If you don’t  have a password that can be used for this purpose, the command htpasswd can do it for you.

# htpasswd -cb /usr/lib/cgi-bin/.htpasswd admin Str0ngPassw0rd

Comments and Conclusion

Congratulations! You have successfully installed AWStats with Apache on your Debian 12 OS.

For additional help or useful information, we recommend you to check  the official AWStats documentation.

How to Install Strapi with Nginx on Debian 12

Strapi is a most advanced open source content management system (CMS) designed to help developers to build powerful API.

Strapi follows a “headless” architecture, which means it separates the content management backend from the frontend presentation, giving developers the freedom to use various technologies and frameworks on the frontend.

In this tutorial, we will show you how to install Strapi on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Step 2: Install Nginx webserver

You can install Nginx via apt package manager by executing the following command.

# apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

# systemctl start nginx
# systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

# systemctl status nginx

Output:

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
    Process: 627 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 646 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 655 (nginx)
      Tasks: 2 (limit: 2273)
     Memory: 3.8M
        CPU: 27ms
     CGroup: /system.slice/nginx.service
             ├─655 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─656 "nginx: worker process"

Step 3: Install Node.js

Strapi is based on Node.js, for that reason, you need to have Node.js installed on your server.

To install Node.js and npm on your Debian OS use the following command:

# apt install nodejs npm

You can verify the Node.js version with the following command:

# node --version

You should see the following output:

v18.13.0

Also, verify the npm version with the following command:

# npm --version

You should get the following output:

9.2.0

Step 4: Install PostgreSQL

Strapi uses PostgreSQL as a database backend, so you will need to install PostgreSQL on your server.

You can run the following command to install the PostgreSQL server:

# apt-get install postgresql-15

After the successful installation, start the PostgreSQL service and enable it to start after the system reboot:

# systemctl start postgresql
# systemctl enable postgresql

Verify that is active and running on your server:

# systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited)
   Main PID: 13153 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Next, connect to the PostgreSQL shell:

# su postgres
# psql

Then, we create the Strapi database:

postgres=# CREATE DATABASE strapidb; 
postgres=# CREATE USER strapi WITH PASSWORD 'Your-Strong-Password'; 
postgres=# GRANT ALL PRIVILEGES ON DATABASE strapidb to strapi; 
postgres=# \q

Return to your root user account.

# exit

Step 5: Create a Strapi Application

Once PostgreSQL and Node.js have been installed, we can proceed to install Strapi.

You can use the npx command line utility to easily create a Strapi app.

# cd /opt
# npx create-strapi-app@latest strapi --no-run

You will see the following output.

Need to install the following packages:
  create-strapi-app@4.12.1
Ok to proceed? (y) y

Proceed with the creation by pressing y.

In the interactive shell, select custom installation then your database client, database name and user name as provisioned.

? Choose your installation type Custom (manual settings)
? Choose your preferred language JavaScript
? Choose your default database client postgres
? Database name: strapidb
? Host: 127.0.0.1
? Port: 5432
? Username: strapi
? Password: ********************
? Enable SSL connection: No

Next, navigate to the strapi directory and build the application with the following command.

# cd strapi
# npm run build

Output:

> strapi@0.1.0 build
> strapi build

Building your admin UI with development configuration...

✔ Webpack
  Compiled successfully in 1.12m

Admin UI built successfully

Then run Strapi in development mode.

# npm run develop

If everything is fine, you will get the following output.


Press the CTRL+C to stop the application.

Step 6: Run Strapi with PM2

In this step we will describe you to how to run Strapi app with PM2 command. PM2 is a Production Process Manager for Node.js applications.

First, install PM2 application by running the following command:

# npm install pm2@latest -g

Now create a pm2 ecosystem file which is where you can setup some environment variables for each pm2 app you want to install and run.

# nano /root/ecosystem.config.js

Paste the following content in the file.

module.exports = {
  apps: [
    {
      name: 'strapi',
      cwd: '/opt/strapi',
      script: 'npm',
      args: 'start',
      env: {
        NODE_ENV: 'production',
        DATABASE_HOST: 'localhost',
        DATABASE_PORT: '5432',
        DATABASE_NAME: 'strapidb',
        DATABASE_USERNAME: 'strapi',
        DATABASE_PASSWORD: 'Your-Strong-Password'
      },
    },
  ]
};

Note: /opt/strapi is the path to your project, you are required to replace this with your own path before you proceed.

Once modified, save the file then start the app in the background with the command:

# pm2 start /root/ecosystem.config.js

You can see that the status of the app is set to online.

# pm2 list

To allow the app to start automatically on boot, use the command:

# pm2 startup -u root

Save the process:

# pm2 save

Your Strapi service is now running in the background in production mode.

Step 7: Configure Nginx for Strapi

Create a new Nginx virtual host configuration file.

# nano /etc/nginx/conf.d/strapi.conf

Add the following configurations:

upstream strapi {
server 127.0.0.1:1337;
}

server {

listen 80;
server_name your-domain.com www.your-domain.com;

location / {
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
      }
}

Save and close the file, then edit the Nginx main configuration file.

# nano /etc/nginx/nginx.conf

Add the following line after the line http{: but before the line include /etc/nginx/conf.d/*.conf;.

server_names_hash_bucket_size 64;

Save the file, then verify the Nginx configuration.

# /usr/sbin/nginx -t

You should see the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart the Nginx service to implement the changes.

# systemctl restart nginx

Step 8: Access Strapi Web Interface

Now, open your web browser and access the Strapi web UI using the URL http://your-domain.com/admin. You should see the Strapi default page:

Then click on the Let’s start button. You should see the Strapi dashboard:

Comments and Conclusion

Congratulations. You have learned how to install Strapi on Debian 12 OS. You can now create your own application easily using Strapi.

For additional help or useful information, we recommend you to check  the official Strapi documentation.

How to Install GlassFish on Debian 12

Glassfish is a free, open-source Java application server that simplifies the process of deploying Java applications to a scalable platform. Originally developed by Sun Microsystems, GlassFish is now maintained by Oracle and is released under both the Common Development and Distribution License as well as the GPL.

In this tutorial, we will show you the complete steps to install GlassFish on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Step 2: Install Java (OpenJDK) on Debian 12

Java packages are available on Debian 12 repositories and you can install it with the following command:

# apt install default-jdk

Check Java version after installation:

# java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb12u1, mixed mode, sharing)

Step 3: Download GlassFish

Check the official GlassFish Download page to locate the latest version of the software.

The latest version at the moment is 7.0.6. You can download it with the following command:

# wget https://download.eclipse.org/ee4j/glassfish/glassfish-7.0.6.zip

Once that downloads, unpack it into /opt with:

# unzip glassfish-7.0.6.zip -d /opt

Step 4: Create a systemd file for GlassFish

You need to create a systemd file so you can control the GlassFish service. Create the file with the following command:

# nano /usr/lib/systemd/system/glassfish.service

In that file, paste the following content:

[Unit]
Description = GlassFish Server v7.0.6
After = syslog.target network.target

[Service]
User = root
ExecStart = /usr/bin/java -jar /opt/glassfish7/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /opt/glassfish7/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /opt/glassfish7/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

[Install]
WantedBy = multi-user.target

Reload system daemon and start the service:

# systemctl daemon-reload
# systemctl start glassfish
# systemctl enable glassfish

To confirm everything is working normally, check the status of service:

# systemctl status glassfish

Output:

● glassfish.service - GlassFish Server v7.0.6
     Loaded: loaded (/lib/systemd/system/glassfish.service; enabled; preset: enabled)
     Active: active (running)
    Process: 1355 ExecStart=/usr/bin/java -jar /opt/glassfish7/glassfish/lib/client/appserver-cli.jar start-domain (code=exited, status=0/SUCCESS)
   Main PID: 1370 (java)
      Tasks: 89 (limit: 2273)
     Memory: 314.9M
        CPU: 22.599s
     CGroup: /system.slice/glassfish.service

Step 5: Access GlassFish console on web browser

To test your installation, open your web browser and type https://your-IP-address:8080. You will see the default GlassFish page.

Step 6: Configure GlassFish

With GlassFish installed, you now must configure it with an admin password. The default password is blank, so you’ll want to create one with the command:

# /opt/glassfish7/bin/asadmin --port 4848 change-admin-password

When you run this command, you will be prompted to supply the admin password and details as shown below.

Enter admin user name [default: admin]> admin
Enter the admin password> )> Just press the Enter key
Enter the new admin password> 
Enter the new admin password again>

Once that’s taken care of, to access the administration panel remotely, run the following command.

# /opt/glassfish7/bin/asadmin --port 4848 enable-secure-admin
Enter admin user name> admin
Enter admin password for user " admin" >  
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

After setting the administrative panel, restart the domain.

# /opt/glassfish7/bin/asadmin --port 4848 restart-domain

You can now access the GlassFish admin panel at http://your-IP-address:4848.

Provide your admin username and password and click on Login. You should see the GlassFish dashboard:

Comments and Conclusion

That’s it! You have now installed and started GlassFish on your Debian system. Remember that this guide assumes you have administrative privileges on your system. Always check the official GlassFish documentation for the most up-to-date installation instructions and any specific considerations related to your system configuration.

How to Install WordPress on Debian 12

WordPress is a popular content management system (CMS) used for creating and managing websites. It is an open-source platform written in PHP and paired with a MySQL or MariaDB database. WordPress provides a user-friendly interface and a wide range of themes, plugins, and customization options, making it accessible to users with varying levels of technical expertise.

In this tutorial we’ll show you how to install WordPress on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Also, install necessary packages:

# apt install nano wget unzip

Step 2: Install Nginx web server on Debian 12

To install Nginx, run the following command:

# apt install nginx

You can start the Nginx service and configure it to run on startup by entering the following commands:

# systemctl start nginx
# systemctl enable nginx

Verify the status of the Nginx service using systemctl status command:

# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
    Process: 674 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 873 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 875 (nginx)
      Tasks: 2 (limit: 2273)
     Memory: 4.5M
        CPU: 402ms
     CGroup: /system.slice/nginx.service
             ├─875 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─876 "nginx: worker process"

Step 3: Install PHP and PHP extensions for WordPress

You can install PHP and other supporting packages using the following command:

# apt install php php-curl php-fpm php-bcmath php-gd php-soap php-zip php-curl php-mbstring php-mysqlnd php-gd php-xml php-intl php-zip

Verify if PHP is installed.

php -v

Output:

PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

After installing all the packages, edit the php.ini file:

# nano /etc/php/8.2/fpm/php.ini

Change the following settings per your requirements:

max_execution_time = 300
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M

To implement the changes, restart the php-fpm service:

# systemctl restart php8.2-fpm

Step 4: Install MariaDB Database Server

You can install MariaDB with the following command:

# apt install mariadb-server mariadb-client

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

# systemctl start mariadb
# systemctl enable mariadb

Verify the status of the MariaDB service using systemctl status command:

# systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.11.3 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 959 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 2273)
     Memory: 256.5M
        CPU: 6.621s
     CGroup: /system.slice/mariadb.service
             └─959 /usr/sbin/mariadbd

Once the database server is installed, run the following command to secure your MariaDB server:

# mysql_secure_installation

You will then be asked several configuration questions, which you must answer Y to each of them.

Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

Restart the database server for the changes to take effect.

# systemctl restart mariadb

Step 5: Create a New Database for WordPress

To do this, log in to your MariaDB server using the following command:

# mysql -u root -p

Run the following commands to create a new database and user:

MariaDB [(none)]> CREATE DATABASE wordpress_db;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Note: Make sure to replace 'password' with a strong password of your choice.

Step 6: Download WordPress

We will now download the latest version of WordPress from the WordPress Official site.

Use the following command to download WordPress:

# wget https://wordpress.org/latest.zip

Extract file into the folder /var/www/html/ with the following command,

# unzip latest.zip -d /var/www/html/

Next, navigate to the  /var/www/html/wordpress/ directory:

# cd /var/www/html/wordpress

WordPress comes with a configuration sample file. Make a copy of this file:

# cp wp-config-sample.php wp-config.php

Next, edit the WordPress configuration file and define your database settings:

# nano wp-config.php

Change the following lines that match your database settings:

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_db' );

/** MySQL database username */
define( 'DB_USER', 'wordpress_user' );

/** MySQL database password */
define( 'DB_PASSWORD', 'password' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

Save the file when you are finished.

Change the permission of the website directory:

# chown -R www-data:www-data /var/www/html/wordpress/

Step 7: Configure Nginx Web Server for WordPress

Navigate to /etc/nginx/conf.d directory and run the following command to create a configuration file for your installation:

# nano /etc/nginx/conf.d/wordpress.conf

Add the following content:

server {
  listen 80;

    server_name  your-domain.com www.your-domain.com;
    root   /var/www/html/wordpress;
    index  index.php;

    access_log /var/log/nginx/your-domain.com.access.log;
    error_log /var/log/nginx/your-domain.com.error.log;

    client_max_body_size 100M;

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

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
         include fastcgi_params;
         fastcgi_intercept_errors on;
    }
}

Save the file and Exit.

Restart the Nginx web server.

# systemctl restart nginx

Step 8: Access WordPress Web Installer

Open your browser type your domain e.g http://your-domain.com You will be redirected to the language selection screen:

Select your language and click on the Continue button.

Provide the requested information and click on the Install WordPress button. Once the installation has been finished. You should see the following screen:

Click on the Log in button. You should see the WordPress login screen:

Enter your administrator user, password and click on the Log In button. You will get the dashboard in the following screen:

Comments and Conclusion

That’s it. You have successfully installed WordPress CMS (Content Management System) on Debian 12 OS.

For additional help or useful information, we recommend you to check the official WordPress documentation.

If you have any questions please leave a comment below.

How to Install Elgg on Debian 12

Elgg is an open-source social networking platform that allows users to create and manage their own social networks and communities.

It provides a flexible architecture that allows developers to extend and customize its functionality according to their specific needs. Elgg also supports the creation of plugins and themes, enabling further customization and integration with other systems.

In this tutorial, we will show you how to install Elgg on Debian 12 OS.

Step 1: Update Operating System

Update your Debian 12 operating system to the latest version with the following command:

# apt update && apt upgrade

Step 2: Install Apache webserver

You can install it via apt package manager by executing the following command.

# apt install apache2

Verify the status of the Apache service using systemctl status command:

# systemctl status apache2

Output:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 3682 (apache2)
      Tasks: 55 (limit: 2273)
     Memory: 8.6M
        CPU: 32ms
     CGroup: /system.slice/apache2.service
             ├─3682 /usr/sbin/apache2 -k start
             ├─3684 /usr/sbin/apache2 -k start
             └─3685 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions for Elgg

To install PHP and additional PHP modules to support Elgg, run the following command:

# apt install php php-cli php-common libapache2-mod-php php-curl php-zip php-gd php-mysql php-xml php-mbstring php-xmlrpc php-intl

Verify if PHP is installed.

php -v
Output:
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

After installing all the packages, edit the php.ini file:

# nano /etc/php/8.2/apache2/php.ini

Change the following settings per your requirements:

max_execution_time = 300
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = America/Chicago

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

Verify the status of the MariaDB service using systemctl status command:

# systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.11.3 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 16734 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 2273)
     Memory: 203.0M
        CPU: 464ms
     CGroup: /system.slice/mariadb.service
             └─16734 /usr/sbin/mariadbd

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.

# mysql_secure_installation

Configure it like this:

- Enter current password for root (enter for none): Enter
- Switch to unix_socket authentication [Y/n] Y
- Change the root password? [Y/n] Y
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] Y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y

Now run the command below to log in to the MariaDB shell.

# mysql -u root -p

Once you are logged in to your database server you need to create a database for the Elgg installation:

MariaDB [(none)]> CREATE DATABASE elgg;
MariaDB [(none)]> CREATE USER 'elgg'@'localhost' IDENTIFIED BY 'Str0ngPass2F';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON elgg. * TO 'elgg'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 5: Download Elgg

The latest version of Elgg is available to download from the official website. As of writing this tutorial, the latest version available is 5.0.1.

# wget https://elgg.org/download/elgg-5.0.1.zip

Then extract file into the folder /var/www/ with the following command:

# unzip elgg-5.0.1.zip -d /var/www/

Rename the extracted directory:

# mv /var/www/elgg-5.0.1 /var/www/elgg/

Create a data directory:

# mkdir /var/www/data/

Then enable permission for the Apache webserver user to access the files:

# chown -R www-data:www-data /var/www/data/
# chown -R www-data:www-data /var/www/elgg/

Step 6: Configure Apache for Elgg

Run the commands below to create a new VirtualHost file called elgg in the /etc/apache2/sites-available/ directory.

# nano /etc/apache2/sites-available/elgg.conf

Paste the content as shown below:

 <VirtualHost *:80>
    ServerAdmin admin@your-domain.com
    DocumentRoot /var/www/elgg/
    
    ServerName your-domain.com
    ServerAlias www.your-domain.com

    <Directory /var/www/elgg/> 
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory> 

    ErrorLog /var/log/apache2/your-domain.com-error_log
    CustomLog /var/log/apache2/your-domain.com-access_log common

 </VirtualHost>

Remember to replace your-domain.com with the domain name of your server.

Save and exit the configuration file.

Then enable the "rewrite" module in Apache:

# a2enmod rewrite

To enable this site run the command:

# ln -s /etc/apache2/sites-available/elgg.conf /etc/apache2/sites-enabled/elgg.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Install free Let’s Encrypt SSL certificate

First we need to install the Certbot client which is used to create Let’s Encrypt certificates:

# apt install certbot python3-certbot-apache

To get the SSL certificate using the Certbot, type the command given below:

# certbot --apache -d your-domain.com -d www.your-domain.com

If the SSL certificate is successfully obtained, certbot displays a message to show the configuration was successful:

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain.com.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-09-02. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Now, you have successfully installed SSL on your website.

Step 8: Access Elgg Web Interface

Open your web browser and type the URL https://your-domain.com. You should see the following page:

Click on the Next button.

The installer will then check the requirements. Once all checks are passed, click on the Next button.

After that, you will have to write the credentials from the database, data directory, and site URL and then click on the Next button:

Then, you have to set up your site name and email and then click on the Next button:

Provide your admin username, password, email and click on the Next button. Once the installation has been completed, you should see the following page:

Click on the Go to site button you should see your administration panel:

Comments and Conclusion

Congratulations! You have successfully installed Elgg. Thanks for using this tutorial for installing Elgg on your Debian 12 OS.

For additional help or useful information, we recommend you to check  the official Elgg documentation.

How to Install Elasticsearch 8 on Debian 11

Elasticsearch is a highly scalable and distributed open-source full-text search and analytics engine tool. It is designed to store, search, and analyze large volumes of data in real-time, making it a popular tool for a variety of use cases such as log analytics, e-commerce product search, and security analytics.

Elasticsearch uses a document-oriented data model, which means that it stores data in JSON documents that can be easily searched and analyzed. It also provides a powerful query language called Elasticsearch Query DSL, which allows users to perform complex queries on the data stored in the engine.

In this tutorial, we will show you how to install Elasticsearch on Debian 11.

Step 1: Update Operating System

Update your Debian 11 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Also, install:

# apt install curl wget gnupg apt-transport-https

Step 2: Add Elasticsearch Repository

By default, Elasticsearch is not included in the Debian 11 default repository. So you will need to add the Elasticsearch repository to APT.

First, import the Elasticsearch GPG key.

# wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

Then add the Elasticsearch repository.

# echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list

Once you are done, update the repository with the following command:

# apt update

Step 3: Install and Configure Elasticsearch

Now, you can install the Elasticsearch using the following command:

# apt install elasticsearch

After installation is completed, edit Elasticsearch configuration file “/etc/elasticsearch/elasticsearch.yml”:

# nano /etc/elasticsearch/elasticsearch.yml

Add the following content:

cluster.name: LinuxTuto
node.name: Debian 11
path.data: /var/lib/elasticsearch
network.host: 127.0.0.1 
xpack.security.enabled: false

Then start and enable the service.

# systemctl start elasticsearch
# systemctl enable elasticsearch

To confirm the status of the service of Elasticsearch, run the command:

$ sudo systemctl status elasticsearch.service
 elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: active (running)
Docs: https://www.elastic.co
Main PID: 73979 (java)
Tasks: 100 (limit: 2301)
Memory: 1.3G
CPU: 53.939s
CGroup: /system.slice/elasticsearch.service
├─73979 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/elasticsearch/bin/elast>
├─74040 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manage>
└─74063 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Step 4: Test Elasticsearch

To verify that Elasticsearch is running correctly, you can use the curl command:

# curl -X GET "localhost:9200/"

If Elasticsearch is working properly, the result should be like this:

{
  "name" : "Debian 11",
  "cluster_name" : "LinuxTuto",
  "cluster_uuid" : "ezWPhn_fQLS5dcSiexroQA",
  "version" : {
    "number" : "8.7.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "09520b59b6bc1057340b55750186466ea715e30e",
    "build_date" : "2023-03-27T16:31:09.816451435Z",
    "build_snapshot" : false,
    "lucene_version" : "9.5.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

This means that Elasticsearch is active and running on your server.

Step 5: Uninstall Elasticsearch

Run the following script to remove Elasticsearch from your system.

# apt remove elasticsearch

Comments and Conclusion

In this tutorial we have installed the free version which is released under the Elastic license. You can check the Subscriptions page for more information about Elastic license levels.

For additional help or useful information, you can check the official Elasticsearch Documentation.

If you have any questions please leave a comment below.

How to Install PostgreSQL 15 on Debian 11

PostgreSQL also known as Postgres, is a free and open source object-relational database system that runs on Client-Server architecture. It is one of the leading database servers used for production servers. DevOps use it as an alternative to MariaDB.

In this guide we are going to install PostgreSQL 15 in Debian 11.

1. Update Operating System

Update your Debian 11 operating system to make sure all existing packages are up to date:

# apt update && sudo apt upgrade -y

2. Install PostgreSQL 15 using the official repository

PostgreSQL is available in the default Debian repositories but the available versions are not up to date.

To get the latest packages of PostgreSQL, you must add the official repo of PostgreSQL.

First, install all required dependencies by running the following command:

# apt-get install wget sudo curl gnupg2 -y

After installing all the dependencies, create the file repository configuration with the following command:

# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Now import the repository signing key by using the following command:

# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Update your local package index with the following command:

# apt -y update

Now you can run the following command to install the latest version of the PostgreSQL server:

# apt-get install postgresql-15 -y

After the successful installation, start the PostgreSQL service and enable it to start after the system reboot:

# systemctl start postgresql
# systemctl enable postgresql

Verify that is active and running on your server:

# systemctl status postgresql
Output
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited)
   Main PID: 7543 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 2300)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/postgresql.service

By default, PostgreSQL listens on port 5432. You can check it with the following command:

# ss -antpl | grep 5432

You will get the PostgreSQL listening port in the following output:

LISTEN 0      244             127.0.0.1:5432       0.0.0.0:*    users:(("postgres",pid=7525,fd=6))
LISTEN 0      244                 [::1]:5432          [::]:*    users:(("postgres",pid=7525,fd=5))

You can also check the version using the following command:

# sudo -u postgres psql -c "SELECT version();"

You will get the version in the following output:

                                                           version
-----------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 15.0 (Debian 15.0-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
(1 row)

3. Logging into PostgreSQL

To access your PostgreSQL server, you must log in as a Postgres user. To do this run the following command:

# su postgres

Now you can access your PostgreSQL shell with the following command:

$ psql

In your output you will see:

Output
psql (15.0 (Debian 15.0-1.pgdg110+1))
Type "help" for help.

postgres=#

Once you have accessed the command shell of Postgres, you can now use SQL queries to perform several database-related operations.

To set the Postgres pasword, run the following command:

ALTER USER postgres PASSWORD 'password';

To create a database named test, run the following command:

CREATE DATABASE test;

To list all databases, run the following command:

\l

You should see all databases in the following output:

To switch the database to test, run the following command:

\c test

To create a table (e.g accounts), run the following command:

CREATE TABLE accounts (
	user_id serial PRIMARY KEY,
	username VARCHAR ( 50 ) UNIQUE NOT NULL,
	password VARCHAR ( 50 ) NOT NULL,
	email VARCHAR ( 255 ) UNIQUE NOT NULL,
	created_on TIMESTAMP NOT NULL,
        last_login TIMESTAMP 
);

To list all tables, run the following command:

\dt

You should see all tables in the following output:

          List of relations
 Schema |   Name   | Type  |  Owner
--------+----------+-------+----------
 public | accounts | table | postgres
(1 row)<

To exit from the shell, run the following command:

exit

4. Backup and Restore a Single Database

You can back up and restore a single database using the pg_dump utility.

For example, to back up a single database named test and generate a backup file named test_backup.sql, run the following command:

su - postgres
pg_dump -d test -f test_backup.sql

You can also restore a single database using psql command.

For example, to restore a single database named test from a backup file named test_backup.sql, run the following command:

su - postgres
psql -d test -f test_backup.sql

Comments and Conclusion

At this point, you learn to set up PostgreSQL 15 on Debian 11.  If you need more information, or have any questions, just comment below and we will be glad to assist you!

Check below for some of our other articles.

How to Install Moodle on Debian 11

Moodle is a popular, free, and open-source Course Management system based on PHP released under the GNU General Public License.

The Moodle platform is highly customizable and takes a modular approach to features, so it is extensible and adaptable to your needs. It is probably most popular open source learning management platform available today.

In this tutorial, we will show you how to install Moodle on your Debian 11 OS.

Step 1: Update Operating System

Update and upgrade the system repositories to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade

Step 2: Install Apache webserver

Apache web server is available on the Debian repository and can be installed via apt package manager by executing the following command:

$ sudo apt install apache2

You can start the Apache service and configure it to run on startup by entering the following commands:

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Verify the status of the Apache service using systemctl status command:

$ sudo systemctl status apache2

Output:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 459 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 666 (apache2)
      Tasks: 6 (limit: 2301)
     Memory: 24.3M
        CPU: 439ms
     CGroup: /system.slice/apache2.service
             ├─666 /usr/sbin/apache2 -k start
             ├─677 /usr/sbin/apache2 -k start
             ├─678 /usr/sbin/apache2 -k start
             ├─679 /usr/sbin/apache2 -k start
             ├─680 /usr/sbin/apache2 -k start
             └─681 /usr/sbin/apache2 -k start

You can test to make sure everything is working correctly by navigating to:

http://your-IP-address

If everything is configured properly, you should be greeted by the Apache2 Debian Default Page, as seen below.

Step 3: Install PHP and PHP extensions for Moodle

By default, Debian 11 comes with PHP version 7.4.

You can install PHP and required PHP extensions using the following command:

$ sudo apt install php libapache2-mod-php php-iconv php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml php-pspell php-json php-xmlrpc

Verify if PHP is installed.

php -v
Output: PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

Step 4: Install MariaDB

We will use MariaDB as the database system for Moodle (Moodle supports MariaDB/MySQL and PostgreSQL).

You can install MariaDB with the following command:

$ sudo apt install mariadb-server mariadb-client

The commands below can be used to stop, start and enable MariaDB service to start automatically at the next boot:

$ sudo systemctl start mariadb
$ sudo systemctl stop mariadb
$ sudo systemctl enable mariadb

Also, you can verify the status of the MariaDB service using systemctl status command:

$ sudo systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.5.15 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 16987 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 8 (limit: 2287)
     Memory: 63.0M
        CPU: 1.403s
     CGroup: /system.slice/mariadb.service
             └─16987 /usr/sbin/mariadbd

Then open the MariaDB default configuration file:

$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Under ‘[mysqld]‘ line, paste the following configuration:

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

Save and exit, then restart MariaDB service:

$ sudo systemctl restart mariadb

Step 5: Create Database

Log into the MariaDB prompt:

$ sudo  mysql -u root

To create a database, database user, and grant all privileges to the database user run the following commands:

MariaDB [(none)]> CREATE DATABASE moodledb;
MariaDB [(none)]> CREATE USER 'moodle_user'@'localhost' IDENTIFIED BY 'Moodle_Passw0rd!';
MariaDB [(none)]> GRANT ALL ON moodledb.* TO 'moodle_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 6: Download Moodle

We will now download the latest stable Moodle version from the Moodle Official site.

Use the following command to download Moodle:

$ sudo wget https://download.moodle.org/download.php/direct/stable400/moodle-4.0.1.zip

Extract file into the folder /var/www/html/ with the following command:

$ sudo unzip moodle-4.0.1.zip -d /var/www/html/

Then, create a new directory in /var/www/html directory:

$ sudo mkdir /var/www/html/moodledata

Enable permission for the Apache webserver user to access the files:

$ sudo chown -R www-data:www-data /var/www/html/moodle/
$ sudo chmod -R 755 /var/www/html/moodle/
$ sudo chown -R www-data:www-data /var/www/html/moodledata/

Step 7: Configure Apache Web Server for Moodle

Navigate to /etc/apache2/sites-available directory and run the following command to create a configuration file for your installation:

$ sudo nano /etc/apache2/sites-available/moodle.conf

Add the following content:

<VirtualHost *:80>

ServerAdmin webmaster@your-domain.com

ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/moodle

<Directory /var/www/html/moodle/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the virtual host:

$ sudo a2ensite moodle.conf

After that, restart the Apache web server.

$ sudo systemctl restart apache2

Step 8: Access Moodle Web Installer

Open your browser type your domain e.g http://your-domain.com You will see the Moodle installation page.

Choose a language, and then click ‘Next‘:

Configure the URL, web root directory, and data directory and then click ‘Next‘:

Configure ‘Database driver‘, use MariaDB database server and then click ‘Next‘.

Type in the database information and then click ‘Next‘ to continue.

Accept the Copyright Agreement. Just click ‘Continue‘.

System Checking, checks the server configuration and all PHP extensions needed by Moodle.

 

If all the requirements are OK click ‘Continue

Make sure all results are ‘Success‘. Then click ‘Continue‘ again.

Fill in your admin info and click ‘Update profile‘.

You will be redirected to the user admin ‘Dashboard‘:

Comments and Conclusion

That’s it. You have successfully installed Moodle on Debian 11 OS.

If you have any questions please leave a comment below.