Category Archives: Linux

Discover DevOps roles and learn Linux from basics to advanced at DevOpsRoles.com. Detailed guides and in-depth articles to master Linux for DevOps careers.

How to reset admin password WordPress

Introduction

In this tutorial, I lost the admin password WordPress. How to reset admin password WordPress. Did you forget your WordPress admin password? Don’t worry; it happens to the best of us. Thankfully, resetting your admin password is a straightforward process.

How to reset admin password WordPress

You’ve logged into the MySQL database server as the root user and you’re trying to access the wordpressdb database. Here are the steps you’ve taken, For Example, I will use wordpressdb database.

[root@server1 ~]# mysql -u root -p
mysql> show databases;
mysql> use wordpressdb;

The output is below

[root@server1 ~]# mysql -u root -p

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpressdb        |
+--------------------+
5 rows in set (0.01 sec)

mysql> use wordpressdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 

Find the user table

mysql> show tables;

The output is as below:

mysql> show tables;
+-----------------------+
| Tables_in_wordpressdb |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.00 sec)

Find users

mysql> SELECT ID, user_login, user_pass FROM wp_users;

The output is below

mysql> SELECT ID, user_login, user_pass FROM wp_users;
+----+------------+------------------------------------+
| ID | user_login | user_pass                          |
+----+------------+------------------------------------+
|  1 | admin      | $P$B3jZNLbpdkZBm9NkkgtnfyaT7ECXWl0 |
+----+------------+------------------------------------+
1 row in set (0.00 sec)

The administrator is usually user number 1

mysql> SELECT * FROM wp_users where id = '1';

The output is as below:

mysql> SELECT * FROM wp_users where id = '1';
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
| ID | user_login | user_pass                          | user_nicename | user_email         | user_url               | user_registered     | user_activation_key | user_status | display_name |
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
|  1 | admin      | $P$B3jZNrepdkZBm9NkkgtnfyaT7ECXWl0 | admin         | pvhuu285@gmail.com | http://192.168.122.229 | 2020-09-04 04:11:59 |                     |           0 | admin        |
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
1 row in set (0.00 sec)

For MySQL 5 and higher

just execute a query like this to reset the password for the admin WordPress

mysql> UPDATE wp_users SET user_pass = MD5 ('123456789') WHERE ID = '1';

Check again

mysql> SELECT * FROM wp_users where id = '1';

The output is as below:

mysql> SELECT * FROM wp_users where id = '1';
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
| ID | user_login | user_pass                          | user_nicename | user_email         | user_url               | user_registered     | user_activation_key | user_status | display_name |
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
|  1 | admin      | $P$BaDO1CjqaJhGcYKwsk0va7dlAj5cXp. | admin         | pvhuu285@gmail.com | http://192.168.122.229 | 2020-09-04 04:11:59 |                     |           0 | admin        |
+----+------------+------------------------------------+---------------+--------------------+------------------------+---------------------+---------------------+-------------+--------------+
1 row in set (0.00 sec)

We log in through wp-login.php and input a new password, as usual.

http://192.168.122.229/wp-login.php

Conclusion

You have Reset admin password WordPress. I hope will this your helpful. Thank you for reading the DevopsRoles page!

How to install new python package using PIP

Introduction

In this tutorial, How to Setup a Python Virtual Environment. I will Install New Python package for the test environment.

In the preview post, I have installed and configured basic PIP here

Activate Your Virtual Environment

source venv/bin/activate

You can see “(venv)” indicator at the beginning of your command prompt.

(Test_Environment) [devopsroles@server1 ~]$

At any time, you can stop your virtual environment using the deactivate command.

(Test_Environment) [devopsroles@server1 ~]$ deactivate
[devopsroles@server1 ~]$ 

Install new python package using PIP

Install Packages

[devopsroles@server1 ~]$ pip3 freeze > package.txt
[devopsroles@server1 ~]$ python3 -m venv Test_Environment
[devopsroles@server1 ~]$ source Test_Environment/bin/activate
(Test_Environment) [devopsroles@server1 ~]$ pip install flask==1.0.0
(Test_Environment) [devopsroles@server1 ~]$ pip freeze > package_after.txt

After, install flask package in Test_Environmet as below

(Test_Environment) [devopsroles@server1 ~]$ ll
total 8
-rw-rw-r--. 1 devopsroles devopsroles  93 Sep  3 21:21 package_after.txt
-rw-rw-r--. 1 devopsroles devopsroles 297 Sep  3 21:20 package.txt
drwxrwxr-x. 5 devopsroles devopsroles 100 Sep  3 21:21 Test_Environment

You can difference confirmation as the picture below

Now, you can install everything package for another developer could easily recreate your environment and run code

git clone https://github.com/username/devopsroles.git
cd /home/huupv
source venv/bin/activate
pip install -r requirements.txt

Conclusion

You can install a new python package using PIP for a Virtual environment. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Install PIP on Centos 8

Introduction

In this tutorial. How to install pip on Centos 8. Pip is a package management system that allows you to install, remove, and otherwise manage software packages written in Python.

How to Install PIP on Centos 8

Two Python versions are Python 2 and Python 3.

Install pip3 for Python 3

sudo dnf install python3

The output is as below:

[devopsroles@server1 ~]$ sudo dnf install python3
[sudo] password for devopsroles: 
Last metadata expiration check: 0:07:32 ago on Wed 02 Sep 2020 09:15:00 PM +07.
Dependencies resolved.
==========================================================================================================
 Package                  Architecture Version                                      Repository       Size
==========================================================================================================
Installing:
 python36                 x86_64       3.6.8-2.module_el8.1.0+245+c39af44f          AppStream        19 k
Installing dependencies:
 python3-pip              noarch       9.0.3-16.el8                                 AppStream        19 k
 python3-setuptools       noarch       39.2.0-5.el8                                 BaseOS          162 k
Enabling module streams:
 python36                              3.6                                                               

Transaction Summary
==========================================================================================================
Install  3 Packages

Total download size: 201 k
Installed size: 466 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64.rpm            7.3 kB/s |  19 kB     00:02    
(2/3): python3-pip-9.0.3-16.el8.noarch.rpm                                7.1 kB/s |  19 kB     00:02    
(3/3): python3-setuptools-39.2.0-5.el8.noarch.rpm                          52 kB/s | 162 kB     00:03    
----------------------------------------------------------------------------------------------------------
Total                                                                      43 kB/s | 201 kB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                  1/1 
  Installing       : python3-setuptools-39.2.0-5.el8.noarch                                           1/3 
  Installing       : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Running scriptlet: python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Installing       : python3-pip-9.0.3-16.el8.noarch                                                  3/3 
  Running scriptlet: python3-pip-9.0.3-16.el8.noarch                                                  3/3 
  Verifying        : python3-pip-9.0.3-16.el8.noarch                                                  1/3 
  Verifying        : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Verifying        : python3-setuptools-39.2.0-5.el8.noarch                                           3/3 

Installed:
  python3-pip-9.0.3-16.el8.noarch                            python3-setuptools-39.2.0-5.el8.noarch       
  python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64       

Complete!

Check version pip

pip3 --version

The output as below

[devopsroles@server1 ~]$ pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

To install and build Python modules with pip, you need to install the Development tools:

sudo yum install python3-devel
sudo yum groupinstall 'development tools'

Installing pip2 for Python 2

sudo dnf install python2
pip2 --version
sudo yum install python2-devel
sudo yum groupinstall 'development tools'

For example, I have installed two python3 and python2 on Centos 8 as below

[devopsroles@server1 ~]$ sudo yum list installed | grep pip
libpipeline.x86_64                          1.5.0-2.el8                           @anaconda 
platform-python-pip.noarch                  9.0.3-16.el8                          @anaconda 
python2-pip.noarch                          9.0.3-16.module_el8.2.0+381+9a5b3c3b  @AppStream
python2-pip-wheel.noarch                    9.0.3-16.module_el8.2.0+381+9a5b3c3b  @AppStream
python3-pip.noarch                          9.0.3-16.el8                          @AppStream
python3-pip-wheel.noarch                    9.0.3-16.el8                          @anaconda 

Managing Python Packages with pip

Typically, you should use pip inside a virtual environment only. It is used when separating the Python execution environment, such as when you want to change the Python execution environment for each project or you do not want to keep the local environment dirty venv.

In this section, we will go through several basic pip commands.

To install a package

pip install flask

If you want to install a specific version of the package

pip install flask==1.0.0

Uninstall a package

pip uninstall package_name

Search packages

pip search "package_name"

View the full list of packages

pip list

List outdated packages:

pip list --outdated

To upgrade an already installed package

pip3 install --upgrade package_name

Check pip dependencies

pip check

List of packages that need updating

pip list -o

Show packages by package name == version

pip freeze

Useful when outputting to requirements.txt

pip freeze > requirements.txt

Package update

pip install  -U package_name

Update pip itself

pip install  -U pip

Checking the details of the package

pip show package-name

Conclusion

How to install pip on CentOS 8 and how to easily install and uninstall Python modules with pip. Thank you for reading the DevopsRoles page!

Initial Server Setup Centos 8

Introduction

When launching a new server with CentOS 8, ensuring a secure and properly configured foundation is essential. Whether you’re setting up a VPS for the first time or deploying infrastructure for production, a systematic initial server setup will help harden your system and prepare it for future installations. In this guide, we’ll walk through the essential steps to Initial Server Setup CentOS 8 server – from creating a non-root sudo user to configuring your firewall and installing core utilities.

Update Your System

Before any configuration, ensure that your system is up to date. This not only secures your server but also ensures compatibility with future installations:

sudo dnf update -y
sudo dnf upgrade -y

Create a Sudo User and Granting Administrative Privileges

useradd devopsroles
passwd devopsroles
usermod -aG wheel devopsroles
su - devopsroles

The output terminal as below

Open a new terminal window

ssh devopsroles@SERVER_IP_ADDRESS

Disable SSH Root Login

We have new account. so, I can secure our server by disabling remote SSH account to the root account.

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config_BK
sudo sed -i -e 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
sudo cat /etc/ssh/sshd_config | grep PermitRootLogin

The output terminal as below

we need to restart the SSH

sudo systemctl reload sshd

Changing the hostname

sudo hostnamectl set-hostname server1.devopsroles.com

Setting Up a Basic Firewall CentOS 8

Firewalld is a firewall management tool for Linux operating systems. you need to make sure that the server firewall allows web access.

sudo firewall-cmd --add-service=http --permanent
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo systemctl status firewalld

Update CentOS 8 System

sudo yum check-update
sudo yum upgrade -y
sudo yum clean all

Install System Utilities

sudo yum -y install bind-utils net-tools  psmisc traceroute tree vim-enhanced wget

Conclusion

By following this initial server setup guide for CentOS 8, you’ve established a secure and functional baseline for your system. Creating a non-root user with sudo privileges, securing SSH access, enabling the firewall, and installing essential tools are critical steps to ensure stability, security, and readiness for production workloads. With this solid foundation, you’re now well-prepared to deploy applications, configure services, or automate infrastructure tasks confidently.

For ongoing security, remember to regularly update your system and monitor user access and services. If you’re planning to install a web server, database, or other services next, this setup ensures you start from a well-configured environment. I hope will this your helpful. Thank you for reading the DevopsRoles page!

RabbitMQ tutorial for beginners

Introduction

In this tutorial, I will witten about RabbitMQ: Install, configuration, and example. RabbitMQ is a message broker, written in Erlang. Now, let’s go to the RabbitMQ tutorial for beginners.

It is transferring data ( messages) between several services: one service adds a message to the queue, the other receives these messages.

How to install and Run use RabbitMQ

Debian/Ubuntu

# apt install rabbitmq-server

Centos

# yum -y install epel-release
# yum -y install erlang socat
# wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
# rpm -Uvh rabbitmq-server-3.6.10-1.el7.noarch.rpm

Docker

# docker run docker pull rabbitmq

RabbitMQ tutorial for beginners

Rabbitmq-plugins

The Documentation here

To view active plugin use list

$ sudo rabbitmq-plugins list

Show activate the plugin RabbitMQ Management

$ sudo rabbitmq-plugins enable rabbitmq_management

Active plugins are stored in a file /etc/rabbitmq/enabled_plugins

$ cat /etc/rabbitmq/enabled_plugins

HTTP API

The documention here

rabbitmq_management active API support on port 15672

# netstat -nplt | grep 15672

Example check it

# curl -i -u guest:guest localhost:15672/api/overview

rabbitmqadmin

Document here

rabbitmqctl

The Documentation here. It is mainly for managing nodes in a cluster – adding, deleting, rebooting, managing logs.

# rabbitmqctl status

View users

# rabbitmqctl list_users

WEB UI

After activating the plugin, the web interface for managing the server on port 15672.

Add a new user And the rights to everything. User access is guest denied by default.

# rabbitmqctl add_user test test
# rabbitmqctl set_user_tags test administrator
# rabbitmqctl set_permissions -p / test ".*" ".*" ".*"

There are three basic concepts for RabbitMQ

  • producer: the client doing the sending of the message
  • queue: the actual message queue
  • consumer: the client receiving messages from the queue
  • exchange: receives messages from the producer, and sends them to queues according to its type

Example

To work with RabbitMQ, AMQP (Advanced Message Queuing Protocol) support is required. we will install for python pika

$ sudo yum install python-pika

Sending a message

To create a script for the producer.

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',
                     routing_key='hello',
                     body='Hello World!')

print(" [x] Sent 'Hello World!'")

connection.close()

Run the script

$ ./producerScript.py

check with rabbitmqadmin

# rabbitmqadmin get queue='hello'

List of queues with rabbitmqctl

# rabbitmqctl list_queues

Receiving a message

The second script – consumertest.py- will receive a message from the queue

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')

def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

Run it

# ./consumer.py

We check the queue – now it’s empty here

# rabbitmqctl list_queues

Conclusion

Through the article, RabbitMQ tutorial for beginners. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Centos 8 LEMP WordPress

In this tutorial, How to Install and configure LEMP WordPress running a Centos 8. LEMP is an acronym for Linux, Nginx, MySQL, and PHP. Now, let’s go to Centos 8 LEMP WordPress.

Centos 8 LEMP WordPress Environment

  • Centos 8
  • Nginx
  • MySQL
  • WordPress

1.Nginx Install

The first, Your update for Centos 8.

[root@DevopsRoles vagrant]# dnf update

Next, Install Nginx on Centos 8

[root@DevopsRoles vagrant]# dnf install nginx
# Set to start automatically at reboot 
[root@DevopsRoles vagrant]# systemctl enable  --now nginx
# Check status
[root@DevopsRoles vagrant]# systemctl status nginx

Firewall port setting HTTP (80) Allow HTTPS(443)

[root@DevopsRoles vagrant]# firewall-cmd --add-port=80/tcp --permanent
[root@DevopsRoles vagrant]# firewall-cmd --reload

2.Install MySQL

[root@DevopsRoles vagrant]# dnf install @mysql
 # After installation, familiar service start, and automatic start setting
[root@DevopsRoles vagrant]# systemctl start mysqld
[root@DevopsRoles vagrant]# systemctl enable mysqld
 # The initial security settings of mysql
[root@DevopsRoles vagrant]# mysql_secure_installation
# Operation check
[root@DevopsRoles vagrant]# mysql -u root -p

3.Install PHP

[root@DevopsRoles vagrant]# dnf install php-fpm php-cli php-json php-opcache php-xml php-gd php-curl
# php is also set to start automatically
[root@DevopsRoles vagrant]# systemctl enable --now php-fpm

Extension php required to run WordPress on Centos 8

[root@DevopsRoles vagrant]# dnf install php-cli php-json php-opcache php-xml php-gd php-curl php-mysqlnd

4.Database Creation

[root@DevopsRoles vagrant]# mysql -u root -p
# db creation (name can be anything)
SQL> create database wordpressdb;
# Create user, set permissions and reflect settings
SQL> create user wpadmin@localhost identified by 'Stro123@.';
SQL> grant all on wordpressdb.* to wpadmin@localhost;
SQL> flush privileges;
SQL> quit

5.Install WordPress

# Download wordpress
[root@DevopsRoles vagrant]# wget https://wordpress.org/latest.tar.gz
# Create a folder for #wordpress
[root@DevopsRoles vagrant]# mkdir /usr/share/nginx/wp.devopsroles.com
# Decompress
[root@DevopsRoles vagrant]# tar xzf latest.tar.gz -C /usr/share/nginx/wp.devopsroles.com/ --strip-components=1
# Copy configuration file
[root@DevopsRoles vagrant]# cp /usr/share/nginx/wp.devopsroles.com/wp-config-sample.php /usr/share/nginx/wp.devopsroles.com/wp-config.php
# Open configuration file
[root@DevopsRoles vagrant]# vi /usr/share/nginx/wp.devopsroles.com/wp-config.php

Look like wp-config.php file as below:

/** MySQL database name */
define( 'DB_NAME', 'wordpressdb' );
/** MySQL database user name */
define( 'DB_USER', 'wpadmin' );

/** MySQL database password */
define( 'DB_PASSWORD', 'Stro123@.' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database character set when creating database table */
define( 'DB_CHARSET', 'utf8' );

/** Database collation (should not be changed in most cases) */
define( 'DB_COLLATE', '' );

Get the authentication unique key for WordPress.

curl -s https://api.wordpress.org/secret-key/1.1/salt/

Copy and paste the returned contents into wp-config.php

define('AUTH_KEY',         'balabal');
define('SECURE_AUTH_KEY',  'balabal');
define('LOGGED_IN_KEY',    'balabal');
define('NONCE_KEY',        'balabal');
define('AUTH_SALT',        'balabal');
define('SECURE_AUTH_SALT', 'balabal');
define('LOGGED_IN_SALT',   'balabal');
define('NONCE_SALT',       'balabal');

6.Nginx Settings

I have configured Nginx for WordPress with content as below:

vi /etc/nginx/conf.d/devopsroles.conf

server {
    listen       80 default_server;
    server_name  devopsroles.com;
    root         /usr/share/nginx/wp.devopsroles.com;

    access_log /var/log/nginx/access_devopsroles.com.log;
    error_log /var/log/nginx/error_devopsroles.com.log;

    index   index.php;

    location / {
        try_files    $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_index index.php;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

Set user and group nginx for the folder as below

chown -R nginx:nginx /usr/share/nginx/wp.devopsroles.com/

Restart Nginx

systemctl restart nginx

I have installed success Centos 8 LEMP WordPress. Have a good nice 🙂 Thank you for reading the DevopsRoles page!

Using Netdata to Monitor PHP-FPM

In this tutorial, How to Monitor the PHP-fpm using Netdata on Centos 7. Netdata is a free open source. It is very easy to install and configure for real-time monitoring. Now, let’s go to Netdata to Monitor PHP-FPM.

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI. It is commonly used in LEMP ( Linux Nginx MySQL/MariaDB PHP) stack; Nginx uses PHP FastCGI for serving dynamic HTTP content.

Steps install and configure

  • Centos 7 Server or RHEL 7 Server
  • Install PHP and enable PHP-FPM status
  • Install Netdata and configure Monitor for PHP-FPM status.

1. How to Install PHP

For example, How to install PHP version 7.3 on Centos 7.

2. Enable the PHP-FPM status page.

Check php-fpm running on your system.

[root@DevopsRoles vagrant]# netstat -nplt | grep php-fpm
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      4328/php-fpm: maste 
[root@DevopsRoles vagrant]# ps -ef | grep php
root      4328     1  0 21:50 ?        00:00:00 php-fpm: master process (/etc/opt/remi/php73/php-fpm.conf)
apache    4329  4328  0 21:50 ?        00:00:00 php-fpm: pool www
apache    4330  4328  0 21:50 ?        00:00:00 php-fpm: pool www
apache    4331  4328  0 21:50 ?        00:00:00 php-fpm: pool www
apache    4332  4328  0 21:50 ?        00:00:00 php-fpm: pool www
apache    4333  4328  0 21:50 ?        00:00:00 php-fpm: pool www
root      4381  3003  0 21:52 pts/0    00:00:00 grep --color=auto php

Configure file php-fpm status as shown.

$ sudo vim /etc/php-fpm.d/www.conf 
OR
$ sudo vim /etc/opt/remi/php73/php-fpm.d/www.conf	#for PHP versions 7.0, 7.1,7.3 vvv

You find and uncomment the variable pm.status_path = /status as shown in the screenshot.

[root@DevopsRoles vagrant]# cat /etc/opt/remi/php73/php-fpm.d/www.conf | grep pm.status_path
pm.status_path = /status

Save the changes and exit the file.

Check the PHP-FPM configuration file for any errors

$ sudo php-fpm -t
OR
$ sudo systemctl restart php73-php-fpm

Create a new Nginx config for PHP-FPM as shown

[root@DevopsRoles ~]# vi /etc/nginx/conf.d/php-fpm.conf

# The content as below:

    server {

        listen       80;
        #listen       [::]:80 default_server;
        server_name  127.0.0.1;

    location  /status {
        access_log off;
        allow 127.0.0.1;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        deny all;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
   }
   }

Reload PHP-FPM and Nginx config for changes to take effect.

[root@DevopsRoles ~]# systemctl reload php73-php-fpm
[root@DevopsRoles ~]# systemctl reload nginx

Now, Use the curl command to check php-fpm status.

root@DevopsRoles ~]# curl http://127.0.0.1/status
pool:                 www
process manager:      dynamic
start time:           18/Jul/2020:10:16:17 +0700
start since:          878
accepted conn:        14
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       4
active processes:     1
total processes:      5
max active processes: 1
max children reached: 0
slow requests:        0

Memo: meaning of different values of PHP-FPM Status

-pool – the name of the pool.
-process manager – possible values static, dynamic or ondemand. We never use static.  Trying ondemand is on todo list.
-start time – the date and time FPM has started or reloaded.
-start since – number of seconds since FPM has started
-accepted conn – the number of request accepted by the pool
-listen queue – the number of request in the queue of pending connections. If this number is non-zero, then you better increase number of process FPM can spawn.
-max listen queue – the maximum number of requests in the queue of pending connections since FPM has started
-listen queue len – the size of the socket queue of pending -connections
-idle processes – the number of idle processes
-active processes – the number of active processes
-total processes – the number of idle + active processes
-max active processes – the maximum number of active processes since FPM has started
-max children reached – number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.
-slow requests – Enable php-fpm slow-log before you consider this. If this value is non-zero you may have slow php processes. Poorly written mysql queries are generally culprit.

3. Install Netdata on Centos 7 here

4. Configure Netdata to Monitor PHP-FPM

The Netdata configure for Nginx in folder /etc/netdata/python.d which is written in YAML format.

You can open it or create a new file php-fpm.conf as shown

[root@DevopsRoles python.d]# cat /etc/netdata/python.d/php-fpm.conf 
# The output as below:
localhost:
  name : 'local'
  url  : 'http://localhost/status'

localipv4:
  name : 'local'
  url  : 'http://127.0.0.1/status'

Restart Netdata Server

[root@DevopsRoles ~]# systemctl restart netdata 

5. Using Netdata to Monitor PHP-FPM

Open a web browser access the netdata web UI.

http://NETDATA_SERVER_IP:19999
or
http://DOMAIN_NAME:19999

The result as the picture below

Conclusion

Through the article, you can use Netdata to monitor PHP-FPM. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Using Netdata to Monitor Nginx

In this tutorial, How to Monitor the Nginx using Netdata on Centos 7. Netdata is a free open source. It is very easy to install and configure for real-time monitoring.

Steps install and configure

  • Centos 7 Server or RHEL 7 Server
  • Install Web Server Nginx
  • Install Netdata and configure Monitor for Web Server Nginx.

1. Install Web Server Nginx

Enable EPEL repository

[root@DevopsRoles ~]# yum install epel-release

Install the Nginx package, as follows.

[root@DevopsRoles ~]# yum install nginx

Start and enable Nginx Web Server, as follows.

[root@DevopsRoles ~]# systemctl start nginx
[root@DevopsRoles ~]# systemctl enable nginx
[root@DevopsRoles ~]# systemctl status nginx

If you are running a firewall. You need to open port 80/443 for Nginx Webserver.

Enable Nginx Stub_Status Module

I will enable the stub_status module which netdata uses to collect metrics from your Nginx web server.

[root@DevopsRoles ~]# vi /etc/nginx/nginx.conf

Copy and paste the location configuration as below

location /server_status {
 	stub_status;
 	allow 127.0.0.1;	#only allow requests from localhost
 	deny all;		#deny all other hosts	
 }

restart the Nginx service to effect

[root@DevopsRoles ~]# nginx -t
[root@DevopsRoles ~]# systemctl restart nginx

Now, Use curl command to check

curl http://127.0.0.1/server_status

# The output terminal as below:
[root@DevopsRoles ~]# curl http://127.0.0.1/server_status
Active connections: 1 
server accepts handled requests
 1 1 1 
Reading: 0 Writing: 1 Waiting: 0

3. Install Netdata on Centos 7 here

4. Configure Netdata to Monitor Nginx

The Netdata configure for Nginx in folder /etc/netdata/python.d which is written in YAML format.

You can open it or create a new file nginx.conf as below

[root@DevopsRoles python.d]# cat /etc/netdata/python.d/nginx.conf 
# The output as below:
localhost:
  name : 'local'
  url  : 'http://localhost/server_status'

localipv4:
  name : 'local'
  url  : 'http://127.0.0.1/server_status'

Restart Netdata Server

[root@DevopsRoles ~]# systemctl restart netdata 

5. Using Netdata to Monitor Nginx Web Server

Open a web browser access the netdata web UI.

http://NETDATA_SERVER_IP:19999
or
http://DOMAIN_NAME:19999

The result as the picture below

Conclusion

Through the article, you can use Netdata to monitor Nginx. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Using Netdata to Monitor MariaDB Database

In this tutorial, How to Monitor the MariaDB database using Netdata on Centos 7. Netdata is a free open source. It is very easy to install and configure for real-time monitoring.

Steps install and configure

  • Centos 7 Server or RHEL 7 Server
  • Install MariaDB Database
  • Install Netdata and configure Monitor for MariaDB Database.

1. Install MariaDB Database

Adding MariaDB YUM software repository.

[root@DevopsRoles ~]# vim /etc/yum.repos.d/MariaDB.repo

The content file MariaDB.repo is as follows.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Install the MariaDB package, as follows.

[root@DevopsRoles ~]# yum install MariaDB-server MySQL-python MariaDB-client -y

Start and enable MariaDB Database Server, as follows.

[root@DevopsRoles ~]# systemctl start mariadb
[root@DevopsRoles ~]# systemctl enable mariadb
[root@DevopsRoles ~]# systemctl status mariadb

By default, the MySQL installation is unsecure and you need to secure it, as follows

[root@DevopsRoles ~]# mysql_secure_installation

To create this user MariaDB

MariaDB [(none)]> create user 'netdata'@'localhost'; 
MariaDB [(none)]> grant usage on *.* to 'netdata'@'localhost'; 
MariaDB [(none)]> flush privileges; 

If you are running a firewall. You need to open the port 3306 for MariaDB Database

3. Install Netdata on Centos 7 here

4. Configure Netdata to Monitor MariaDB

The netdata configure for MariaDB in folder /etc/netdata/python.d which is written in YAML format.

You can open it or create a new file mysql.conf as below

[root@DevopsRoles python.d]# cat /etc/netdata/python.d/mysql.conf 
localhost:
  name : 'local'
  user : 'netdata'
  port : '3306'

Restart Netdata Server

[root@DevopsRoles ~]# systemctl restart netdata 

5. Using Netdata to Monitor MariaDB Database

Open a web browser access the netdata web UI.

http://NETDATA_SERVER_IP:19999
or
http://DOMAIN_NAME:19999

The result as the picture below

Netdata debug for mariadb

/usr/libexec/netdata/plugins.d/python.d.plugin 1 debug mysql

Error netdata for MariaDB code (Fixed)

2020-07-05 16:32:37: python.d ERROR: mysql[localhost] : MySQLdb or PyMySQL module is needed to use mysql.chart.py plugin

On My Centos missing MySQL-python package

Conclusion

Through the article, you can use Netdata to Monitor MariaDB Database. I hope will this your helpful.

Using Netdata to Monitor Apache Performance

In this tutorial, How to Monitor Apache Performance using Netdata on Centos 7. Netdata is a free open source. It is very easy to install and configure for real-time monitoring.

Steps install and configure

  • Centos 7 Server or RHEL 7 Server
  • Install Apache HTTP Server with mod_status_module enabled
  • Install Netdata and configure Monitor for Apache HTTP Server.

1. Install Apache HTTP server

First, install the Apache HTTP server on Centos. I will Yum package manager to install Apache.

[root@DevopsRoles ~]# yum install httpd

Start and enable Apache HTTP server.

[root@DevopsRoles ~]# systemctl start httpd
[root@DevopsRoles ~]# systemctl enable httpd
[root@DevopsRoles ~]# systemctl status httpd

If you are running a firewall. You need to open ports 80 and 443 for Apache.

2. Enable mod_status module in Apache

You need to enable and configure the mod_status module in apache, This is required by Netdata.

[root@DevopsRoles ~]# cat /etc/httpd/conf.modules.d/00-base.conf | grep mod_status
LoadModule status_module modules/mod_status.so

Create a server-status.conf for the Apache server-status page as below

[root@DevopsRoles ~]# cat /etc/httpd/conf.d/server-status.conf
<Location "/server-status">
    SetHandler server-status
    #Require host localhost           #uncomment to only allow requests from localhost 
</Location>

Restart Apache HTTP Server

[root@DevopsRoles ~]# systemctl restart httpd

Test working Apache Server status page.

[root@DevopsRoles ~]# curl http://localhost/server-status  

3. Install Netdata on Centos 7 here

4. Configure Netdata to Monitor Apache Performance

The Netdata configure for Apache in folder /etc/netdata/python.d

You can open it or create new file apache.conf as below

[root@DevopsRoles ~]# cat /etc/netdata/python.d/apache.conf
localhost:
  name : 'local'
  url  : 'http://localhost/server-status?auto'

localipv4:
  name : 'local'
  url  : 'http://127.0.0.1/server-status?auto'

Restart netdata server

[root@DevopsRoles ~]# systemctl restart netdata 

5. Using Netdata to Monitor Apache Performance

Open a web browser access the Netdata web UI.

http://NETDATA_SERVER_IP:19999
or
http://DOMAIN_NAME:19999

The result as below

Conclusion

Thought the article, you can use Netdata to monitor Apache Performance. I hope will this your helpful.