环境是使用lnmp一键安装包搭建的;

1 首先去这个网站下载证书:免费ssl证书

最终会得到两个文件

2:在/usr/local/nginx/conf创建cert目录把这两个文件放进去,这个地址后面有用。

编辑/usr.local/nginx/conf/nginx.conf:添加下面这段:

server {
listen ;
server_name www.domain.cn; #这里改成你的
ssl on;
root /home/wwwroot/default; #你的地址
#下面两个是上面下载的两个文件地址
ssl_certificate /usr/local/nginx/conf/cert/full_chain.pem;
ssl_certificate_key /usr/local/nginx/conf/cert/private.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1. TLSv1.; ssl_prefer_server_ciphers on;
index index.php index.html index.htm; # 优先解析php文件 # 匹配后缀为php的文件
location ~ \.php?.*$
{
root /home/wwwroot/default; # 设置网站根目录
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
location /nginx_status
{
stub_status on; access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}

注意最终格式是http:{server{}}不要把这段写在http外面了

如果有概率出现:No input file specified.但是重启php后正常

vim fastcgi.conf

将下面这行,注释

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

然后,重启lnmp

转自

lnmp给网站增加https - 苏贺贺的个人博客 - CSDN博客 https://blog.csdn.net/qq_41179401/article/details/86104881

php 将http转化为https 小程序部署上线 - 媛媛*小怪兽 - 博客园 https://www.cnblogs.com/dennyxiao/p/9009905.html

lnmp新增https访问【转】的更多相关文章

  1. ubuntu安装nginx和设置网站https访问

    安装nginx 在控制台 输入 sudo apt-get install nginx 等待安装成功之后.可以打开浏览器.输入你的域名或者ip地址会出现"Welcome to nginx!&q ...

  2. Nginx下配置网站ssl实现https访问

    第一步:服务器环境,lnmp即Linux+Nginx+PHP+MySQL,本文中以我的博客为例,使用的是阿里云最低档的vps+免费的Linux服务器管理系统WDCP快速搭建的lnmp环境(同类产品还有 ...

  3. Nginx实现ssl一级、二级域名证书部署并用https访问代理转发服务器

    1.  规划 域名 解析IP Nginx代理 htpps://www.devcult.com 47.88.10.155   htpps://auto.devcult.com 47.88.10.155 ...

  4. 安装配置ingress-nginx支持https访问

    说明: ​ 1.k8s版本:v1.23: ​ 2.内网测试环境1台master,2台node节点,使用 DaemonSet+HostNetwork+nodeSelector 方式部署 ingress- ...

  5. Windows下Nginx配置SSL实现Https访问(包含证书生成)

    Vincent.李   Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...

  6. Tomcat创建HTTPS访问,java访问https

    一 https和ssL HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的 ...

  7. wdcp 下apache模式开启https访问,支持多站点

    1.vi conf/httpd.conf 查找 #Include conf/extra/httpd-ssl.conf (删除行首的配置语句注释符号"#"保存退出) 2.vi con ...

  8. PHP curl https访问问题

    PHP curl https访问问题,原代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /* @String url URL地址  * @Array data P ...

  9. 阿里云Ubuntu 14.04 + Nginx + let's encrypt 搭建https访问

    参考页面: https://certbot.eff.org/#ubuntutrusty-nginx http://bbs.qcloud.com/thread-12059-1-1.html http:/ ...

随机推荐

  1. python(函数调用)

    1.在原文件中调用 def abc(x,y): print x + y abc(2,3) #直接通过函数名加括号进行调用传参 2.同一个包(package)下面调用不同文件中的函数 "&qu ...

  2. 解决 Jumpserver coco 使用登录用户(ldap)进行SSH连接目标主机,忽略系统用户

    前言 Jumpserver 作为国内流行的开源堡垒机,很多公司都在尝试使用,同时 Jumpserver 为了契合众多公司的用户认证,也提供了 LDAP 的用户认证方式,作为 Jumpserver 的用 ...

  3. sqlite3入门之sqlite3_get_table,sqlite3_free_table

    sqlite3_get_table sqlite3_get_table函数原型: int sqlite3_get_table( sqlite3 *db, /* An open database */ ...

  4. react navtagion 头部有返回按钮 标题不居中解决方法

    头部右边写一个隐藏的组件 hederRight:( <View><View> )

  5. Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题

    Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] ​ 总共两次询 ...

  6. machine learning (2)-linear regression with one variable

    machine learning- linear regression with one variable(2) Linear regression with one variable = univa ...

  7. kvm创建win7虚拟机默认只识别2个cpu解决方法

    现在人在部署OpenStack之后会发现按照配额运行Linux的虚拟机没有问题,但是运行windows的虚拟机会发现如果配置2个以上的核则无法识别,windows server也最多支持到4个核.无法 ...

  8. HDFS中的数据块(Block)

    我们在分布式存储原理总结中了解了分布式存储的三大特点: 数据分块,分布式的存储在多台机器上 数据块冗余存储在多台机器以提高数据块的高可用性 遵从主/从(master/slave)结构的分布式存储集群 ...

  9. Apollo简介及工作原理

    一.Apollo简介 1.Apollo是携程框架部门研发的分布式配置中心 2.集中化管理应用的不同环境和不同集群的配置 3.配置修改后能够实时推送到应用端 4.具备规范的权限.流程治理等特性 二.Ap ...

  10. LightOJ - 1058 - Parallelogram Counting(数学,计算几何)

    链接: https://vjudge.net/problem/LightOJ-1058 题意: There are n distinct points in the plane, given by t ...