Installing mariadb. Installing MariaDB on Debian

January 2, 2017 12:16 pm 13 224 views | no comments

Requirements

  • CentOS 7 server.
  • A user with sudo access.

All necessary instructions can be found in .

Step 1 Install MariaDB

To install MariaDB, use the Yum repository. Run the following command and press y to continue.

sudo yum install mariadb-server

Once the installation is complete, start the daemon:

sudo systemctl start mariadb

The systemctl command does not show the output of some commands. To make sure the daemon is running, type:

sudo systemctl status mariadb

If the MariaDB daemon was running, the output of the command will be the lines:

Active: active (running)
[…]
Dec 01 19:06:20 centos-512mb-sfo2-01 systemd: Started MariaDB database server.

Now we need to configure MariaDB autostart. To do this, enter:

sudo systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

After that, you need to ensure data security.

2: MariaDB Security

After the installation is complete, you need to run the built-in MariaDB security script, which changes some default options and blocks remote root login. To run the script, type:

sudo mysql_secure_installation

The script provides detailed description every step. It will first ask for the root password. Because in new installation there is no such password yet, just press Enter. The script will then prompt you to create such a password. Enter complex password and confirm it.

The script will then ask you a series of questions. To accept the default data, you can simply press Y and Enter. The script will lock out anonymous users and remote root login, delete test tables, and reset privileges.

Step 3: Testing MariaDB

Now we need to make sure that the installation of MariaDB was successful.

Try connecting to the db using the mysqladmin tool (it's a client to run administration commands). To connect to MariaDB as root (-u root), enter a password (-p), and query the program version, enter the command:

mysqladmin -u root -p version

The command will output:

mysqladmin Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Server version 5.5.50-MariaDB
protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 4 min 4 sec
Threads: 1 Questions: 42 Slow queries: 0 Opens: 1 Flush tables: 2 Open tables: 27 Queries per second avg: 0.172

This means that the installation of the MariaDB DBMS was successful.

Conclusion

Now you can do basic installation and setting up MariaDB.

Today we will be engaged in raising one of the most demanded roles of any linux server, which occupy a leading role in this functional segment. Setting web servers CentOS 7 based on a bunch of popular http server apache, interpreter php and database servers mysql, or in short - setting lamp. This bundle is the most popular configuration among web hosting today. Although the same company has been on its heels lately, but based on nginx, it may have already gotten ahead of it, I don’t have exact data on this.

This article is part of a single series of articles about the server.

Web server on CentOS 7

So, our centos web server will consist of three main components - an http server apache, programming language interpreter php and database servers mysql. Let's get to know each of them a little:

  1. Apache- http server or just apache web server. It is a cross-platform software that supports almost all popular operating systems, including Windows. It is valued primarily for its reliability and configuration flexibility, which can be significantly expanded thanks to plug-ins, of which there are a great many. Among the shortcomings, they note a greater demand for resources, compared to other servers. To keep the same load as, for example, nginx, apache will not be able to with similar hardware parameters.
  2. PHP- programming language general purpose, which is most often used in web development. It is by far the most popular language in this application area. Supported by almost all hosting providers.
  3. MySQL— database management system. Gained its popularity in the environment of small and medium-sized applications, which are very numerous on the web. So, like php, it is by far the most popular database used on websites. Supported by most hosts. On CentOS instead of mysql is installed mariadb is a fork of mysql. They are fully compatible, it is possible at any time to switch from one subd to another and back. Recently, I have seen information that mariadb works faster than mysql and people are slowly moving to it. In practice, I did not happen to observe this, since I have never worked with loaded databases. And under normal conditions, the difference is not noticeable.

The experimental server will be, the characteristics are as follows:

CPU2 cores
Memory8 GB
Disk150GB SSD

This is a custom setting. They are not optimal for the price, but they were exactly what I needed.

I want to clarify right away that I am dismantling the basic default setting. To improve performance, reliability and usability, you need to install a few more tools, which I will discuss separately. AT general case to organize a web server, what is in this article will be enough.

If you don't have a server yet, then you need to run . And if the server is already installed, then don't forget it. I recommend paying attention to the setting, as there are many useful information, which I do not give in the framework of this article - updating the system, setting up a firewall, installing an editor, and much more.

Apache setup on CentOS 7

On CentOS, the apache service is called httpd. When I first got acquainted with this distribution, it was unusual for me. In Freebsd and Debian, which I previously worked with, the web server service was called apache, although somewhere I noticed, it seems in the fryu, that the configuration file is named httpd.conf. To this day, I don't know why both of these names spread. I would be glad if someone shared information with me on this subject in the comments.

Now let's get down to apache installation. On CentOS 7, this is very easy:

# yum install -y httpd

Add apache to startup:

# systemctl enable httpd

Starting apache on CentOS 7:

# systemctl start httpd

Check if the server is running:

# netstat -tulnp | grep httpd tcp6 0 0:::80:::* LISTEN 21586/httpd

Everything is in order, hung on the 80th port, as it should be. Already now you can go to http://ip-address and see the picture:

Now we are going to configure apache. I prefer the following web hosting structure:

Let's create a structure like this:

# mkdir /web && mkdir /web/site1.ru && mkdir /web/site1.ru/www && mkdir /web/site1.ru/logs # chown -R apache. /web

IncludeOptional conf.d/*.conf

If not, uncomment and go to the /etc/httpd/conf.d directory. We create the site1.ru.conf file there:

ServerName site1.ru ServerAlias ​​www.site1.ru DocumentRoot /web/site1.ru/www Options FollowSymLinks AllowOverride All Require all granted ErrorLog /web/site1.ru/logs/error.log CustomLog /web/site1.ru/logs/access.log common

Restarting apache on centos

Now we do restart apache :

# systemctl restart httpd

If there are any errors, look at the apache log /var/log/httpd/error_log . If everything is in order, then we will check if our virtual host is configured normally. To do this, create in the folder /web/site1.ru/www index.html file the following content:

# mcedit /web/site1.ru/www/index.html

Apache is set!

# chown apache. /web/site1.ru/www/index.html

192.168.1.25 site1.ru

where 192.168.1.25 is the ip address of our web server.

Now in the browser we type the address http://site1.ru. If we see a picture:

so everything is set up correctly. If there are any errors, then we go to look at the logs. And in this case, not the general httpd log, but the error log of a specific virtual host at /web/site1.ru/logs/error.log .

I will immediately draw your attention to setting up the rotation of virtual host logs. It often happens that if you do not set it up right away, then you forget. But if the site has good traffic, then the logs will grow rapidly and can take up a lot of space. It is better to set up rotation of the web server logs immediately after creation. It is not difficult to do this.

To set up virtual host log rotation, you need to edit the /etc/logrotate.d/httpd file. It is created during the installation of apache and includes the default log location rotation setup. And since we moved the logs of each virtual host to an individual folder, you need to add these folders to this file:

# mcedit /etc/logrotate.d/httpd /web/*/logs/*.log/var/log/httpd/*log ( missingok notifempty sharedscripts delaycompress postrotate /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true endscript )

In principle, the simplest web server is already ready and can be used. But now there are hardly any sites with static content that only support html. So let's continue with our setup.

If you need to organize the work of the site according to the protocol https, then use the guide for .

Installing php on CentOS 7

Let's take the next step to support dynamic site content. Let's install php on CentOS 7:

# yum install -y php

And then a few more useful components. Install popular modules for php:

# yum install -y php-mysql php-mbstring php-mcrypt php-devel php-xml php-gd

Let's restart apache:

# systemctl restart httpd

Let's create a file in the virtual host directory and check php job:

# mcedit /web/site1.ru/www/index.php# chown apache. /web/site1.ru/www/index.php

We go to the address http://site1.ru/index.php

You should see the php information output. If something is wrong, some errors occurred, see the virtual host error log, php errors will be there too.

Where is php.ini

After installation, the question often arises, where are the php settings stored? Traditionally, they are in a single settings file. On CentOS php.ini is in /etc, right at the root. There you can edit the global settings for all virtual hosts. Personal settings for each site can be made separately in the virtual host configuration file that we made earlier. Let's add some useful settings there:

# mcedit /etc/httpd/conf.d/site1.ru.conf

Add at the very end, before

php_admin_value date.timezone "Europe/Moscow" php_admin_value max_execution_time 60 php_admin_value upload_max_filesize 30M

To apply the settings, you need to restart apache. Now in the output of phpinfo you can see the change in settings.

Upgrading to php 5.6 on CentOS 7

In our example, we installed on CentOS 7 php 5.4 from the standard repository. And what if we need a newer version, for example php 5.6? In this case, you need to update php.

# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm # rpm -Uvh remi-release-7*.rpm

Now update php 5.4 to php 5.6:

# yum --enablerepo=remi,remi-php56 install php php-common php-mysql php-mbstring php-mcrypt php-devel php-xml php-gd

Restart apache:

# systemctl restart httpd

And let's go to see the output of phpinfo - http://site1.ru/index.php

Great, we have updated php to version 5.6.

Installing MySQL on CentOS 7

As I wrote earlier, now the mysql fork is becoming more widespread - mariadb. It has full compatibility with mysql, so you can safely use it. I prefer to use it.

Install mariadb on CentOS 7:

# yum install -y mariadb mariadb-server

Add mariadb to autorun:

# systemctl enable mariadb.service

Start mariadb:

# systemctl start mariadb

Check if it is running or not:

# netstat -tulnp | grep mysqld tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 22276/mysqld

I draw your attention to the fact that it even appears in the system as a mysqld service. Now we run the standard security configuration script:

# /usr/bin/mysql_secure_installation

I will not give the entire output of this script, everything is quite simple and clear there. First, we set a password for root (the current password after installation is empty), then we delete anonymous users, disable the ability to connect to root remotely, delete the test user and the database.

File settings mysql/mariadb is in /etc/my.cnf. For normal operation, the default settings are sufficient. But if you decide to change them, don't forget to restart the database service.

restart mariadb/mysql on CentOS 7:

# systemctl restart mariadb

That's all. The basic functionality of the web server on CentOS 7 is configured.

I will be glad to remarks and comments on the topic of the article. I remind you that this article is part of a single series of articles about the server.

Workshop on Kali Linux

A course for those who are interested in conducting penetration tests and want to practically try themselves in situations close to real ones. The course is designed for those who do not yet have experience in information security. Training lasts 3 months for 4 hours a week. What this course will give you:
  • Look for and exploit vulnerabilities or configuration flaws in corporate networks, websites, servers. Emphasis on pentesting Windows OS and on the security of the corporate segment.
  • Learning tools like metasploit, sqlmap, wireshark, burp suite and many more.
  • Mastering the tools Kali Linux in practice, any information security specialist should be familiar with it.
Test yourself on the entrance test and see the program for more details.

I am going to install MariaDB SSL (Secure Sockets Layer) as well as secure connections from MySQL client and PHP applications. How to enable SSL for MariaDB server and client running on Linux or Unix-like system?

MariaDB is a database server that offers wedge functionality for the MySQL server.

MariaDB was created by some of the original authors of MySQL, with the help of a broader staff of Free developers and others. software open source code. In addition to the core MySQL features, MariaDB offers a rich set of feature enhancements, including alternative storage engines, server optimizations, and other fixes. In this guide i am going to talk about how to set up a mariadb server with ssl and how to establish secure connections using the console and PHP scripts.

When creating SSL certificates, it is important to use 192.168.1.100 as the default name.

Step 1 – Installing MariaDB

Enter the command according to your choice of Linux or Unix.

Installing MariaDB Server/Client on Ubuntu/Debian Linux

Type one of the following commands: apt-get command or apt command:

$ sudo apt-get install mariadb-server mariadb-client

Installing MariaDB Server/Client on CentOS/RHEL/Fedora Linux

Enter the following yum command:

$ sudo yum install mariadb-server mariadb

For Fedora Linux users, you need to enter the dnf command:

$ sudo dnf install mariadb-server mariadb

Installing MariaDB Server/Client on Arch Linux

Enter the following pacman command:

$ sudo pacman -S mariadb

Installing MariaDB server/client on FreeBSD unix

To install the port, run:

# cd /usr/ports/databases/mariadb100-server/ && make install clean # cd /usr/ports/databases/mariadb100-client/ && make install clean

To add a binary package, type:

# pkg install mariadb100-server mariadb100-client

Step 2 — Secure MariaDB Installation

Enter the following command:

$ mysql_secure_installation

Figure.01: Secure the MariaDB installation

Step 3 - Create a CA Certificate

Create a directory called ssl in /etc/mysql/ directory :

$ cd /etc/mysql $ sudo mkdir ssl $ cd ssl

Meaning: The Common Name used for server and client certificates/keys must be different from the Common Name used for the CA certificate. To avoid any issues, I install them like this:

Default CA Name: MariaDB admin
Default server name: MariaDB server
Default client name: MariaDB client

Enter the following command to create a new CA key:

$ sudo openssl genrsa 2048 > ca-key.pem

Examples of possible data outputs:


Figure.02: Creating a CA key

Enter the following command to generate a certificate using this key:

$ sudo openssl req -new -x509 -nodes -days 365000 -key ca-key.pem -out ca-cert.pem
Figure.03: Using the CA key, generate a CA certificate for MariaDB

Examples of possible data outputs:

You should now have the following two files:

  1. /etc/mysql/ssl/ca-cert.pem - Certificate file for the Certificate Authority (CA).
  2. /etc/mysql/ssl/ca-key.pem - Key file for the Certificate Authority (CA).

I am going to use both files to create server and client certificates.

Step 4 - Create a Server Certificate

To create a server key, run:

$ sudo openssl req -newkey rsa:2048 -days 365000 -nodes -keyout server-key.pem -out server-req.pem

Examples of possible data outputs:


Figure 04: Creating a server key for the MariaDB server

Then process RSA key server, for this enter:

$ sudo openssl rsa -in server-key.pem -out server-key.pem

Examples of possible data outputs:

Writing RSA key

Finally, sign the server's certificate by running:

$ sudo openssl x509 -req -in server-req.pem -days 365000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem

Examples of possible data outputs:

Signature ok subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=MariaDB server Getting CA Private Key

You should now have additional files:

  1. /etc/mysql/ssl/server-cert.pem– MariaDB server certificate file.
  2. /etc/mysql/ssl/server-key.pem - MariaDB server key file.

You must use at least two files on the MariaDB server and any other nodes you intend to use for cluster/replication traffic. These two files will secure the communication on the server side.

Step 5 - Create a Client Certificate

mysql client and application PHP/Python/Perl/Ruby will use the client certificate to secure client connectivity. You must install the following files on all your clients, including the web server. To create a client key, run:

$ sudo openssl req -newkey rsa:2048 -days 365000 -nodes -keyout client-key.pem -out client-req.pem

Examples of possible data outputs:


Figure.05: Creating a client key for the MariaDB server

Then process the RSA client key by typing

$ sudo openssl rsa -in client-key.pem -out client-key.pem writing RSA key

Finally, sign the client certificate by running:

$ sudo openssl x509 -req -in client-req.pem -days 365000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

Examples of possible data outputs:

Signature ok subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=MariaDB client Getting CA Private Key

Step 6 - How to verify certificates?

Enter the following command to check the certificates to make sure everything was created correctly:

$ openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem

Examples of possible data outputs:

server-cert.pem: OK client-cert.pem: OK

There should be no errors and you should get an OK response for the server and client certificates.

Step 7 - Configure the MariaDB Server to Use SSL

Edit the file vi /etc/mysql/mariadb.conf.d/50-server.cnf or /etc/mysql/mariadb.cnf in the following way:

$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

Add like this:

### MySQL Server ### ## Securing the Database with ssl option and certificates ## ## There is no control over the protocol level used. ## ## mariadb will use TLSv1.0 or better. ## ssl ssl-ca=/etc/mysql/ssl/ca-cert.pem ssl-cert=/etc/mysql/ssl/server-cert.pem ssl-key=/etc/mysql/ssl/server-key. pem

Save and close the file. You can restart mariadb like this:

$ sudo /etc/init.d/mysql restart

$ sudo systemctl restart mysql

Step 8 - Configure the MariaDB Client to Use SSL

Configure MariaDB client as 192.168.1.200 to use SSL (add to /etc/mysql/mariadb.conf.d/50-mysql-clients.cnf):

$ sudo vi /etc/mysql/mariadb.conf.d/50-mysql-clients.cnf

Add to section:

## MySQL Client Configuration ## ssl-ca=/etc/mysql/ssl/ca-cert.pem ssl-cert=/etc/mysql/ssl/client-cert.pem ssl-key=/etc/mysql/ssl/ client-key.pem ### This option is disabled by default ### ### ssl-verify-server-cert ###

Save and close the file. You must copy files /etc/mysql/ssl/ca-cert.pem , /etc/mysql/ssl/client-cert.pem and /etc/mysql/ssl/client-key.pem for all your clients. For example:

{[email protected]): rsync /etc/mysql/ssl/ca-cert.pem /etc/mysql/ssl/client-cert.pem /etc/mysql/ssl/client-key.pem \ [email protected]:/etc/mysql/ssl

Step 9 - Check

Enter the following command:

$ mysql -u (User-Name-Here) -h (Server-IP-here) -p (DB-Name-Here) $ mysql -u root -h 192.168.1.100 -p mysql $ mysql -u root -h 127.0 .0.1 -p mysql

Enter the following SHOW VARIABLES LIKE '%ssl%'; command in MariaDB [(none)]> line:

MariaDB [(none)]> SHOW VARIABLES LIKE "%ssl%";

OR run the status command:

MariaDB [(none)]>status;

Examples of possible data outputs:

Figure 06: Establishing a secure connection to the console and verifying it

Check SSL and TLS connections. The following command should fail because ssl 3 is not supported and thus not configured to be used:

$ openssl s_client -connect 192.168.1.100:3306 -ssl3 140510572795544:error:140A90C4:SSL routines:SSL_CTX_new:null ssl method passed:ssl_lib.c:1878:

Check TLS v 1/1.1/1.2:

$ openssl s_client -connect 192.168.1.100:3306 -tls1 $ openssl s_client -connect 192.168.1.100:3306 -tls1_1 $ openssl s_client -connect 192.168.1.100:3306 -tls1_2

Examples of possible data outputs:

CONNECTED(00000003) --- no peer certificate available --- No client certificate CA names sent --- SSL handshake has read 5 bytes and written 7 bytes --- New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol: TLSv1 Cipher: 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg: None PSK identity: None PSK identity hint: None SRP username: None Start Time: 1485335036 Timeout: 7200 (sec) Verify return code: 0 (ok) ---

How to read tcpdump packet capture file to check secure communication

Finally, you can use the command packet sniffer tcpdump, which runs under the command line, to look at port 3306:

$ sudo tcpdump -i eth0 -s 65535 port 3306 -w /tmp/mysql.pcap

Now connect to your application PHP/Python/Perl/Ruby mysql or mysql console application:

$ mysql -u bar -h 192.168.1.100 -p foo

Use tcpdump to verify that no textual information, including passwords, is being exchanged between the server and client. This is done in the following way:

$ tcpdump -r /tmp/mysql.pcap | less

Step 10 - Adding a User to the MariaDB Server

Enter the following command:

$ mysql -u root -p

Create a database called foo :

CREATE DATABASE foo;

Create a user named bar for for a database called foo :

GRANT ALL ON foo.* TO [email protected] IDENTIFIED BY "mypassword" REQUIRE SSL;

Granting access from a web server hosted at 192.168.1.200 :

GRANT ALL ON foo.* TO [email protected] IDENTIFIED BY "mypassword" REQUIRE SSL;

Create a secure connection from bash shell

You can login from the console like this:

$ mysql -u bar -p -h 192.168.1.100 foo

Create a secure connection from Python

Install interface first Python for MySQL:

$ sudo apt-get install python-mysql.connector

OR for Python v3.x

$ sudo apt-get install python3-mysql.connector

Here is an example python code for a secure connection using:

#!/usr/bin/python import MySQLdb ssl = ("cert": "/etc/mysql/ssl/client-cert.pem", "key": "/etc/mysql/ssl/client-key.pem" ) conn = MySQLdb.connect(host="192.168.1.100", user="bar", passwd="mypassword", ssl=ssl) cursor = conn.cursor() cursor.execute("SHOW STATUS LIKE "Ssl_cipher"" ) print cursor.fetchone()

#!/usr/bin/python # Note (Example is valid for Python v2 and v3) from __future__ import print_function import sys import mysql.connector from mysql.connector.constants import ClientFlag config = ( "user": "bar", " password": "mypassword", "host": "192.168.1.100", "client_flags": , "ssl_ca": "/etc/mysql/ssl/ca-cert.pem", "ssl_cert": "/etc/mysql /ssl/client-cert.pem", "ssl_key": "/etc/mysql/ssl/client-key.pem", ) cnx = mysql.connector.connect(**config) cur = cnx.cursor(buffered= True) cur.execute("SHOW STATUS LIKE "Ssl_cipher"") print(cur.fetchone()) cur.close() cnx.close()

Examples of possible data outputs:

("Ssl_cipher", "DHE-RSA-AES256-SHA")

| |

Step 1 Install MariaDB

Debian 9 contains the MariaDB 10.1 package in the standard repository. This is his default MySQL option.

To install it, update the package index:

Now install the package:

sudo apt install mariadb-server

The command will install MariaDB but won't prompt you to choose a password or change other settings. On the this moment The MariaDB installation has several vulnerabilities that need to be addressed.

Step 2: Setting up MariaDB

After the installation is complete, you need to run a security script that will remove untrusted parameters and protect the database from unauthorized access.

sudo mysql_secure_installation

The script will ask a series of questions. First you need to specify the MariaDB root password. This is the MariaDB administrative account, which has elevated privileges. You just installed MariaDB and haven't made any configuration changes yet, you don't have that password yet, so just press Enter.

In the next prompt, the script will prompt you to set the root password for the database. Type N and press the Enter key. In Debian, the MariaDB root account is closely related to automated system maintenance, so changing standard methods This account cannot be authenticated. Otherwise, when updating the package, the database may be damaged, and access to the root account may be lost. Later we will look at how to set up an additional account administrator if socket authentication is not for you.

For other questions, you can press Y and Enter. This will remove anonymous users and test databases, disable remote root login, and update the current MariaDB settings.

Step 3: Configuring Password Authentication Support

On new Debian installations root user MariaDB supports authentication with the unix_socket plugin by default, not with a password. This improves security and usability in many cases, but can also make things more difficult if you need to allow access. external program(e.g. phpMyAdmin).

Since the server uses the root user for tasks such as log rotation, starting and stopping the server, account authentication root is better do not change. Changing the credentials in the /etc/mysql/debian.cnf file may work initially, but future package updates will overwrite these changes. Instead, the developers recommend creating a separate administrator account with password authentication.

So, create an account called admin with the same permissions as root, but with password authentication enabled. To do this, open command line MariaDB in terminal:

Now create a new user with root privileges and password authentication support. Specify your username and password in the command.

GRANT ALL ON *.* TO "admin"@"localhost" IDENTIFIED BY "password" WITH GRANT OPTION;

Reset privileges:

FLUSH PRIVILEGES;

Close the MariaDB shell:

Step 4: Testing MariaDB

When installed from the standard repository, MariaDB starts automatically. To verify this, check the status of the service:

sudo systemctl status mariadb
mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-09-04 16:22:47 UTC; 2h 35min ago
Process: 15596 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSIT
Process: 15594 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Process: 15478 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||
Process: 15474 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITI
Process: 15471 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysql
Main PID: 15567 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 27 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─15567 /usr/sbin/mysqld
Sep 04 16:22:45 deb-mysql1 systemd: Starting MariaDB database server...
Sep 04 16:22:46 deb-mysql1 mysqld: 2018-09-04 16:22:46 140183374869056 /usr/sbin/mysqld (mysqld 10.1.26-MariaDB-0+deb9u1) starting as process 15567 ...
Sep 04 16:22:47 deb-mysql1 systemd: Started MariaDB database server.

If the DBMS did not start for some reason, enter:

sudo systemctl start mariadb

For additional verification, you can try connecting to the database using the mysqladmin tool (this is the client that allows you to run administrative commands). For example, this command will connect to MariaDB as root and print the version using a Unix socket:

sudo mysqladmin version
mysqladmin Ver 9.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Server version 10.1.26-MariaDB-0+deb9u1
protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 2 hours 44 min 46 sec
Threads: 1 Questions: 36 Slow queries: 0 Opens: 21 Flush tables: 1 Open tables: 15 Queries per second avg: 0.003

If you have created an additional administrator, you can perform this operation with the command:

mysqladmin -u admin -p version

MariaDB is up and running as expected.

In this article, we will look at how to install and configure Linux, Apache, MariaDB, PHP on Centos7 / RHEL 7. In new version Centos7 /RHEL 7 many changes.

What is LAMP?

LAMP is a set of software on an OS, consisting of operating system Linux, Apache web server, base server MySQL data and language PHP programming(or Perl/Python). LAMP is used to run heavy dynamic websites entirely made up of free and open source software. In this article, I am going to explain how Linux, Apache, MySQL/MariaDB (replacement for MySQL), PHP (LAMP) are installed on CentOS 7 or RHEL 7.

  • Install RHEL 7 or CentOS 7 server. Open a terminal to the server via ssh, you must have root superuser rights.
  • You will also need knowledge of yum commands
  • You will need the IP address of your server, use the following command to determine the IP address for the eth0 interface
ifconfig eth0 or ip a show eth0 or ip addr list eth0 | awk "/inet /(sub(/\/+/,"",$2); print $2)" or ifconfig eth0 | awk "/inet /(print $2)" 10.180.10.10
  • The resulting IP address 10.180.10.10 will be used to test the installation

So let's get started

Installing Apache on a CentOS 7 /RHEL 7 server

To install the web server, use the command

Yum install httpd

Enable HTTPd Service in Startup

systemctl enable httpd.service ln -s "/usr/lib/systemd/system/httpd.service" "/etc/systemd/system/multi-user.target.wants/httpd.service"

To disable automatic download

Systemctl disable httpd.service rm "/etc/systemd/system/multi-user.target.wants/httpd.service"

Start HTTPd service on CentOS 7 / RHEL 7

systemctl start httpd.service

At this point, you can point your web browser to your server's IP address, http://10.180.10.10. You will see start page apache:

Stopping HTTPd service on CentOS 7 / RHEL 7

systemctl stop httpd.service

Restarting HTTPd service on CentOS 7 / RHEL 7

View apache service status on CentOS 7 / RHEL 7

Make sure the web server is running

Systemctl status httpd.service

Also restarting the web server can be done with the following command

Apachectl graceful

Checking apache / httpd for configuration errors on Centos 7/ RHEL 7

Apachectl configtest

Default HTTPD server configuration:

  1. Default config file: /etc/httpd/conf/httpd.conf
  2. Configuration files, loadable modules: /etc/httpd/conf.modules.d/ (e.g. PHP)
  3. Select MPMs as loadable modules and events: /etc/httpd/conf.modules.d/00-mpm.conf
  4. Standard ports: 80 and 443 (SSL)
  5. Default log files: /var/log/httpd/(access_log,error_log)

Installing MariaDB on a CentOS 7 / RHEL Server

MariaDB is an updated replacement for the MySQL server. On RHEL / CentOS 7, MariaDB database management system is used instead of MySQL. Enter the following yum command to install the MariaDB server:

Yum install mariadb-server mariadb

To start MariaDB, use the command:

Systemctl start mariadb.service

To ensure that the MariaDB service starts automatically at boot time, type:

Systemctl enable mariadb.service

command output

Ln -s "/usr/lib/systemd/system/mariadb.service" "/etc/systemd/system/multi-user.target.wants/mariadb.service"

To stop/restart and disable MariaDB use the following commands:

sudo systemctl stop mariadb.service #-- Stop mariadb server sudo systemctl restart mariadb.service #-- Restart mariadb server sudo systemctl disable mariadb.service #-- Disable autoloading of mariadb server sudo systemctl is-active mariadb.service #-- Check started whether the server?

First launch of MariaDB

Enter the following command:

/usr/bin/mysql_secure_installation

By answering the questions you will be able to configure the initial security of the database

Checking the MariaDB Installation

Enter the following command

MySQL -u root -p

Sample output:

Installing PHP on CentOS 7 / RHEL 7

For PHP installations and modules such as gd / mysql enter the following command

Yum install php php mysql php-gd php-pear

You need to restart the HTTPD (Apache) server, enter:

Systemctl restart httpd.service

To search for all other PHP modules:

Yum search php

To get more detailed information about module:

Yum info php-pgsql

PHP validation on the server

Create a file named /var/www/html/test.php like this:

/var/www/html/test.php

Add the following code:

LAMP server is installed, if you have problems setting up the server, we perform one-time work on installing and configuring the LAMP web server.

Internet