Python 3.12 on Ubuntu 22.04

How to Install Python 3.12 on Ubuntu 22.04

Python is a high-level, interpreted programming language known for its simplicity, readability, and versatility. It is used for a wide range of applications, including web development, data analysis, artificial intelligence, scientific computing, automation, and more.

Python’s versatility and ease of use make it an ideal choice for both beginners and experienced developers. It is often recommended as a first programming language due to its simplicity and readability.

Python 3.12 is the latest stable release of the Python programming language. This tutorial illustrates two methods of how to install it on your Ubuntu 22.04 OS.

  • Install Python 3.12 from the deadsnakes PPA
  • Manually build Python 3.12 from the source code

Update Operating System

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

# apt update && apt upgrade -y

Method 1: Install Python 3.12 with APT

Installing Python 3.12 on Ubuntu 22.04 using APT is quite easy, a big thumbs up to the deadsnakes custom PPA!

This makes it easy to install Python on Ubuntu and be able to receive continued updates, bug fixes, and security updates.

Install the prerequisite for adding custom PPAs:

# apt install software-properties-common -y

Then proceed and add the deadsnakes PPA to the APT package manager sources list:

# add-apt-repository ppa:deadsnakes/ppa

Press Enter to continue.

Once the repository has been installed, run an APT update to ensure that the newly imported PPA is reflected.

# apt update

You can now install Python 3.12 with the following command:

# apt install python3.12

To verify the installation and Python 3.12 build version, perform the following:

# python3.12 --version
3.12.0

If you have installed Python 3.12 using the APT package manager, the PIP will not be installed by default. To install PIP, run the following command:

# curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 

You can check PIP for the Python 3.12 version using the following command:

# pip3.12 -V

pip 23.2.1 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

Method 2: Install Python 3.12 from Source

The other alternative to get Python 3.12 installed on your Ubuntu 22.04 OS is by building it from the source code.

With this installation method, the main issue is that you cannot quickly update like the APT package manager and will need to recompile for any changes.

First, install the required prerequisite packages for the compilation of the Python 3.12 source code.

# apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Now proceed and download the latest release version of Python from the Python official release page.

Alternatively, copy the download link for Python 3.12 gzipped tarball and use wget to pull it with the following command:

# wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz

Once done, extract the archive:

# tar -xf Python-3.12.0.tgz

Now navigate into the extracted directory and run the configure script to check the required dependencies. The –-enable optimization flag optimizes the binary by running multiple tests.

# cd Python-3.12.*/
# ./configure --enable-optimizations

Now initiate the Python 3.12 build process:

# make -j 4

Remember, the (-j) corresponds to the number of cores in your system to speed up the build time.

To find out how many cores you have on your system, execute the following code:

# nproc

Output:

4

We have four cores, so in the (make) command, we used (-j 4).

Once the build process has been completed, run the following command to complete the Python installation on the Ubuntu 22.04 system.

The altinstall prevents the compiler to override default Python versions.

# make altinstall

Verify your installation:

# python3.12 --version
Python 3.12.0

Install Python Modules|Extensions on Ubuntu 22.04

Modules and extensions can be installed on Ubuntu 22.04 using the Python Package manager (PIP).

Use the syntax below to install a Python module of choice.

# pip3.12 install module-name

In this tutorial, We will show you how to install a Python module numpy.

# pip3.12 install numpy

Output:

Collecting numpy
  Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/e3/e2/4ecfbc4a2e3f9d227b008c92a5d1f0370190a639b24fec3b226841eaaf19/numpy-1.26.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading numpy-1.26.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.5/58.5 kB 687.4 kB/s eta 0:00:00
Downloading numpy-1.26.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.9/17.9 MB 1.2 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.26.0

You can verify your module installation using the following command:

# pip3.12 list
Package                Version             
---------------------- --------------------
..............
numpy 1.26.0
..............

Use Python 3.12 as default Python3

First, check the current default version using the below command from the terminal.

python3 --version

Output:

Python 3.10.12

Use update-alternatives to create symbolic links to Python3:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 2

And choose which one to use as Python3 via command:

sudo update-alternatives --config python3
 Selection    Path                        Priority   Status
------------------------------------------------------------
* 0           /usr/local/bin/python3.12     2        auto mode
  1           /usr/bin/python3.10           1        manual mode
  2           /usr/local/bin/python3.12     2        manual mode

Press <enter> to keep the current choice[*].

Now check the default version using the below command:

# python3 --version

Output:

Python 3.12.0

That is it!  You are now set to use Python 3.12 to build web applications, software development, create workflows e.t.c

Comments and Conclusion

In the tutorial, you have learned how to install Python 3.12 on Ubuntu 22.04 using APT or install it using source code.

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

If you have any questions please leave a comment below.

How to Install SuiteCRM on Debian 12

SuiteCRM is a free and open-source Customer Relationship Management (CRM) platform that is designed to help businesses to manage their customer relationships, sales, marketing, and customer support activities.

It is a popular choice for organizations looking for a cost-effective CRM solution with extensive customization options.

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

Step 1: Update Operating System

The first step is to ensure that your system is up-to-date. You can do this by running the following command:

# apt update && apt upgrade

Step 2: Install Apache Web Server

To install Apache, run 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; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 2024 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 2028 (apache2)
      Tasks: 7 (limit: 2273)
     Memory: 19.2M
        CPU: 180ms
     CGroup: /system.slice/apache2.service
             ├─2028 /usr/sbin/apache2 -k start
             ├─2029 /usr/sbin/apache2 -k start
             ├─2030 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions for SuiteCRM

By default, Debian12 comes with PHP version 8.2. To install PHP and the necessary extensions, run the following command:

# apt install php php-cli libapache2-mod-php php-json php-common php-mysql php-zip php-gd php-imap php-mbstring php-curl php-xml php-ldap php-pear

Once the installation is complete 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

Then edit the php.ini file:

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

Change the following settings:

memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 32M

Restart the Apache service to apply the changes:

# systemctl restart apache2

Step 4: Install MariaDB and create a database

You can install the MariaDB server 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: 774 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2273)
     Memory: 245.4M
        CPU: 5.791s
     CGroup: /system.slice/mariadb.service
             └─774 /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:

- 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 SuiteCRM installation:

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

Step 5: Download SuiteCRM

Download the latest stable version of SuiteCRM from the SuiteCRM website using the following command:

# wget https://suitecrm.com/download/141/suite714/562969/suitecrm-7-14-0.zip

Unzip the downloaded release file with the following command:

# unzip suitecrm-7-14-0.zip

Rename it to make it simpler:

# mv /var/www/SuiteCRM-7.14.0/ /var/www/suitecrm

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

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

Step 6: Create Virtualhost for SuiteCRM

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

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

Paste the content as shown below:

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

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

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

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

Save and exit the configuration file.

Then enable the "rewrite" module in Apache:

# /usr/sbin/a2enmod rewrite

To enable this site run the command:

To enable this site run the command:

# /usr/sbin/a2ensite suitecrm.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Access SuiteCRM Web Interface

Go to your browser and visit http://suitecrm.your-domain.com. You should see the following page:

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

If everything is okay, click the Next button.

Provide your database name, database username, password, admin username and password. Then, click on the Next button.

You are presented with the details of SuiteCRM configuration completion. Click the Next button and you should see the login page:

Provide your admin credential and click on the LOG IN button, you should see the SuiteCRM dashboard in the following page:

Step 8: Set up Cron Jobs

SuiteCRM needs cron jobs to function properly. Edit the www-data user’s crontab file.

# sudo crontab -e -u www-data

Add the following line at the end of the file.

*    *    *    *    *     cd /var/www/suitecrm; php -f cron.php > /dev/null 2>&1

Save and close the file.

Comments and Conclusion

That’s it. You have successfully installed SuiteCRM on Debian 12.

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

If you have any questions please leave a comment below.

How to Install NextCloud on Debian 12

Nextcloud is a versatile and community-driven project, making it a popular choice for individuals, businesses, and organizations looking for a secure and self-hosted cloud storage and collaboration solution.

It is similar in functionality to popular cloud storage services like Dropbox, Google Drive, and Microsoft OneDrive but gives users greater control over their data and privacy because it can be deployed on their own servers or a cloud infrastructure of their choice.

In this tutorial, we will show you how to install Nextcloud 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: 1280 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1281 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1304 (nginx)
      Tasks: 2 (limit: 2273)
     Memory: 1.7M
        CPU: 23ms
     CGroup: /system.slice/nginx.service
             ├─1304 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─1307 "nginx: worker process"

Step 3: Install PHP and PHP extensions for Nextcloud

To install PHP and the necessary extensions, run the following command:

# apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-intl php-curl php-xml php-mbstring php-bcmath php-gmp

Once the installation is complete 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

To install the MariaDB database server, 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: 14433 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 2273)
     Memory: 163.8M
        CPU: 513ms
     CGroup: /system.slice/mariadb.service
             └─14433 /usr/sbin/mariadbd

Once the installation is complete, run the following command to secure your MariaDB server:

# 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

Restart the database server for the changes to take effect.

# systemctl restart mariadb

Step 5: Create a New Database for Nextcloud

Once you have installed MariaDB, you’ll need to create a new database and user for Nextcloud to use.

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

# mysql -u root -p

You will be prompted to enter your root password. Once you have entered your password, you will be taken to the MariaDB prompt.

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

MariaDB [(none)]> CREATE DATABASE nextcloud;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'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 and Install Nextcloud

You can download the latest version of Nextcloud from the Nextcloud Official site.

Use the following command to download the latest version of Nextcloud:

# wget  https://download.nextcloud.com/server/releases/latest.zip

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

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

Change ownership of the /var/www/nextcloud directory to www-data.

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

Step 7: Configure Nginx for Nextcloud

Run the commands below to create a new VirtualHost file called nextcloud in the /etc/nginx/conf.d/ directory.

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

Paste the content as shown below:

server {
  listen 80;
  server_name your-domain.com www.your-domain.com;
  root /var/www/nextcloud;
  index index.php index.html;
  charset utf-8;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  location ~ .php$ {
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

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

Save and exit the configuration file.

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Step 8: 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-nginx

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

# certbot --nginx -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/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain.com/privkey.pem
   Your cert will expire on 2023-12-03. 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 9: Access Nextcloud Web Interface

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

Click the Install button, you will see the Web interface of NextCloud.

Comments and Conclusion

That’s it. You have successfully installed NextCloud on Debian 12 OS.

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

If you have any questions please leave a comment below.

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 Craft CMS on Debian 12

Craft CMS is a popular content management system (CMS) that allows users to create and manage websites and digital experiences. It is known for its flexibility, powerful features, and user-friendly interface. Craft CMS is developed by Pixel & Tonic, a software development company.

In terms of performance and scalability, Craft CMS is designed to handle websites of all sizes, from small blogs to large enterprise solutions. It utilizes a modern technology stack and provides caching mechanisms to optimize page loading times.

The Craft Plugin Store offers a wide range of plugins for various purposes, such as e-commerce, SEO optimization, analytics, and integrations with third-party services.

In this tutorial, we will guide you through the process of installing Craft CMS on Debian 12 OS.

Step 1: Update Operating System

The first step is to ensure that your system is up-to-date. You can do this by running the following command:

# apt update && sudo apt upgrade

Also, install necessary packages.

# apt install sudo nano wget unzip zip

Now create a new non-root user account with sudo privileges and switch to it.

# /usr/sbin/adduser craftcms

# /usr/sbin/usermod -aG sudo craftcms

# su - craftcms

NOTE: You can replace craftcms with your username.

Step 2: Install Nginx Web Server

Craft CMS requires a web server to run, and we will be using the Nginx web server in this tutorial. To install Nginx, run the following command:

$ sudo apt install nginx

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

$ sudo systemctl start nginx
$ sudo systemctl enable nginx

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

$ sudo systemctl status nginx

Step 3: Install PHP and PHP extensions for Craft CMS

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

$ sudo apt install php php-cli php-common php-json php-gmp php-fpm php-xmlrpc php-bcmath php-imagick 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:

$ sudo 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
date.timezone = America/Chicago

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

$ sudo systemctl restart php8.2-fpm

Step 4: Install Composer dependency manager

To install Composer, run the following commands:

$ sudo curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

Verify that Composer has been installed successfully by running the following command:

$ composer --version
Composer version 2.5.8 2023-06-09 17:13:21

Step 5: Install MariaDB database server

To install the MariaDB database server, run the following command:

$ sudo apt install mariadb-server mariadb-client

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

$ sudo systemctl status mariadb

Step 6: Create a New Database for Craft CMS

Once you have installed MariaDB, you’ll need to create a new database and user for Craft CMS to use.

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

$ sudo mysql -u root

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

MariaDB [(none)]> CREATE DATABASE craftcms;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON craftcms.* TO 'craft'@'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 7: Download and Install Craft CMS

Create a new directory for your Craft CMS installation using the following command:

$ sudo mkdir /var/www/craftcms

Change ownership of the /var/www/craft directory to the craftcmsuser.

$ sudo chown -R craftcms:craftcms /var/www/craftcms

Then download the latest stable release of Craft CMS from the command line:

$ cd /var/www/craftcms
$ composer create-project craftcms/craft .

You will be asked to provide database details, admin username, password, site URL as shown below:

Are you ready to begin the setup? (yes|no) [no]:yes
Which database driver are you using? (mysql or pgsql) [mysql] mysql
Database server name or IP address: [127.0.0.1] 127.0.0.1
Database port: [3306] 3306
Database username: [root] craft
Database password: password
Database name: craftcms
Database table prefix:
Install Craft now? (yes|no) [yes]:yes

Username: [admin] admin
Email: admin@your-domain.com
Password:
Confirm:
Site name: Your Website
Site URL: http://your-domain.com
Site language: [en-US] 

Change ownership of the /var/www/craftcms directory to www-data.

$ sudo chown -R www-data:www-data /var/www/craftcms

Step 8: Configure Nginx for Craft CMS

Run the commands below to create a new VirtualHost file called craftcms in the /etc/nginx/conf.d/ directory.

$ sudo nano /etc/nginx/conf.d/craftcms.conf

Paste the content as shown below:

server {

  listen 80;

  server_name your-domain.com www.your-domain.com;
  root /var/www/craftcms/web;
  index index.html index.htm index.php;
  charset utf-8;

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

  location ~ [^/]\.php(/|$) {
    try_files $uri $uri/ /index.php?$query_string;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTP_PROXY "";
  }
}

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

Save and exit the configuration file.

To implement the changes, restart Nginx webserver:

$ sudo systemctl restart nginx

Step 9: Access Craft CMS Web Interface

Open your web browser and type the URL http://your-domain.com. You should see the welcome screen:

To access Craft’s administrative interface type the URL http://your-domain.com/admin you should see the login page:

Provide your admin credential and click on the Sign in button, you should see the Craft CMS dashboard in the following page:

Comments and Conclusion

Congratulations! You have successfully installed Craft CMS with Nginx on Debian 12 OS. You can now create your own website easily using Craft CMS.

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