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

Two implementations of front-end routing from vue-router

Table of contents Mode Parameters HashHistory Has...

Detailed explanation of mysql execution plan id is empty (UNION keyword)

Introduction During the work process, slow querie...

Detailed tutorial on using VMware WorkStation with Docker for Windows

Table of contents 1. Introduction 2. Install Dock...

10 bad habits to avoid in Docker container applications

There is no doubt that containers have become an ...

Sample code for implementing rolling updates of services using Docker Swarm

1. What is Docker Swarm? Docker Swarm is a cluste...

Example of implementing a virtual list in WeChat Mini Program

Table of contents Preface analyze Initial Renderi...

JavaScript+html to implement front-end page sliding verification

This article shares the specific code of JavaScri...

HTML set as homepage and add to favorites_Powernode Java Academy

How to implement the "Set as homepage" ...

HTML structured implementation method

DIV+css structure Are you learning CSS layout? Sti...