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

How to view image information in Docker

In this article, we will need to learn how to vie...

Use personalized search engines to find the personalized information you need

Many people now live on the Internet, and searchin...

Details about the like operator in MySQL

1. Introduction When filtering unknown or partial...

Detailed explanation of the usage of position attribute in HTML (four types)

The four property values ​​of position are: 1.rel...

HTML background color gradient effect achieved through CSS style

Effect screenshots: Implementation code: Copy code...

Summary of some HTML code writing style suggestions

Omit the protocol of the resource file It is reco...

uniapp realizes the recording upload function

Table of contents uni-app Introduction HTML part ...

MySQL scheduled task example tutorial

Preface Since MySQL 5.1.6, a very unique feature ...

Can't connect to local MySQL through socket '/tmp/mysql.sock' solution

Error message: ERROR 2002: Can't connect to l...

Docker uses Supervisor to manage process operations

A Docker container starts a single process when i...

How to install and modify the initial password of mysql5.7.18

For Centos installation of MySQL, please refer to...

A brief discussion on event-driven development in JS and Nodejs

Table of contents Event-driven and publish-subscr...