title: "Lnmp + Https"
date: 2019-08-28T16:18:20+08:00
draft: true
---

注:我的linux的ip地址为192.168.0.104

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

下载lnmp软件包

wget http://soft.vpser.net/lnmp/lnmp1.6-full.tar.gz

LNMP+HTTPS Linux 第1张

解压

tar -zxvf lnmp1.6-full.tar.gz

运行lnmp执行脚本

cd lnm1.6-full
./install.sh lnmp

选择数据库

LNMP+HTTPS Linux 第2张

输入密码,启用MySQL InnoDB

LNMP+HTTPS Linux 第3张

选择PHP

LNMP+HTTPS Linux 第4张

成功安装

LNMP+HTTPS Linux 第5张

访问192.168.0.104页面

LNMP+HTTPS Linux 第6张

在nginx的server家目录(默认是在/home/wwweoot/default)中添加一个index.php

<? php
    phpinfo();
?>

访问index.php,测试nginx与php是否关联

LNMP+HTTPS Linux 第7张

生成一个RSA密钥

mkdir /usr/local/nginx/conf/cert
cd /usr/local/nginx/conf/cert
openssl genrsa -des3 -out server.key 1024

根据server.key生成证书请求

openssl req -new -key server.key -out server.csr

拷贝一个不需要输入密码的密钥文件

openssl rsa -in server.key -out server_nopass.key

自己签约证书

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

在nginx.conf配置文件中添加ssl的基本信息

listen 80;
root /home/wwwroot/default
server_name _;
index index.html index.php;

listen 443 ssl;
# ssl on;
ssl_certificate /usr/local/nginx/conf/cert/server.crt;
ssl_certificate_key /usr/local/nginx/conf/cert/server_nopass.key;
#error_page  403 http://www.abc.com/;     
ssl_session_cache    shared:SSL:1m;
ssl_session_timeout  5m;
ssl_ciphers  HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers  on;

安装nss

yum install openssl mod_nss crypto-utils

修改nss.conf配置文件

Listen 443
VirtualHost _default_:443
NSSCertificateDatabase  /etc/httpd/alias
NSSPassPhraseDialog  file:/etc/httpd/nss-db-password.conf

其中 /etc/httpd/nss-db-password.conf 只包含以下一行,其中 123456是后面你为 NSS 数据库设置的密码

internal:123456

用apache来检查是否加载了nss模块

apache -M | grep nss

LNMP+HTTPS Linux 第8张

为 NSS 数据库设置一个密码

certutil -W -d /etc/httpd/alias

用 genkey 命令为 box1 创建有效期为 365 天的 NSS 兼容证书

genkey --nss --days 365 box1

LNMP+HTTPS Linux 第9张
LNMP+HTTPS Linux 第10张
LNMP+HTTPS Linux 第11张
LNMP+HTTPS Linux 第12张
LNMP+HTTPS Linux 第13张
LNMP+HTTPS Linux 第14张

列出现有的证书

certutil –L –d /etc/httpd/alias

用https来访问服务器

注:若无法成功则reboot虚拟机
LNMP+HTTPS Linux 第15张
LNMP+HTTPS Linux 第16张

下载博客或论坛模板

https://wp.xz.cn/
https://github.com/purple910/Linux/releases

解压

unzip Discuz_X3.2_SC_UTF8.zip
unzip wordpress-5.3.2.zip

将其主要文件复制到nginx的root目录下

cp -fr upload /home/wwwroot/default
cp -fr wordpress /home/wwwroot/default

安装博客

LNMP+HTTPS Linux 第17张
LNMP+HTTPS Linux 第18张
LNMP+HTTPS Linux 第19张
LNMP+HTTPS Linux 第20张
LNMP+HTTPS Linux 第21张
LNMP+HTTPS Linux 第22张
LNMP+HTTPS Linux 第23张
LNMP+HTTPS Linux 第24张

安装论坛

LNMP+HTTPS Linux 第25张
LNMP+HTTPS Linux 第26张

添加权限

chmod -Rf 777 /home/wwwroot/default/upload/config
chmod -Rf 777 /home/wwwroot/default/upload/data
chmod -Rf 777 /home/wwwroot/default/upload/uc_client
chmod -Rf 777 /home/wwwroot/default/upload/uc_server

LNMP+HTTPS Linux 第27张
LNMP+HTTPS Linux 第28张
LNMP+HTTPS Linux 第29张
LNMP+HTTPS Linux 第30张
LNMP+HTTPS Linux 第31张
LNMP+HTTPS Linux 第32张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄