Tag Archives: PHP

PHP 8.4 on Ubuntu 24.04

How to Install PHP 8.4 on Ubuntu 24.04

PHP (Hypertext Preprocessor) is a widely-used, open-source, server-side scripting language designed for web development. It is especially suited for creating dynamic web pages and applications.

In this tutorial, we will show you how to install PHP 8.4 on a Ubuntu 24.04 OS.

Update Operating System

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

# apt update && apt upgrade

Add PHP Repository

By default, PHP 8.4 is not included in the Ubuntu 24.04 default repository.  So you will need to add Ondrej Sury PPA into your system.

First, install the required packages using the following command:

# apt-get install ca-certificates apt-transport-https software-properties-common

Once all the packages are installed, add this PPA using the following command:

# add-apt-repository ppa:ondrej/php

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

# apt-get update

Install PHP 8.4

Now, you can install the PHP 8.4 using the following command:

# apt-get install php8.4

Once the PHP is installed, you can check the PHP version on your system with the following command:

# php8.4 --version

Output:

# PHP 8.4.1 (cli) (built: Nov 21 2024 14:54:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.1, Copyright (c), by Zend Technologies

Install PHP 8.4 for Apache

To install PHP as an Apache module, execute:

# apt install libapache2-mod-php8.4

Then, restart Apache to integrate the new PHP module:

# systemctl restart apache2

To verify that PHP is working with the Apache web server, you can create a test PHP file:

echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php

Then open your web browser and type http://your-IP-address/info.php and you should see the PHP information page.

Install PHP 8.4 FPM for Nginx

For the Nginx web server, you need to install the FPM service, you can install it using the following command:

# apt install php8.4-fpm

Once the installation has been completed, you can confirm that the PHP-FPM service has been installed correctly with the following command:

# systemctl status php8.4-fpm

Output:

● php8.4-fpm.service - The PHP 8.4 FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php8.4-fpm.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:php-fpm8.4(8)
    Process: 11741 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.4/fpm/pool.d/www.conf 84 (code=exited, status=0/SUCCESS)
   Main PID: 11737 (php-fpm8.4)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00req/sec"
      Tasks: 3 (limit: 2218)
     Memory: 8.0M (peak: 9.0M)
        CPU: 116ms
     CGroup: /system.slice/php8.4-fpm.service
             ├─11737 "php-fpm: master process (/etc/php/8.4/fpm/php-fpm.conf)"
             ├─11739 "php-fpm: pool www"
             └─11740 "php-fpm: pool www"

Test PHP and PHP-FPM

To configure Nginx to use PHP-FPM, you need to edit the default Nginx configuration file:

# nano /etc/nginx/sites-available/default

Add the following configurations to the file.

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

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

Then create a test PHP file similar to the Apache setup:

echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php

To implement the changes, restart Nginx webserver:

# systemctl restart nginx

Then open your web browser and type http://your-IP-address/info.php and you should see the PHP information page.

Install PHP Extension

Installing PHP extensions are simple with the below-mentioned syntax:

# sudo apt install php8.4-[extension]

Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces:

# apt install php8.4-mysql php8.4-imap php8.4-ldap php8.4-xml php8.4-curl php8.4-mbstring php8.4-zip

To check loaded PHP modules use the command:

# php8.4 -m

Example Output:

[PHP Modules]
..............
imap
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
..............

[Zend Modules]
Zend OPcache

Running PHP 8.4 with Other Versions

Instead of removing old PHP versions, it is also possible to run multiple PHP versions side-by-side.

The update-alternatives command provides an easy way to switch between PHP versions for PHP CLI.

# update-alternatives --config php

This brings up a prompt to interactively select the alternative PHP binary path that php points to.

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php.default   100       auto mode
  1            /usr/bin/php.default   100       manual mode
  2            /usr/bin/php8.3        83        manual mode
  3            /usr/bin/php8.4        84        manual mode

To set the path without the interactive prompt:

# update-alternatives --set php /usr/bin/php8.4

Comments and Conclusion

In the tutorial, you have learned how to install PHP 8.4 on Ubuntu 24.04.

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

If you have any questions please leave a comment below.

How to Install Drupal on Ubuntu 24.04

Drupal is an open-source content management system (CMS) used for building and managing websites and web applications. It is highly flexible and customizable, making it suitable for a wide range of web projects, from simple blogs to complex enterprise websites.

It is used by a wide range of organizations, including educational institutions, non-profits, businesses, and government agencies, to build websites that require robust content management, high security, and flexibility.

In this tutorial, we will show you how to install Drupal on your Ubuntu 24.04 OS.

Step 1: Update Operating System

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

# apt update && apt upgrade -y

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 (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
   Main PID: 10412 (nginx)
      Tasks: 2 (limit: 2218)
     Memory: 1.7M (peak: 1.9M)
        CPU: 23ms
     CGroup: /system.slice/nginx.service
             ├─10412 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─10413 "nginx: worker process"

Step 3: Install PHP and PHP extensions for Drupal

By default, Ubuntu 24.04 comes with PHP version 8.3.  You can install PHP and other supporting packages using the following command:

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

Verify if PHP is installed.

php -v
Output:
PHP 8.3.6 (cli) (built: Jun 13 2024 15:23:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, 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 (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running)
    Process: 24565 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 24574 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2218)
     Memory: 362.8M (peak: 379.1M)
        CPU: 1.160s
     CGroup: /system.slice/mysql.service
             └─24574 /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 Drupal installation:

mysql> CREATE DATABASE drupaldb;
mysql> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'Str0ngP@ss';
mysql> GRANT ALL PRIVILEGES ON drupaldb. * TO 'drupaluser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download Drupal

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

# wget https://ftp.drupal.org/files/projects/drupal-11.0.0.zip

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

# unzip drupal-11.0.0.zip -d /var/www/

Rename it to make it simpler:

# mv /var/www/drupal-11.0.0/ /var/www/drupal

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

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

Step 6: Configure Nginx for Drupal

Create a new Nginx virtual host configuration file:

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

Paste the content as shown below:

server {
  listen 80;
  server_name your-domain.com www.your-domain.com;
  root /var/www/drupal;
  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.3-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 7: Access Drupal Web Interface

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

Choose your preferred language and hit Save and continue. You will get the following screen:

Choose Standard and hit Save and continue.

Fill in your database settings and hit Save and continue.

Then fill in some basic information about your site and then hit Save and continue.

You will get the dashboard in the following screen:

Installation of Drupal has been completed. Now revert the permissions for the settings.php file:

# chmod 644 /var/www/html/drupal/sites/default/settings.php

Comments and Conclusion

That’s it. You have successfully installed Drupal on Ubuntu 24.04 OS.

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

If you have any questions please leave a comment below.

How to Install Magento 2.4.7 on Ubuntu 24.04

Magento is an open-source e-commerce platform that provides online merchants with a flexible shopping cart system, as well as control over the look, content, and functionality of their online stores. It also has a large community of developers and users who contribute to its ongoing development and provide support through forums, documentation, and other resources.

Magento comes in two main editions: Magento Open Source (formerly known as Magento Community Edition) and Magento Commerce (formerly known as Magento Enterprise Edition). The Open Source edition is free to use and provides basic e-commerce functionality, while the Commerce edition is a paid version that includes more advanced features such as customer segmentation, targeted promotions, and advanced marketing tools.

In this tutorial we will show you how to install the Open Source version of Magento 2.4.7 on Ubuntu 24.04 OS.

Before starting the installation, you can check the system requirement for installing Magento 2.4.7.

Step 1: Update Operating System

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

# apt update && apt upgrade

Step 2: Install Apache web server

To install Apache web server, 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 (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running)
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 22413 (apache2)
      Tasks: 6 (limit: 2130)
     Memory: 16.8M (peak: 17.0M)
        CPU: 658ms
     CGroup: /system.slice/apache2.service
             ├─22413 /usr/sbin/apache2 -k start
             ├─22468 /usr/sbin/apache2 -k start
             ├─22469 /usr/sbin/apache2 -k start
             ├─22470 /usr/sbin/apache2 -k start

Step 3: Install PHP and PHP extensions

Magento 2.4.7 comes with support for the latest PHP 8.3, while PHP 8.2 remains fully supported. By default, PHP 8.3 is included in the Ubuntu 24.04 default repository.

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

# apt install php php-exif php-bz2 php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml

Verify if PHP is installed.

php -v
Output:
PHP 8.3.0-1ubuntu1 (cli) (built: Jan 19 2024 14:00:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0-1ubuntu1, Copyright (c), by Zend Technologies

Update php.ini file

Now it’s time to increase values in the php.ini file.

Open php.ini file:

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

Change the following data:

short_open_tag = On
memory_limit = 512M
upload_max_filesize = 128M
max_execution_time = 3600

Then save this php.ini file.

After that, you should restart the Apache web server for the configuration 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

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

# systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running)
    Process: 2907 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2919 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 2130)
     Memory: 362.8M (peak: 379.2M)
        CPU: 1.737s
     CGroup: /system.slice/mysql.service
             └─2919 /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 to create a database, database user, and grant all privileges to the database user run the following commands:

mysql> CREATE DATABASE magentodb;
mysql> CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'Str0ngPa$$w0rd';
mysql> GRANT ALL ON magentodb.* TO 'magentouser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Step 5: Installing Elasticsearch

Starting Magento 2.4, all installations must be configured to use Elasticsearch as the catalog search engine.

Import the Elasticsearch GPG key:

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

Add the Elasticsearch repository:

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

Update the apt package manager and install Elasticsearch:

# apt update && apt install elasticsearch

Then start and enable the service:

# systemctl start elasticsearch
# systemctl enable elasticsearch

Open the elasticsearch.yml file:

# nano  /etc/elasticsearch/elasticsearch.yml

Then uncomment the lines and update the values:

node.name: "ubuntu"
cluster.name: magento 2.4.7
network.host: 127.0.0.1
http.port: 9200
xpack.security.enabled: false

After that, you should restart elasticsearch service for the configuration to take effect:

# systemctl restart elasticsearch

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

# curl -X GET "localhost:9200/"

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

{
  "name" : "ubuntu",
  "cluster_name" : "magento 2.4.7",
  "cluster_uuid" : "nKzTibHRT_ahq6lCsWk6Ew",
  "version" : {
    "number" : "8.13.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "9287f29bba5e270bd51d557b8daccb7d118ba247",
    "build_date" : "2024-03-29T10:05:29.787251984Z",
    "build_snapshot" : false,
    "lucene_version" : "9.10.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Step 6: Install Composer

To download Composer, run the following command:

# curl -sS https://getcomposer.org/installer | php

Next, move the composer file to the /usr/local/bin path:

# mv composer.phar  /usr/local/bin/composer
# chmod +x   /usr/local/bin/composer

Verify the Composer version installed:

# composer --version

Output:
Composer version 2.7.2 2024-03-11 17:12:18

Step 7: Install Magento 2.4.7

For most situation it is recommended to install Magento using the Marketplace by creating access key.

To get the access keys, you should create an account in the Magento marketplace.

Then for generating access keys go to:

My profile > Marketplace > My products > Access Keys

Once access keys are generated run the following  command to download Magento 2.4.7:

# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.7 /var/www/magento2

Username : Your Public Key
Password : Your Private Key

Navigate to the Magento directory:

# cd /var/www/magento2

Chmod cache and static content folder:

# find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +

Change the ownership of the magento2 directory to the webserver user and also the permissions:

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

Now, install Magento using the composer command, type:

# bin/magento setup:install \
--base-url=http://your-domain.com \
--db-host=localhost \
--db-name=magentodb \
--db-user=magentouser \
--db-password='Str0ngPa$$w0rd' \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@your-domain.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

After the installation process you will see the admin link for your Magento site.

[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_nuqh2y
Nothing to import.

Step 8: Configure Apache for Magento 2.4.7

Run the command below to create a new VirtualHost file in the /etc/apache2/sites-available/ directory:

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

Paste the content as shown below:

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

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

Next run the following command to enable rewrite module:

# a2enmod rewrite

To enable this site run the command:

# a2ensite magento2.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 9: Access your Magento 2.4.7 Application

Open your browser and type your domain http://your-domain.com

Comments and Conclusion

That’s it. You have successfully installed Open Source version of Magento 2.4.7 on Ubuntu 24.04.

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

If you have any questions please leave a comment below.

How to Install Laravel on Debian 12

Laravel is a free, open-source PHP web application framework used for web development. It follows the Model-View-Controller (MVC) architectural pattern and provides an elegant syntax and tools for tasks such as routing, templating, authentication, and more. Laravel aims to make web development tasks more enjoyable and efficient by providing a clean and expressive syntax, along with a set of conventions and tools for common tasks.

Laravel has gained popularity in the PHP development community due to its elegant syntax, developer-friendly features, and active community. It is widely used for building web applications, APIs, and various other web-based projects.

In this tutorial, we will show you how to install Laravel on Debian 12 OS with Nginx web server and MariaDB database server.

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

Also, install necessary packages.

# apt install sudo nano wget unzip zip

Step 2: Install Nginx Web Server

To install Nginx web server, 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

Step 3: Install PHP and PHP extensions

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

# 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:

# 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:

# systemctl restart php8.2-fpm

Step 4: Install MariaDB and create a database

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

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

# mysql -u root

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

MariaDB [(none)]> CREATE DATABASE laravel_db;
MariaDB [(none)]> CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'Str0ngPa$$word';
MariaDB [(none)]> GRANT ALL ON laravel_db.* TO 'laravel_user'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

Step 5: Install Composer dependency manager

To install Composer, run the following commands:

# curl -sS https://getcomposer.org/installer | php
# 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 6: Install Laravel 

Navigate to the webroot directory, type:

# cd /var/www/html

Now, install Laravel using the composer command, type:

# composer create-project laravel/laravel laravelapp

The command creates a new directory called laravelapp and installs all the files and directories for Laravel.

Change the ownership of the Laravel directory to the webserver user and also the permissions:

# chown -R www-data:www-data /var/www/html/laravelapp
# chmod -R 775 /var/www/html/laravelapp/storage

Once the installation is done navigate to the installation directory and check the Laravel version:

# cd laravelapp
# php artisan

Step 7: Configure Nginx Web Server for Laravel

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

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

Add the following content:

server {
    listen 80;
    listen [::]:80;
    server_name your-domain.com;
    root /var/www/html/laravelapp/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Save the file and Exit.

Check Nginx syntax:

# /usr/sbin/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 8: Access your Laravel Application

Open your browser and type your domain e.g http://your-domain.com

Comments and Conclusion

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

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

If you have any questions please leave a comment below.

How to Install Dolibarr ERP on Debian 12

Dolibarr ERP is an open-source software suite designed to help businesses and organizations manage various aspects of their operations. It provides modules for a wide range of business functions, making it a comprehensive solution for small and medium-sized enterprises (SMEs). Dolibarr is written in PHP and is often used as a web application, making it accessible from different devices with a web browser.

Dolibarr ERP is suitable for a variety of businesses, particularly those in the SME sector. It provides a cost-effective solution for managing key business processes and can be adapted to different industries and sectors. As an open-source solution, it offers flexibility and the ability to tailor the system to specific organizational needs.

In this tutorial, we will show you how to install Dolibarr ERP 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

Also, install necessary packages.

# apt install curl nano wget unzip zip

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: 13773 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 13777 (apache2)
      Tasks: 7 (limit: 2273)
     Memory: 37.4M
        CPU: 494ms
     CGroup: /system.slice/apache2.service
             ├─13777 /usr/sbin/apache2 -k start
             ├─13778 /usr/sbin/apache2 -k start
             ├─13779 /usr/sbin/apache2 -k start
             ├─13780 /usr/sbin/apache2 -k start

Step 3: Install PHP and required extensions

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

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

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 = 512M
post_max_size = 32M
upload_max_filesize = 32M
date.timezone = America/Chicago

Restart the Apache service to apply the changes:

# systemctl restart apache2

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

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

# systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.11.6 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: 10002 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 2273)
     Memory: 242.0M
        CPU: 1.918s
     CGroup: /system.slice/mariadb.service
             └─10002 /usr/sbin/mariadbd

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

# mysql -u root

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

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

Step 5: Download Dolibarr

The latest version of Dolibarr is available to download from GitHub. You can download it with the following command:

# wget https://github.com/Dolibarr/dolibarr/archive/refs/tags/19.0.0.zip

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

# unzip 19.0.0.zip -d /var/www/
# mkdir /var/www/dolibarr
# mv /var/www/dolibarr-19.0.0/htdocs/* /var/www/dolibarr

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

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

Step 6: Configure Apache for Dolibarr

To create a new VirtualHost file run the following commands:

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

Paste the content as shown below:

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

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

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

 </VirtualHost>

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:

# /usr/sbin/a2ensite dolibarr.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 7: Access Dolibarr Web Interface

To complete the setup go to your browser and visit http://your-domain.com.

Select your language and click on the Next step button. You should see the following page:

Validate the PHP checks and click on the Start button. You should see the following page:

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

Installation successful, click on the Next step button.

Click on the Next step button.

Set a new admin username and password. Then, click on the Next step button.

Click on the Go to Dolibarr button and you should see the login page:

Provide your admin username and password. Then, click on the LOGIN button.

To finalize the installation and remove the installation warnings on the dashboard, run the following commands:

# touch /var/www/dolibarr/documents/install.lock
# chown root:root /var/www/dolibarr/conf/conf.php

Comments and Conclusion

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

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

If you have any questions please leave a comment below.

How to Install RainLoop on Debian 12

RainLoop is an open-source web-based email client that allows users to access their email accounts through a web browser. It provides a user-friendly interface for managing emails, contacts, and other related tasks without the need for a dedicated email client like Outlook or Thunderbird.

It is designed to be lightweight, fast, and easy to install, making it a popular choice for those who want a simple webmail solution.

In this tutorial, we will show you how to install RainLoop on Debian 12 OS with Nginx web server and MariaDB database server..

Step 1: Update Operating System

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

# apt update && apt upgrade

Also, install necessary packages.

# apt install curl nano wget unzip zip

Step 2: Install Nginx webserver

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

# apt install nginx

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

# systemctl status nginx

Step 3: Install PHP

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-imap php-mbstring php-curl php-xml

Once the installation is complete verify if PHP is installed:

php -v
Output:
PHP 8.2.12 (cli) (built: Oct 27 2023 13:00:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.12, 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 = 25M
upload_max_filesize = 25M

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

# systemctl restart php8.2-fpm

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

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

# systemctl status mariadb

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

mysql> CREATE DATABASE rainloop;
mysql> CREATE USER 'rainloopuser'@'localhost' IDENTIFIED BY 'Str0ngPa$$word';
mysql> GRANT ALL PRIVILEGES ON rainloop . * TO 'rainloopuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit;

Step 5: Download RainLoop

You can download the latest stable release version for RainLoop with the following command:

# https://www.rainloop.net/repository/webmail/rainloop-latest.zip

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

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

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

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

Step 6: Configure Nginx for RainLoop

Then, create an virtual host configuration file:

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

Add the following lines:

server {

listen 80;

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

   index index.php;

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

location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_keep_conn on;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

location ^~ /data {
        deny all;
    }

}

Save and exit the configuration file.

Check Nginx syntax:

# /usr/sbin/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: 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 webmail.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/webmail.your-domain.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/webmail.your-domain.com/privkey.pem
   Your cert will expire on 2024-03-06. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

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

Now, you have successfully installed SSL on your website.

Step 8: RainLoop Setup and Configurations

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

You can log in with the default username admin and default password 12345

You will see the Rainloop dashboard as below:

When you login for the first time, you need to change your admin password immediately.

Enter your new password and click on the Update Password button to change the password.

Then, open the Contacts menu and select MySQL from the dropdown menu:

Enter the database credentials you created earlier and press the Test button to check the connection and install the necessary tables.

If the button turns green, it means the connection is successful.

Comments and Conclusion

Congratulations. You have learned how to install RainLoop on Debian 12 OS.

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

How to Install MediaWiki on Debian 12

MediaWiki is a free and open-source wiki software platform used to power various wikis, including the most well-known one, Wikipedia.

MediaWiki is written in PHP and uses a backend database (usually MySQL or MariaDB) to store the content. It provides a powerful platform for creating collaborative websites, knowledge bases, documentation systems, and more.

In this tutorial, we will show you how to install MediaWiki 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

Also, install necessary packages.

# apt install curl nano wget unzip zip

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: 24002 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 24006 (apache2)
      Tasks: 6 (limit: 2273)
     Memory: 23.4M
        CPU: 13.701s
     CGroup: /system.slice/apache2.service
             ├─24006 /usr/sbin/apache2 -k start
             ├─24206 /usr/sbin/apache2 -k start
             ├─24207 /usr/sbin/apache2 -k start
             ├─24208 /usr/sbin/apache2 -k start

Step 3: Install PHP and required extensions

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

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

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

Step 4: Install MariaDB and create a database

To install MariaDB run the following command:

# apt install mariadb-server mariadb-client

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

# systemctl status mariadb

Output:

● mariadb.service - MariaDB 10.11.4 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: 24964 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 2273)
     Memory: 87.9M
        CPU: 4.312s
     CGroup: /system.slice/mariadb.service
             └─24964 /usr/sbin/mariadbd

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

# mysql -u root

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

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

Step 5: Install Composer dependency manager

To install Composer, run the following commands:

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

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

# composer --version
Composer version 2.6.6 2023-12-08 18:32:26

Step 6: Download MediaWiki

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

# wget https://releases.wikimedia.org/mediawiki/1.40/mediawiki-1.40.1.zip

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

# unzip mediawiki-1.40.1.zip -d /var/www/

Rename it to make it simpler:

# mv /var/www/mediawiki-1.40.1/ /var/www/mediawiki

Now, install all PHP dependencies using the following command:

# cd /var/www/mediawiki && composer install --no-dev

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

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

Step 7: Configure Apache for MediaWiki

To create a new VirtualHost file run the following commands:

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

Paste the content as shown below:

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

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

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

 </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:

# /usr/sbin/a2ensite mediawiki.conf

To implement the changes, restart Apache webserver:

# systemctl restart apache2

Step 8: Access MediaWiki Web Interface

To complete the setup go to your browser and visit http://your-domain.com.

Start the setup clicking on the link to “set up the wiki”.

Choose language and click on the Continue button.

If everything is OK, you will get the message “The environment has been checked. You can install MediaWiki”. Click “Continue” to advance to the next step.

Add the database information such as the Database name, username, and password that you have created in the previous step.

Click on the Continue button.

Provide your website name, admin username, password and click on the Continue button.

Click on the “Continue” button.

Click on the “Continue” button. and the system will generate a “LocalSettings.php” that contains all the configuration you have done.

Copy the file to the /var/www//mediawiki directory. Then, set the correct ownership using the following command:

# chown www-data:www-data /var/www/mediawiki/LocalSettings.php

Once you have completed this last step you will be redirected to the MediaWiki dashboard:

Comments and Conclusion

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

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

If you have any questions please leave a comment below.

How to Install PHP 8.3 on Ubuntu 22.04

PHP, which stands for “Hypertext Preprocessor,” is a server-side scripting language widely used for web development. PHP is often used to create dynamic web pages, handle forms, interact with databases, and perform various server-side tasks.

It has been a popular choice for web development for many years, and despite the emergence of other languages and frameworks, it continues to be widely used in the industry.

In this tutorial, we will show you how to install PHP 8.3 on a Ubuntu 22.04 OS.

Update Operating System

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

# apt update && apt upgrade

Add PHP Repository

By default, PHP 8.3 is not included in the Ubuntu 22.04 default repository.  So you will need to add Ondrej Sury PPA into your system.

First, install the required packages using the following command:

# apt-get install ca-certificates apt-transport-https software-properties-common

Once all the packages are installed, add this PPA using the following command:

# add-apt-repository ppa:ondrej/php

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

# apt-get update

Install PHP 8.3

Now, you can install the PHP 8.3 using the following command:

# apt-get install php8.3

Once the PHP is installed, you can check the PHP version on your system with the following command:

# php8.3 --version

Output:

# PHP 8.3.0 (cli) (built: Nov 24 2023 08:50:08) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies

Install PHP 8.3 for Apache

To install PHP as an Apache module, execute:

# apt install libapache2-mod-php8.3

Then, restart Apache to integrate the new PHP module:

# systemctl restart apache2

Install PHP 8.3 FPM for Nginx

For the Nginx web server, you need to install the FPM service, you can install it using the following command:

# apt install php8.3-fpm

Once the installation has been completed, you can confirm that the PHP-FPM service has been installed correctly with the following command:

# systemctl status php8.3-fpm

Output:

● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.3-fpm.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:php-fpm8.3(8)
    Process: 58796 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.3/fpm/pool.d/www.conf 83 (code=exited, status=0>
   Main PID: 58793 (php-fpm8.3)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 2178)
     Memory: 7.5M
        CPU: 34ms
     CGroup: /system.slice/php8.3-fpm.service
             ├─58793 "php-fpm: master process (/etc/php/8.3/fpm/php-fpm.conf)
├─58794 php-fpm: pool www
└─58795 php-fpm: pool www

Install PHP Extension

Installing PHP extensions are simple with the below-mentioned syntax:

# sudo apt install php8.3-[extension]

Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces:

# apt install php8.3-mysql php8.3-imap php8.3-ldap php8.3-xml php8.3-curl php8.3-mbstring php8.3-zip

To check loaded PHP modules use the command:

# php8.3 -m

Example Output:

[PHP Modules]
..............
fileinfo
filter
ftp
gettext
hash
iconv
imap
json
ldap
libxml
mbstring
mysqli
mysqlnd
..............

[Zend Modules]
Zend OPcache

Running PHP 8.3 with Other Versions

Instead of removing old PHP versions, it is also possible to run multiple PHP versions side-by-side.

The update-alternatives command provides an easy way to switch between PHP versions for PHP CLI.

# update-alternatives --config php

This brings up a prompt to interactively select the alternative PHP binary path that php points to.

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.3   81        auto mode
  1            /usr/bin/php8.1   81        manual mode
  2            /usr/bin/php8.3   83        manual mode

To set the path without the interactive prompt:

# update-alternatives --set php /usr/bin/php8.1

Comments and Conclusion

In the tutorial, you have learned how to install PHP 8.3 on Ubuntu 22.04.

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

If you have any questions please leave a comment below.