How to Install Jenkins on Debian 10

How to Install Jenkins on Debian 10

In this Jenkins tutorial, you'll learn how to install and complete the initial configuration of Jenkins on Debian systems. how to install Jenkins on a Debian 10 Linux, Buster from the official Jenkins repository.

Jenkins is an open-source automation server that offers an easy way to set up a continuous integration and continuous delivery (CI/CD) pipeline.

Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. Continuous delivery (CD) is a series of practices where code changes are automatically built, tested, and deployed to production.

In this tutorial, we will cover how to install Jenkins on a Debian 10, Buster from the official Jenkins repository.

Installing Jenkins

Perform the following steps as root or user with sudo privileges to install Jenkins on Debian 10:

  1. Jenkins is written in Java, so the first step is to install Java. To do so, update the package index and install the OpenJDK 11 package with the following commands:

    sudo apt update
    sudo apt install default-jdk
    

Java LTS version 8 is not available in the official Debian Buster repositories.

  1. Use wget to download and import the Jenkins repository GPG keys:

    wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
    

The command should return OK, which means that the key has been successfully imported, and the packages from this repository will be considered trusted.

Run the following command to add the Jenkins repository to your system:

```
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
```
  1. Update the apt package list and install the latest version of Jenkins:

    sudo apt update
    sudo apt install jenkins
    
  2. Enable and start the Jenkins service by executing:

    sudo systemctl enable --now jenkins
    
Setting Up Jenkins

To start the setup process, open your browser and type your domain or IP address, followed by port 8080, http://your_ip_or_domain:8080.

A screen similar to the following will be displayed:

During the installation, the Jenkins installer creates an initial 32-character long alphanumeric password. To find the password type:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

5a541fac8f094f8db4155e11117f927a

Copy the password, paste it into the Administrator password field, and click Continue.

On the next screen, the setup wizard will ask you whether you want to install suggested plugins or you want to select specific plugins. Click on the Install suggested plugins box, and the installation process will start immediately.

Next, you will be prompted to set up the first admin user. Fill out the required information and click Save and Continue.

The next page will ask you to set the URL for your Jenkins instance. The field will be populated with an automatically generated URL.

Confirm the URL by clicking on the Save and Finish button, and the setup process will be completed.

Click on the Start using Jenkins button, and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.

At this point, you've successfully installed Jenkins on your system.

Conclusion

In this tutorial, you have learned how to install and complete the initial configuration of Jenkins on Debian systems. You can now visit the official Jenkins documentation page and start exploring Jenkins's workflow and plug-in model.

If you have any questions, please leave a comment below.

How to Install Docker Compose on Debian 10

How to Install Docker Compose on Debian 10

This Docker Compose tutorial explains how to Install Docker Compose on Debian 10. How to Install and Use Docker Compose on Debian 10 Linux. How to install the latest version of Docker Compose on Debian 10, Buster. Docker Compose is a tool that allows you to define and orchestrate multi-container Docker applications

Docker is a containerization platform that allows you to quickly build, test, and deploy applications as portable, self-sufficient containers that can run virtually anywhere.

Docker Compose is a tool that allows you to define and orchestrate multi-container Docker applications. It uses a YAML file to configure the application's containers, networks, and volumes.

Compose can be used for various purposes. Single host application deployments, automated testing, and local development are the most popular use cases for Docker Compose.

This tutorial explains how to install the latest version of Docker Compose on Debian 10, Buster. We'll also explore the basic Docker Compose concepts and commands.

Installing Docker Compose on Debian 10

The Docker Compose installation package is available in the official Debian 10 repositories, but it may not always be the latest version. The recommended approach is to install Docker Compose from the Docker's GitHub repository.

At the time of writing this article, the latest stable version of Docker Compose is version 1.23.1. Before downloading the Compose binary, visit the Compose repository release page on GitHub and check if there is a new version available for download.

Use the following steps to install the latest version of Docker Compose on Debian 10:

  1. Download the Docker Compose binary into the /usr/local/bin directory with wget or curl:

    sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    
  2. Use chmod to make the Compose binary executable:

    sudo chmod +x /usr/local/bin/docker-compose
    
  3. To verify the installation, use the following command which prints the Compose version:

    docker-compose --version
    

The output will look something like this:

```
docker-compose version 1.23.1, build b02f1306
```
Getting Started with Docker Compose

In this section, we will show how to set up a local WordPress development environment with Docker Compose.

Create a directory for the project and navigate into it

mkdir wordpress_app && cd wordpress_app

Open your text editor and create a file named docker-compose.yml:

nano docker-compose.yml

Paste the following content:

version: '3.7'

services:
  db:
    image: mysql:8.0
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - db_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress

  wordpress:
    image: wordpress
    restart: always
    volumes:
      - ./wp_data:/var/www/html
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: password
    depends_on:
       - db

volumes:
    db_data:
    wp_data:

Let's explain the code line by line

The first line specifies the Compose file version. There are several different versions of the Compose file format with support for specific Docker releases.

Next, we are defining two services, db and wordpress. Each service creates a separate container when Docker Compose is run.

The db service:

  • The image is set to mysql:8.0 image. If the image is not present, Compose will pull it from the Docker Hub public repository. The line starting with command overrides the default command.
  • The restart: always policy instructs Compose to restart the container if it goes down.
  • The container will use a named volume db_data to persist the database.
  • Defines the environment variables for the mysql:8.0 image.

The wordpress service:

  • Uses the wordpress image.
  • Mounts the wp_data directory on the host to /var/lib/mysql inside the container.
  • Forwards the exposed port 80 on the container to port 8080 on the host machine.
  • Defines the environment variables for the wordpress image.
  • The depends_on instruction defines the dependency between the two services. In this example, db will be started before wordpress.

From the project directory, start up the WordPress stack by running the following command:

docker-compose up

The output should look something like this:

...
] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
db_1_99946702ac7e | 2019-12-15T21:37:29.109255Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
...

Docker Compose will pull the images, start the containers, and create the wp_data directory in your project directory.

Enter http://0.0.0.0:8080/ in your browser, and you will see the standard WordPress installation screen.

At this point, the WordPress application is up and running, and you can start working on it.

To stop Compose press CTRL+C.

You can also start the Compose in a detached mode by using the -d option:

docker-compose up -d

To view the running docker containers use the following command:

docker-compose ps

                 Name                               Command               State          Ports        
------------------------------------------------------------------------------------------------------
wordpress_app_db_1_99946702ac7e          docker-entrypoint.sh --def ...   Up      3306/tcp, 33060/tcp 
wordpress_app_wordpress_1_a428d8408817   docker-entrypoint.sh apach ...   Up      0.0.0.0:8080->80/tcp 

To stop the services when Compose is running in detached mode, use:

docker-compose stop

If you want to remove the containers entirely use the down option:

docker-compose down

Passing the --volumes switch also remove the data volumes:

docker-compose down --volumes

Uninstalling Docker Compose

If you need to uninstall Docker Compose you can simply remove the binary by typing:

sudo rm /usr/local/bin/docker-compose

Conclusion

To install Docker Compose on a Debian 10, simply download the binary in a directory in the system path and make it executable.

If you have any questions, please leave a comment below.

Jenkins Tutorial | Learn Jenkins from Scratch | Jenkins Tutorial for Beginners

Learn Jenkins from scratch.

Learn Jenkins from scratch.

Jenkins is a Automation and CI Tool. It is a java application and very easy to learn.

How to Install PHP on Debian 10 (Linux)

How to Install PHP on Debian 10 (Linux)

In this post, we will discuss how to install PHP on Debian 10, Buster. We'll also show you how to integrate PHP with Nginx and Apache.

In this post, we will discuss how to install PHP on Debian 10, Buster. We'll also show you how to integrate PHP with Nginx and Apache. Debian 10 ships with PHP version 7.3, which is supported by the most popular CMS and frameworks such as WordPress, Magento, and Laravel.

Prerequisites

To be able to install packages, you need to be logged in as root or user with sudo privileges

Installing PHP with Apache

If you are using Apache as your webserver to install PHP and Apache PHP module run the following commands:

sudo apt update
sudo apt install php libapache2-mod-php

Once the installation is complete, restart Apache to load the PHP module:

sudo systemctl restart apache2

Installing PHP with Nginx

Unlike Apache, Nginx doesn't have a built-in support for processing PHP files. You'll need to use the PHP FPM (“fastCGI process manager”) service to handle the PHP files.

Install the PHP and PHP FPM packages by running the following command:

sudo apt update
sudo apt install php php-fpm

Once the packages are installed, the PHP FPM service will start automatically.

You can now edit your domain Nginx server block and add the following lines so that Nginx can process PHP files:

server {

    # . . . other code

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

Save the configuration file and restart the nginx service for the new configuration take effect:

sudo systemctl restart nginx

Installing PHP extensions

You can extend the PHP core functionalities by installing additional extensions. PHP extensions are available as packages and can be easily installed by typing:

sudo apt install php-[extname]

For example, to install MySQL and GD PHP extensions, you would run the following command:

sudo apt install php-mysql php-gd

When installing PHP extensions, do not forget to restart the Apache or the PHP FPM service, depending on your setup.

Testing PHP Processing

To test whether your web server is properly configured for PHP processing, create a new file called info.php inside the /var/www/html directory with the following code:

/var/www/html/info.php

<?php

phpinfo();

Save the file, open your browser of choice and visit http://your_server_ip/info.php

The phpinfo function prints information about your PHP configuration as shown on the image below:

Conclusion

We have shown you how to install PHP on Debian 10 and configure your webserver to process PHP files. Thank you for reading !