Add the server Block

sudo nano /etc/nginx/sites-available/your_domain

Add the following configuration block, which is similar to the default, but updated for your new directory and domain name:


server {
        listen 80;
        listen [::]:80;

        root /var/www/your_domain/html;
        index index.html index.htm index.nginx-debian.html;

        server_name your_domain www.your_domain;

        location / {
                try_files $uri $uri/ =404;
        }
}

Enable this server block by creating a symbolic link to your custom configuration file inside the sites-enabled directory, which Nginx reads from during startup:

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled

Mysql import error was shown when exporting a database from cPanel to a local server.

During the migration of a web application, I got the below error while restoring a database on another server. The collation id may differ based on the MySQL version.

Error message:

mysql backup.sql < backup.sql
ERROR 1253 (42000) at line 31: COLLATION 'utf8mb4_unicode_ci' is not valid for CHARACTER SET 'utf8'

The MySQL server running on the new server is an older version than the source server. The destination server doesn’t contain the required database collation.

To resolve, edit the database backup file in text editor and replace “utf8mb4_0900_ai_ci” with “utf8mb4_general_ci” and “CHARSET=utf8mb4” with “CHARSET=utf8“.

Replace the below string:

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

with:

ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Save your file and restore the database.

The Linux system users can use the sed command to replace text in files directly.

sed -i 's/utf8mb4_0900_ai_ci/utf8_general_ci/g' backup.sql  
sed -i 's/CHARSET=utf8mb4/CHARSET=utf8/g' backup.sql  

That it. after the above changes, the database was successfully restored!

Here are the different apps in linux for compressing and archiving files.

Definitions:

Tarball: A tarball is a collection of multiple files in Linux stored as a single file. The term tarball comes from the coal-based sealant used during construction works. A tarball is often simply called a TAR file, which stands for Tape Archive. This is because the TAR filetype was originally created to store data in magnetic tapes.

Gzip: GNU gzip is a file compression algorithm used to compress files. The file extension for gzip is GZ and therefore, you can deduce that any file ending with GZ has been compressed using the gzip algorithm.

TAR.GZ: A TAR.GZ file is a version of a tarball compressed with the gzip algorithm. TAR is the file extension for tarballs, whereas GZ denotes gzip. The TGZ file extension is also used sometimes instead of TAR.GZ.

Bzip2: Similar to gzip, several other file compression algorithms are also available, including bzip2. When you compress a TAR file using bzip2, the output file will have either of the following extensions: TAR.BZ2, TAR.BZ, or simply TBZ.

How to Create TAR and TAR.GZ Files

Using the tar Utility
The basic syntax to create compressed tarballs using the tar command is:

$ sudo tar -cvzf archive filename
$ sudo tar -cvzf archive directory

Note that you need to pass the file extension (TAR or TAR.GZ) in the archive name as follows:

$ sudo tar -cvzf new.tar.gz big-file.txt
$ sudo tar -cvf new.tar big-file.txt

To archive and compress the /Documents directory using tar:

$ sudo tar -cvzf new.tar.gz ~/Documents

You can also compress multiple directories and files by creating a single tarball. To do so:

$ sudo tar -cvzf new.tar.gz ~/Documents ~/Downloads file1.txt file2.txt