LNMP deployment and HTTPS Services launch tutorial
What is LNMP: Linux+Nginx+Mysql+ (php-fpm,php-mysql)
That is, the website service architecture of Nginx+Mysql+Php on Linux operating system.
CentOS 6 is MySQL,CentOS 7, Mariadb is Mariadb.
What is the purpose: to provide web services and parse applications of PHP classes
Next, I will deploy phpMyAdmin using the LNMP architecture:
Premise: this operation is carried out on the 172.16.75.1 host
1. Configure a domain name for the web server: www.sss.com
Add a record to the windows/System32/drivers/etc/etc/hosts file under disk C of the physical machine:
172.16.75.1 www.sss.com
two。 Deploy the LNMP schema on the 172.16.75.1 host:
[root@master ~] # yum install nginx mariadb php-fpm php-mysql
Here you may ask, what is the role of php-fpm,php-mysql?
Because Nginx only provides web services and cannot parse PHP applications, php-fpm can
And php-mysql is used to connect PHP applications to Mariadb.
3. Configuration:
[root@master ~] # vim / etc/nginx/nginx.conf
[root@master] # nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successfu
Test the Nginx configuration and enable the service:
[root@master ~] # systemctl start nginx
Enable the php-fpm service:
[root@master ~] # systemctl start php-fpm
Create a directory to store resources, which is defined in nginx.conf:
[root@master ~] # mkdir-pv / myweb/nginx/
I have put the packages of wordpress and phpMyAdmin in this directory beforehand:
First deploy the phpMyAdmin (to manage the database) application
Decompress:
[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 permission is 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 the administrator with an administrative password for the database:
[root@master ~] # mysqladmin-paired 'password' 111111'Enter password:
After completion, test the access on the web side:
This completes the phpMyAdmin deployment.
Next, provide https services for phpMyAdmin:
[root@master] # cd / etc/pki/CA/ [root@master CA] # (umask 077 position 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 3653Using configuration from / etc/pki/tls/openssl.cnfCheck that the request matches the signatureSignature okCertificate 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
Restart the nginx service after testing:
[root@master ssl] # nginx-t [root@master ssl] # nginx-s reload
Web side testing:
Https service implementation.