Tutorial on how to deploy LNMP and enable HTTPS service

Tutorial on how to deploy LNMP and enable HTTPS service

What is LNMP: Linux+Nginx+Mysql+(php-fpm,php-mysql)

That is, the website service architecture of Nginx+Mysql+Php on the Linux operating system.

MySQL in CentOS 6 and MariaDB in CentOS 7

What is the role: Provide web services and can parse PHP-like applications;

Next, I will use the LNMP architecture to deploy phpMyAdmin:

Prerequisite: All operations are performed on the host 172.16.75.1;

1. Configure a domain name for the web server: www.sss.com

Add a record to the windows/System32/drivers/etc/etc/hosts file in the C drive of the physical machine:

172.16.75.1 www.sss.com

2. Deploy the LNMP architecture on the 172.16.75.1 host:

[root@master ~]# yum install nginx mariadb php-fpm php-mysql

Here, everyone may ask, what are the functions of php-fpm and php-mysql?

Because Nginx only provides web services and cannot parse PHP applications, while php-fpm can

And php-mysql is used to connect PHP applications and Mariadb;

3. Configuration:

[root@master ~]# vim /etc/nginx/nginx.conf

[root@master ]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Test that Nginx configuration is correct and start the service:

[root@master ~]# systemctl start nginx

Start the php-fpm service:

[root@master ~]# systemctl start php-fpm

Create a directory to store resources, which has been defined in nginx.conf:

[root@master ~]# mkdir -pv /myweb/nginx/

I have already placed the wordpress and phpMyAdmin packages in this directory:

First deploy the phpMyAdmin application (used to manage the database)

Unzip:

[root@master ~]# cd /myweb/nginx/
[root@master nginx]# tar -xf phpMyAdmin-3.5.4-all-languages.tar.gz 
[root@master nginx]# mv phpMyAdmin-3.5.4-all-languages ​​pma

Create a directory session under /var/lib/php:

The owner is root, the group is apache, and the permissions are 770;

[root@master ~]# cd /var/lib/php
[root@master php]# mkdir session
[root@master php]# chown root:apache session/
[root@master php]# chmod 770 session/

Configure a database management password for the administrator:

[root@master ~]# mysqladmin -p'' password '111111'
Enter password:

After completion, perform access test on the web side:


This completes the phpMyAdmin deployment.

Next, provide https service for phpMyAdmin:

[root@master ~]# cd /etc/pki/CA/
[root@master CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
[root@master CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3653
[root@master CA]# touch index.txt
[root@master CA]# echo 01 > serial
[root@master ssl]# (umask 077; openssl genrsa -out nginx.key 2048)
[root@master ssl]# openssl req -new -key nginx.key -out nginx.csr -days 3653
[root@master ssl]# openssl ca -in nginx.csr -out /etc/pki/CA/certs/nginx.crt -days 3653
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
  Serial Number: 1 (0x1)
  Validity
   Not Before: Nov 12 14:15:57 2018 GMT
   Not After : Nov 12 14:15:57 2028 GMT
  Subject:
   countryName = CN
   stateOrProvinceName = Hebei
   organizationName = james
   organizationalUnitName = james.edu
   commonName = www.james.com
  X509v3 extensions:
   X509v3 Basic Constraints: 
    CA:FALSE
   Netscape Comment: 
    OpenSSL Generated Certificate
   X509v3 Subject Key Identifier: 
    5A:68:D6:47:29:DA:A5:29:98:09:0D:82:02:2D:B1:5D:61:8A:26:EC
   X509v3 Authority Key Identifier: 
    keyid:32:B2:8D:AC:68:57:FC:BF:8B:F2:CA:68:8B:45:93:D4:7F:A2:25:F3
    
  
[root@master ssl]# scp /etc/pki/CA/certs/nginx.crt ./
[root@master ssl]# rm -f nginx.csr

Modify the nginx configuration file:

[root@master ssl]# vim /etc/nginx/nginx.conf

After the detection is correct, restart the nginx service:

[root@master ssl]# nginx -t
[root@master ssl]# nginx -s reload

Web test:

https service implementation.

You may also be interested in:
  • LNMP series tutorial: SSL installation WordPress blog (program download and installation)
  • Tutorial on installing WordPress in VPS using LNMP
  • Tencent Cloud Host Installation LNMP Environment and WordPress Tutorial
  • Tutorial on installing and configuring the blogging program Typecho on the Nginx server
  • Nginx service LNMP WordPress deployment process steps

<<:  How to use Vue-router routing

>>:  MySQL and MySQL Workbench Installation Tutorial under Ubuntu

Recommend

Detailed explanation of Vue development website SEO optimization method

Because the data binding mechanism of Vue and oth...

React hooks pros and cons

Table of contents Preface advantage: shortcoming:...

A brief analysis of different ways to configure static IP addresses in RHEL8

While working on a Linux server, assigning static...

Summary of common Linux distribution mirror source configuration

I have been researching Linux recently and tried ...

MySQL 8.0.21.0 Community Edition Installation Tutorial (Detailed Illustrations)

1. Download MySQL Log in to the MySQL official we...

Detailed explanation of how to adjust Linux command history

The bash history command in Linux system helps to...

Detailed explanation of html download function

The new project has basically come to an end. It ...

Three networking methods and principles of VMware virtual machines (summary)

1. Brigde——Bridge: VMnet0 is used by default 1. P...

What does the "a" in rgba mean? CSS RGBA Color Guide

RGBA is a CSS color that can set color value and ...

HTML Grammar Encyclopedia_HTML Language Grammar Encyclopedia (Must Read)

Volume Label, Property Name, Description 002 <...

Problems with index and FROM_UNIXTIME in mysql

Zero, Background I received a lot of alerts this ...