Install Roundcube on Ubuntu

How to Install Roundcube on Ubuntu 22.04

Roundcube is a free open-source web-based multilingual IMAP email client written in PHP. It provides the full functionality you expect from an email client, including MIME support, address book, folder manipulation, message searching, and spell checking.

This tutorial is going to show you how to install Roundcube webmail on Ubuntu 22.04 with Nginx web server and MySQL database server.

Step 1: Update Operating System

Before you can proceed with installation and configuration of Roundcube webmail on Ubuntu 22.04, update and upgrade your system packages to the latest version with the following command:

# apt update && sudo apt upgrade -y

Step 2: Install Nginx Web Server

In this tutorial, we will use Nginx. If you prefer Apache or another web server, you can use that instead of Nginx.

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; vendor preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
   Main PID: 5317 (nginx)
      Tasks: 2 (limit: 2196)
     Memory: 2.6M
        CPU: 31ms
     CGroup: /system.slice/nginx.service
             ├─5317 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─5318 "nginx: worker process

Step 3: Install PHP and required PHP extensions for Roundcube

Run the following command to install the required PHP extensions. PHP8.1 is fully supported in the 1.6 release.

# apt install php php-fpm php-gd php-common php-json php-imagick php-imap php-xml php-mbstring php-curl php-zip php-bz2 php-intl php-ldap

Verify if PHP is installed.

# php -v
Output:
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# apt install mysql-server

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

# systemctl start mysql
# systemctl enable mysql

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

# systemctl status mysql

Output:

 mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 1083 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 2797)
     Memory: 434.0M
        CPU: 1min 57.932s
     CGroup: /system.slice/mysql.service
             └─1083 /usr/sbin/mysqld

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

# mysql_secure_installation

Configure it like this:

- Set 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 MySQL shell.

# mysql -u root -p

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

mysql> CREATE DATABASE roundcubemail;
mysql> CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'Strong-Password';
mysql> GRANT ALL PRIVILEGES ON roundcubemail . * TO 'roundcube'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download Roundcube

Roundcube is availble on the default Ubuntu repos. However, the repositories do not usually provide an up-to-date version.

The latest stable release version for Roundcube can be installed by downloading the source code from the Roundcube downloads page.

Using the address with wget, download the Roundcube tarball on the server:

# wget https://github.com/roundcube/roundcubemail/releases/download/1.6.0/roundcubemail-1.6.0-complete.tar.gz

Create a roundcube directory:

# mkdir /var/www/roundcube/

After that, you will need to decompress the Roundcube archive:

# tar -xvzf roundcubemail-1.6.0-complete.tar.gz -C /var/www/roundcube/ --strip-components 1

Make Nginx the owner of the roundcube folder and grant it sufficient permissions.

# chown -R www-data:www-data /var/www/roundcube
# chmod 755 -R /var/www/roundcube

Now start the example database included in the downloaded file.

# mysql -u roundcube -p roundcube < /var/www/roundcube/SQL/mysql.initial.sql

Step 6: Configure Nginx for Roundcube

Then, create an virtual host configuration file to host Roundcube:

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

Nginx ignores Roundcube’s Apache .htaccess files, so we’re telling Nginx to ignore some sensitive directories:

server {
        listen 80;

        server_name webmail.your-domain.com;
        root /var/www/roundcube;

        index index.php index.html index.htm;

        error_log /var/log/nginx/roundcube.error;
        access_log /var/log/nginx/roundcube.access;


        location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
            deny all;
        }

        location ~ ^/(config|temp|logs)/ {
            deny all;
        }

        location ~ /\. {
            deny all;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }
}

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

Save and exit the configuration file.

Check Nginx syntax:

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

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Step 7: Roundcube Setup and Configurations

Now open your web browser and go to http://webmail.your-domain.com/installer and you will see the following screen:

If all required modules and extensions are installed, press NEXT and go to the next step.

On the next page, navigate to Database Setup settings and enter the database name, user and password that you created above.

Under SMTP settings, check the box ‘Use the current IMAP username and password for SMTP authentication’:

After complete configuration , Press CREATE CONFIG to finish the installation. You will then be notified that the configuration has been successfully created.

 

Once everything is setup and working, open your terminal and remove the installation directory with the following command:

# rm -rf /var/www/roundcube/install/

And now go to http://webmail.your-domain.com so you can log in.

Comments and Conclusion

Congratulations! You have successfully installed Roundcube webmail client. Thanks for using this tutorial for installing the Roundcube on Ubuntu 22.04 OS.

How to Install AbanteCart on Ubuntu 22.04

AbanteCart is an open-source e-commerce platform based on PHP. It is an ideal e-commerce solution for small to medium businesses.

In this tutorial, we will show you how to install AbanteCart on Ubuntu 22.04 OS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to the latest version with the following command:

# apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

The Apache HTTP Server is a free and open-source cross-platform web server. You can install it via apt package manager by executing the following command.

# apt install apache2

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

# systemctl start apache2
# systemctl enable 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; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3548 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 3552 (apache2)
      Tasks: 7 (limit: 2196)
     Memory: 46.8M         CPU: 1.594s
     CGroup: /system.slice/apache2.service
             ├─3552 /usr/sbin/apache2 -k start
             ├─3554 /usr/sbin/apache2 -k start
             ├─3555 /usr/sbin/apache2 -k start
             ├─3556 /usr/sbin/apache2 -k start

Step 3: Install PHP

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

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

Verify if PHP is installed.

php -v
Output:
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies

Also, disable the php-opcache module to avoid AbanteCart installation time errors.

# phpdismod opcache

Restart Apache for changes to take effect.

# systemctl restart apache2

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# apt install mysql-server

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

# systemctl start mysql
# systemctl enable mysql

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

# systemctl status mysql

Output:

 mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 1083 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 2797)
     Memory: 434.0M
        CPU: 1min 57.932s
     CGroup: /system.slice/mysql.service
             └─1083 /usr/sbin/mysqld

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

# mysql_secure_installation

Configure it like this:

- Set 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 AbanteCart installation:

mysql> CREATE DATABASE abantecart;
mysql> CREATE USER 'abantecart'@'localhost' IDENTIFIED BY 'Your-Strong-Password';
mysql> GRANT ALL PRIVILEGES ON abantecart . * TO 'abantecart'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download AbanteCart

By default, AbanteCart is not available on Ubuntu 20.04 base repository. You can download the latest version of AbanteCart from the Git repository using the following command:

# wget https://github.com/abantecart/abantecart-src/archive/master.zip

Once the download is completed extract the downloaded package using unzip command:

# apt -y install unzip 
# unzip master.zip -d /var/www/

Then, create the public web root directory for Abantecart:

# mkdir /var/www/abantecart

Move the extracted abantecart-src-master/public_html directory to the /var/www/abantecart/ directory:

# mv /var/www/abantecart-src-master/public_html/* /var/www/abantecart/

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

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

Step 6: Create Virtualhost for Abantecart

Then, create an virtual host configuration file to host AbanteCart:

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

Paste the content as shown below:

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

    <Directory /var/www/abantecart/>
        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.

To enable this site run the command:

# a2ensite abantecart.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Access AbanteCart Web Interface

To access the AbanteCart Web Interface, go to your browser and visit http://your-domain.com/.

The first page displays the license agreement. Scroll down Accept the License agreement and click Continue.

Make sure all the required PHP extensions are installed then click on the Continue button.

The next page will require you to fill in the database details. Configure the database and admin credentials and click Continue.

Once the installation has been completed, you should see the following page:

Then if you click on the Your Online Shop you should see your shop page:

Or if you click on the Login to your Control Panel button you should see the login page:

Provide your admin username, password and click on the Login button. You should see your administration panel:

 

Now, open your terminal and remove the installation directory with the following command:

# rm -rf /var/www/abantecart/install/

Comments and Conclusion

Congratulations! You have successfully installed AbanteCart. Thanks for using this tutorial for installing the AbanteCart on Ubuntu 22.04 OS.

For additional help or useful information, we recommend you to check the official AbanteCart website.

How to Install Ghost on Ubuntu 22.04

Ghost is an open-source powerful NodeJS-based Content Management System (CMS) for creating blog oriented websites. It has full support for Markdown and provides an easy-to-use web interface for administration purposes.

In this tutorial we will show you how to install Ghost CMS on a Ubuntu 22.04 OS.

Step 1: Add a new user

To install Ghost, we need to add normal user with root privileges.

# adduser linuxtuto

Note: Do not use username as a ghost it gets cause conflicts with the Ghost-CLI.

To add the user to the sudo group, use the usermod command as follows:

# usermod -aG sudo linuxtuto

Then log in as the new user:

# su - linuxtuto

Step 2: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 3: Install Nginx webserver

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

$ sudo apt install nginx

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

$ sudo systemctl status nginx

Output:

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

Step 4: Install MySQL

You can install the MySQL server with the following command:

$ sudo apt install mysql-server

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

$ sudo systemctl start mysql
$ sudo systemctl enable mysql

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

$ sudo systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 1083 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 2797)
     Memory: 434.0M
        CPU: 1min 57.932s
     CGroup: /system.slice/mysql.service
             └─1083 /usr/sbin/mysqld

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

$ sudo mysql_secure_installation

Configure it like this:

- Set 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

Run the command below to log in to the MySQL shell.

$ sudo mysql -u root -p

Once you are logged in to your database server you need to create a database:

mysql> CREATE DATABASE ghostdb;
mysql> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'Str0ngPEd6';
mysql> GRANT ALL PRIVILEGES ON ghostdb. * TO 'ghostuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Install Node.js

To install Ghost you need a supported Node.js version, so you can use the officially recommended Node.js v16.

First, add the Node.js repository running the following command:

$ sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash

Once added, install the Node.js with the following command:

$ sudo apt-get install nodejs

Verify the installed version of Node.js running the following command:

node --version

You should see the following output:

v16.18.1

Run the following command to install npm latest version globally:

$ sudo npm install npm@latest -g

npm is the node package manager used to install the Ghost-CLI on a system.

Verify the npm version with the following command:

npm --version

You should get the following output:

9.1.2

Step 6: Install Ghost-CLI on Ubuntu 22.04

Ghost-CLI is a command-line tool to help you get Ghost installed and configured for use, quickly and easily.

Run the following command to install.

$ sudo npm install -g ghost-cli@latest

Checking Ghost-CLI version:

$ ghost -v
Ghost-CLI version: 1.23.1

Step 7: Install Ghost

Once your server is setup and ghost-cli is installed you can install Ghost.

You can use the recommended location to install Ghost which is /var/www/ghost

$ sudo mkdir /var/www/ghost

Set up correct permissions.

$ sudo chown linuxtuto:linuxtuto /var/www/ghost
$ sudo chmod 775 /var/www/ghost

Move inside the directory and install Ghost.

$ cd /var/www/ghost/
$ ghost install

You will see the output as follows.

 Checking system Node.js version - found v16.18.1
 Checking logged in user
 Checking current folder permissions
 Checking system compatibility
 Checking for a MySQL installation
 Checking memory availability
 Checking free space
 Checking for latest Ghost version
 Setting up install directory
 Downloading and installing Ghost v5.24.0
 Finishing install process
? Enter your blog URL: http://your-domain.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghostdb
 Configuring Ghost
 Setting up instance
+ sudo useradd --system --user-group ghost
? Sudo Password [hidden]
+ sudo chown -R ghost:ghost /var/www/ghost/content
 Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
+ sudo nginx -s reload
 Setting up Nginx

Now you have to open a web browser and log in with the address https://your-domain.com/ghost and you will be able to create the admin user.

Then you will see the control panel, and you will be able to use it.

Comments and Conclusion

Congratulations! You have successfully installed Ghost CMS on Ubuntu 22.04.

You should now visit the Ghost Help page and learn more about how to manage you Ghost installation.

Thanks for using this tutorial for installing the Ghost CMS on your Ubuntu 22.04 OS.

How to Install ownCloud on Ubuntu 22.04

ownCloud is a powerful an open-source collaboration tool that allows users store and securely share files and folders on a private server.

In this tutorial, we will show you how to install open source version of ownCloud on Ubuntu 22.04.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to the latest version with the following command:

# apt update && sudo apt upgrade -y

Step 2: Install Apache webserver

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

# apt install apache2

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

# systemctl start apache2
# systemctl enable 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; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 845 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 998 (apache2)
      Tasks: 6 (limit: 2797)
     Memory: 27.4M
        CPU: 420ms
     CGroup: /system.slice/apache2.service
             ├─ 998 /usr/sbin/apache2 -k start
             ├─1033 /usr/sbin/apache2 -k start
             ├─1034 /usr/sbin/apache2 -k start
             ├─1035 /usr/sbin/apache2 -k start
             ├─1037 /usr/sbin/apache2 -k start
             └─1038 /usr/sbin/apache2 -k start

Step 3: Install PHP and required extensions 

The PHP version available to install using the default standard repository of Ubuntu 22.04 is 8.x, however, while doing this article OwnCloud doesn’t support PHP 8.x, hence here we are installing PHP7.4 using Ondrej PPA repo.

To have the required version of PHP, add the Ondrej repository:

# add-apt-repository ppa:ondrej/php

Run system update command:

# apt update

Install required extensions:

# apt install php7.4 php7.4-{opcache,gd,curl,mysqlnd,intl,json,ldap,mbstring,mysqlnd,xml,zip}

Step 4: Install MySQL and create a database

You can install the MySQL server with the following command:

# apt install mysql-server

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

# systemctl start mysql
# systemctl enable mysql

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

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 1083 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 2797)
     Memory: 434.0M
        CPU: 1min 57.932s
     CGroup: /system.slice/mysql.service
             └─1083 /usr/sbin/mysqld

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

# mysql_secure_installation

Configure it like this:

- Set 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 MySQL shell.

# mysql -u root -p

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

mysql> CREATE DATABASE owncloud;
mysql> CREATE USER 'owncloud'@'localhost' IDENTIFIED BY 'Str0ngPEd6';
mysql> GRANT ALL PRIVILEGES ON owncloud. * TO 'owncloud'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Install ownCloud

The latest version of ownCloud is available to download from their website. You can download it with the following command:

# wget https://download.owncloud.com/server/stable/owncloud-complete-latest.zip

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

# unzip owncloud-complete-latest.zip -d /var/www/

Create a directory to store the user data:

# mkdir -p /var/www/owncloud/data

Change the ownership of the directory with the command:

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

Step 6: Configure Apache for ownCloud

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

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

Add the following content:

<VirtualHost *:80>

ServerName cloud.your-domain.com

ServerAdmin webmaster@your-domain.com
DocumentRoot /var/www/owncloud

<Directory /var/www/owncloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/apache2/cloud.your-domain.com_error.log
CustomLog /var/log/apache2/cloud.your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Enable the ownCloud virtual host:

# a2ensite owncloud.conf

Restart the Apache web server.

# systemctl restart apache2

Step 7: Access your ownCloud Application

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

After filling in all the necessary details, click Finish setup and, in less than a minute, the installation will complete and you can then log in as the admin user.

Once logged in, you are taken to the main ownCloud page:

Comments and Conclusion

That’s it. You have successfully installed Open Source version of ownCloud on Ubuntu 22.04.

If you have any questions please leave a comment below.

How to Install phpBB on AlmaLinux 9

phpBB is an acronym for PHP Bulletin Board. It is a fully scalable and customizable open-source forum written in PHP. It can be used to to create forums, start topics and share ideas.

In this tutorial we will show you how to install phpBB on AlmaLinux 9 using the LAMP stack.

Step 1: Update Operating System

Update your AlmaLinux 9 operating system to make sure all existing packages are up to date:

# dnf update

Also, install:

# dnf install wget nano unzip

Step 2: Install Apache web server

To install Apache web server, run the following command:

# dnf install httpd

Apache does not start automatically when it is installed, you need to start it:

# systemctl start httpd

Then enable it to start on boot time.

# systemctl enable httpd

If firewalld is enabled consider allowing HTTP and HTTPS services:

# firewall-cmd --permanent --add-service={http,https}
# firewall-cmd --reload

Step 3: Install PHP and required PHP modules

In this section we will install PHP and PHP extensions required to run phpBB with the following command:

# dnf install php php-mysqli php-gd php-zip php-intl php-mbstring php-json

Once the installation is complete, verify the version of PHP installed:

# php -v
Output:
PHP 8.0.13 (cli) (built: Nov 16 2021 18:07:21) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Step 4: Install MariaDB and create a database

To be able to install MariaDB on AlmaLinux 9 you need to add the MariaDB YUM repository:

# curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

Once the repository has been added to the system, installing MariaDB is an easy task that can be accomplished with the following command:

# dnf install mariadb-server

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 installed version of MariaDB.

# systemctl status mariadb

Output:

 mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running)
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 47677 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 11 (limit: 10951)
Memory: 71.2M
CPU: 2.238s
CGroup: /system.slice/mariadb.service
└─47677 /usr/libexec/mariadbd --basedir=/usr

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

mysql_secure_installation

Configure it like this:

Set 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

Once the database server is installed, log into the MariaDB prompt:

#  mysql -u root -p

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

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

Step 5: Download phpBB forum

The phpBB forum is not available to download or install using the AlmaLinux package repositories. We have to download its files manually from its official website.

The version of phpBB as of this writing is 3.3.8.

Change directory to /tmp directory, you can use any directory:

# cd  /tmp

Use the following command to download phpBB forum:

# wget https://download.phpbb.com/pub/release/3.3/3.3.8/phpBB-3.3.8.zip

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

# unzip phpBB-3.3.8.zip -d /var/www/html

Rename the extracted directory:

# mv /var/www/html/phpBB3 /var/www/html/phpbb

Enable permission for the Apache webserver user to access the phpBB files,

# chown -R apache:apache /var/www/html/phpbb

Step 6: Configure Apache Web Server for phpBB forum

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

# nano /etc/httpd/conf.d/phpbb.conf

Add the following content:

<VirtualHost *:80>

ServerName your-domain.com

ServerAdmin webmaster@your-domain.com
DocumentRoot /var/www/html/phpbb

<Directory /var/www/html/phpbb/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/your-domain.com_error.log
CustomLog /var/log/httpd/your-domain.com_access.log combined

</VirtualHost>

Save the file and Exit.

Restart the Apache web server.

# systemctl restart httpd

Step 7: Install phpBB forum on AlmaLinux 9

Open your browser and complete the final steps e.g http://your-domain.com

To start the installation, click the ‘Install’ tab then click install.

Fill in the details of the Administrator user and password and click on ‘Submit‘.

Fill up the database configuration:

For the server configuration you can just leave the default settings and click ‘Submit’:

 

In this steps you will ask to provide your SMTP settings, if email functionality is not configured, simply click ‘Submit‘ without changing any parameter.

Specify the settings of the Bulletin Board such as the default language, Board Title, and a short description of the board. Then click ‘Submit‘:

Finally, the installation should be complete!

Click on ‘the ACP‘ link provided. This takes you to the Admin panel shown:

Now, delete the ‘Install‘ folder to access the create, delete the posts and access the features of the phpBB forum software.

Go to your server terminal and run this command:

# rm -rf /var/www/html/phpbb/phpbb/install

Comments and Conclusion

That’s it. You have successfully installed phpBB on AlmaLinux 9.

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 Django with Apache on Ubuntu 22.04

Django is a python based full stack framework. This framework works based on the model-template-view architectural patterns. Django is considered to be one of the popular web based development frameworks for developing Python’s server applications.

The high profile websites that use Django are Disqus, Instagram, MacArthur Foundation, National Geographic channel, Knight Foundation, Pinterest, Open knowledge foundation, and open stack software.

We will be installing Django application in a Python virtual environment. It is very useful because it allows developers to run and develop an application with different python versions.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to the latest version with the following command:

# apt update && sudo apt upgrade -y

Step 2: Install Apache with mod_wsgi Module

To setup Django to production we will install Apache and the Apache mod_wsgi module.

You can install them via apt package manager by executing the following command:

# apt install apache2 libapache2-mod-wsgi-py3

Once all the packages are installed, you can start the Apache service and configure it to run on startup by entering the following commands:

# systemctl start apache2
# systemctl enable 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; vendor preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 39757 (apache2)
      Tasks: 55 (limit: 2200)
     Memory: 15.2M
        CPU: 206ms
     CGroup: /system.slice/apache2.service
             ├─39757 /usr/sbin/apache2 -k start
             ├─39761 /usr/sbin/apache2 -k start
             └─39762 /usr/sbin/apache2 -k start

Step 3: Install MySQL and create a database

You can install the MySQL server and libmysqlclient-dev (MySQL database development files) with the following command:

# apt install mysql-server libmysqlclient-dev

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

# systemctl start mysql
# systemctl enable mysql

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

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 41039 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 2200)
     Memory: 358.9M
        CPU: 1.070s
     CGroup: /system.slice/mysql.service
             └─41039 /usr/sbin/mysqld

Once the database server is installed, log into the MySQL prompt:

#  mysql -u root

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

mysql> CREATE DATABASE django_db;
mysql> CREATE USER 'django_user'@'localhost' IDENTIFIED BY 'Pa$$word';
mysql> GRANT ALL ON django_db.* TO 'django_user'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Step 4: Install Pip on Ubuntu 22.04

Python comes already installed by default on Ubuntu 22.04. You can verify it by checking its version:

# python3 -V
Output:
Python 3.10.6

Use the following command to install pip and venv on Ubuntu 22.04:

# apt install python3-venv python3-pip

Verify your Pip installation by checking its version:

# pip3 --version
Output:
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Step 5: Install Django Using Virtualenv

First, create a directory and switch to it with the commands below:

# mkdir /var/www/django_project 
# cd /var/www/django_project

Before you install Django, you first need to create a Python virtual environment.

# python3 -m venv django_env

Next, activate the virtual environment with the following command:

# source django_env/bin/activate

Next, install the latest  Django version using the following command:

(django_env) # pip install django

You will get the following output:

Collecting django
  Downloading Django-4.1.1-py3-none-any.whl (8.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.1/8.1 MB 3.3 MB/s eta 0:00:00
Collecting asgiref<4,>=3.5.2
  Downloading asgiref-3.5.2-py3-none-any.whl (22 kB)
Collecting sqlparse>=0.2.2
  Downloading sqlparse-0.4.3-py3-none-any.whl (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.8/42.8 kB 2.0 MB/s eta 0:00:00
Installing collected packages: sqlparse, asgiref, django
Successfully installed asgiref-3.5.2 django-4.1.1 sqlparse-0.4.3

Verify the Django version with the following command:

(django_env) # django-admin --version

You will get the following output:

4.1.1

Since you are setting a production site ensure you’ve python mysqlclient installed:

(django_env) # pip install mysqlclient

You will get the following output:

Collecting mysqlclient
  Downloading mysqlclient-2.1.1.tar.gz (88 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.1/88.1 KB 1.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-2.1.1

Step 6: Creating your Django project

Now you need to create Django project in django_project directory.

(django_env) # django-admin startproject django_app .

Next, modify settings.py file:

(django_env) # nano django_app/settings.py

Add the URL in ALLOWED_HOST List which is above INSTALLED_APPS.

ALLOWED_HOSTS = ['your_server_ip', 'your-domain.com']

The default database set in Django is SQLite. Replace SQLite database backend:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

with MySQL database engine backend :

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_db',
'USER': 'django_user',
'PASSWORD': 'Pa$$word',
'HOST': '127.0.0.1',
'PORT' : '3306',
}
}

In order for our webserver to serve the static files add the following lines:

import os

STATIC_URL='/static/'
STATIC_ROOT=os.path.join(BASE_DIR, 'static/') 

MEDIA_URL='/media/'
MEDIA_ROOT=os.path.join(BASE_DIR, 'media/')

Once done, save the file and exit the text editor.

Now, You can migrate the initial database schema to our MySQL database using the management script:

(django_env) # ./manage.py  makemigrations
(django_env) # ./manage.py  migrate

Create an administrative user for the project by typing:

(django_env) # ./manage.py createsuperuser

You will have to provide a username, an email address, and choose and confirm a password.

Username (leave blank to use 'root'): admin
Email address: admin@your-domain.com
Password:
Password (again):
Superuser created successfully.

You can collect all of the static content into the directory location you configured by running the command:

(django_env) # ./manage.py collectstatic

This will collect all the project static files in static directory. It will give some output like this:

130 static files copied to '/var/www/django_project/static'.

To deactivate the virtual environment run the following command:

(django_env) # deactivate

Step 7: Configure Apache Web Server for Django

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

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

Add the following content:

<VirtualHost *:80>

        ServerAdmin admin@your-domain.com
        ServerName your-domain.com
        ServerAlias www.your-domain.com

        DocumentRoot /var/www/django_project/

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

        Alias /static /var/www/django_project/static
        <Directory /var/www/django_project/static>
                Require all granted
        </Directory>

        Alias /media /var/www/django_project/media
        <Directory /var/www/django_project/media>
                Require all granted
         </Directory>

        <Directory /var/www/django_project/django_app>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess django_app python-path=/var/www/django_project python-home=/var/www/django_project/django_env
        WSGIProcessGroup django_app
        WSGIScriptAlias / /var/www/django_project/django_app/wsgi.py

</VirtualHost>

Save the file and Exit.

Enable the Django virtual host:

# a2ensite django.conf

Restart the Apache web server.

# systemctl restart apache2

Step 8: Access Django Project

That’s it the production site has been setup. You can now access your application with your domain at e.g http://your-domain.com

To access the admin dashboard, add /admin/ to the end of your URL http://your-domain.com/admin This will take you to a log in screen:

Enter your Django admin user, password and click on the Log in. You will get the Django administration dashboard in the following screen:

Comments and Conclusion

That’s it. You have successfully installed Django on Ubuntu 22.04 with Apache and WSGI. For additional information, you can check the official Django documentation.

If you have any questions please leave a comment below.

 

How To Install AngularJS on Ubuntu 22.04

AngularJS is an open-source JavaScript framework developed by Google for building dynamic web applications. Compared to other options such as jQuery, Knockout, Handlebars, or PagerJs, Angular integrates a complete solution that allows us to abandon the old PHP in our developments with modern technology.

In this tutorial you will learn to install and create AngularJS Application on a Ubuntu 22.04 OS.

Step 1: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js

Currently, Angular is only supported on LTS versions of Node.js

The Node.js version included in the default Ubuntu 22.04 repositories is v12.22.9 which is an older LTS version.

We’ll install Node.js version 16.x LTS on our Ubuntu OS.

First, add the Node.js repository running the following command:

curl -sL https://deb.nodesource.com/setup_16.x | bash -

Once added, install the Node.js with the following command:

$ sudo apt-get install nodejs

Verify the installed version of Node.js running the following command:

node --version

You should see the following output:

v16.17.0

Run the following command to install npm latest version globally:

$ sudo npm install npm@latest -g

npm is the node package manager used to install the Angular command-line interface on a system.

Verify the npm version with the following command:

npm --version

You should get the following output:

8.18.0

Step 3: Install AngularJS on Ubuntu 22.04

After installing node package manager, you can now use it to install AngujarJS. Run the following command to install.

$ sudo npm install -g @angular/cli

Check AngularJS version installed using the command below.

$ sudo ng version

Sample output:

Step 4: Create AngularJS Application

Now, you can create a AngularJS application with the following command:

$ sudo ng new angular-demo-app 

Sample Output:

? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? CSS
CREATE angular-demo-app/README.md (1068 bytes)
CREATE angular-demo-app/.editorconfig (274 bytes)
CREATE angular-demo-app/.gitignore (548 bytes)
CREATE angular-demo-app/angular.json (2972 bytes)
CREATE angular-demo-app/package.json (1047 bytes)
CREATE angular-demo-app/tsconfig.json (863 bytes)
CREATE angular-demo-app/.browserslistrc (600 bytes)
CREATE angular-demo-app/karma.conf.js (1433 bytes)
CREATE angular-demo-app/tsconfig.app.json (287 bytes)
CREATE angular-demo-app/tsconfig.spec.json (333 bytes)
CREATE angular-demo-app/.vscode/extensions.json (130 bytes)
CREATE angular-demo-app/.vscode/launch.json (474 bytes)
CREATE angular-demo-app/.vscode/tasks.json (938 bytes)
CREATE angular-demo-app/src/favicon.ico (948 bytes)
CREATE angular-demo-app/src/index.html (300 bytes)
CREATE angular-demo-app/src/main.ts (372 bytes)
CREATE angular-demo-app/src/polyfills.ts (2338 bytes)
CREATE angular-demo-app/src/styles.css (80 bytes)
CREATE angular-demo-app/src/test.ts (749 bytes)
CREATE angular-demo-app/src/assets/.gitkeep (0 bytes)
CREATE angular-demo-app/src/environments/environment.prod.ts (51 bytes)
CREATE angular-demo-app/src/environments/environment.ts (658 bytes)
CREATE angular-demo-app/src/app/app-routing.module.ts (245 bytes)
CREATE angular-demo-app/src/app/app.module.ts (393 bytes)
CREATE angular-demo-app/src/app/app.component.css (0 bytes)
CREATE angular-demo-app/src/app/app.component.html (23115 bytes)
CREATE angular-demo-app/src/app/app.component.spec.ts (1103 bytes)
CREATE angular-demo-app/src/app/app.component.ts (220 bytes)
✔ Packages installed successfully.

After installing, navigate to the installation folder.

$ sudo cd angular-demo-app

Once you are in the project folder you can start Angular application in development mode with the following command:

$ sudo ng serve

By default ng serve start application on localhost on port 4200.

Alternatively, you can change the host and port on which the application is running using:

$ sudo ng serve --host 0.0.0.0 --port 8000

Here, the application is running on IP address 0.0.0.0 and port 8000.

Open your favorite browser and enter the URL your-IP-address:8000 to access your Angular app.

Step 5: Run Angular with PM2

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

First, install PM2 application by running the following command:

$ sudo npm install -g pm2

You can simply start Angular server to serve your application on 127.0.0.1 (localhost) and port 4200 with the following command:

$ sudo pm2 start "ng serve"

You can specific host, port and name of your app with the following command:

$ sudo pm2 start "ng serve --host 0.0.0.0 --port 8000" --name "Angular Demo App"

Enabling watch is another great feature of PM2. It will restart the application after getting any changes in files. This reduces your pain of restarting application after making changes everytime.

$ sudo pm2 start "ng serve --host 0.0.0.0 --port 8000" --name "Angular Demo App" --watch /angular-demo-app

Once you started your Angular application using PM2 run the following command to view the status of your application.

$ sudo pm2 status

For any issues, you can run PM2 logs command. This will display application and error log on screen.

$ sudo pm2 logs 0

Conclusion

Congratulations. You have learned how to Install AngularJS and create a sample app on Ubuntu 22.04. Also, you have learned how to deploy AngularJS application using PM2.

In order to get more information on this topic you can visiting the official website of AngularJS.