Terminate a process from linux terminal by name - ssh

Let’s say we want to end the process ssh in another terminal because the connection is frozen due to network disconnect.
To do this, we need to identify the id of the ssh process, and end the process.
We will use:

  • pipes (|) to redirect the output of one program to the next.
  • ps ax to list all processes in all terminals
  • grep to search for the ssh text in the output of the ps command
  • awk to print the first word {print $1} of the first line NR==1
  • kill command to end the process identified in the awk line

To explain the concept of pipes (|): we execute ps ax to list all processes, and with the | we pass the resulting output to the grep command, which searched for the word ssh:

Using PHP and MySQL to build web pages

Before we begin, let’s allow the user george to connect to MySQL/MariaDB from any host, including the server that hosts php and the web server.
We will use % to allow connection from all hosts:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON `publications`.* TO "george"@"%";
Query OK, 0 rows affected (0.010 sec)

We will be creating the login.php file which we will be using in other phpfiles.
This code will help us connect to the MySQL database with the user and password, and the publications database will be selected.
This code is visible and executed only by the server, it is not visible by the web browser.

MySQL database tutorial

In this article we will work with MySQL databases - creation, adding records, etc..
To connect to a MySQL /MariaDB instance:

# mariadb -u user -p'user_password'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 11.7.2-MariaDB-ubu2404 mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

To show current user’s rights/grants:

Use ZIP and SCP to archive and copy files remotely

We have a folder that we want to archive into a .zip file and copy it to a linux server via scp (secure copy, which uses the ssh protocol).
Let’s add the files to a zip archive first, we can use the zip utility with the -r parameter to recursively add all files (*) in the current folder and subfolders:

$ zip docker-1.zip -r *
  adding: compose.yml (deflated 66%)
  adding: config.inc.php (deflated 63%)
  adding: docker-compose.yml-old (deflated 57%)
  adding: Dockerfile.mariadb (deflated 19%)
  adding: Dockerfile.nginx (deflated 18%)
  adding: Dockerfile.php (deflated 30%)
  adding: Dockerfile.phpmyadmin (deflated 24%)
  adding: Dockerfile.php-old (deflated 30%)
  adding: html/ (stored 0%)
  adding: html/index.php (stored 0%)
  adding: html/test.php (deflated 4%)
  adding: html/mariadb.php (deflated 50%)
  adding: html/404.html (stored 0%)
  adding: nginx.conf (deflated 48%)

We can then supply parameters to the scp command, to copy the resulting archive.
We use an alternate port via the -P parameter, and a ssh keypair with the -i parameter.

Docker containers - LAMP stack to host a site with SQL and PHP

Introduction
Example of a LAMP stack to host a website

Introduction

Docker is set of technogies that allows us to run applications. It uses images that are built according to docker-compose.yml. These images are deployed to containers, each including the software needed to run a web server, database, etc..

Dockerfile → (Build) → Image → (Run) → Container.

  • Dockerfile: contains a set of Docker instructions that installs and configures the software you specify.