环境是使用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

最新文章

  1. javax.servlet.http.HttpServlet was not found
  2. window.open()&&window.showmodaldialog()
  3. NVARCHAR 和VARCHAR区别和使用
  4. Java学习笔记之_JDBC
  5. oracle基本语句
  6. FLASH CC 2015 CANVAS (五)loading的制作
  7. 通过文件流stream下载文件
  8. or1200下raw-os学习(任务篇)
  9. struts2 jsp表单提交后保留表单中输入框中的值 下拉框select与input
  10. Linux按照时间查找文件
  11. Android触控屏幕Gesture(GestureDetector和SimpleOnGestureListener的使用教程)
  12. Foursquare 8.0 :聪明人给互联网公司上的流量转化课
  13. MySQL5.7 安装过程中出现 attempting to start service 过不去
  14. 中文格式python 打印json格式的数据中文显示问题
  15. java 类中的属性为什么一般都是私有的
  16. DesignPatternPrinciple(设计模式原则)二
  17. fitnesse - 安装部署
  18. overflow-x后覆盖滚动条
  19. 微信分享链接出现config:invalid signature错误的解决方法
  20. NLP 依存分析

热门文章

  1. Analysis of Autherntication Protocol with Scyther :Case Study ---补充整理
  2. Spring-Security-Oauth2 基于JDBC存储令牌和RBAC权限认证
  3. 【转】以Python为例的Async / Await的编程基础
  4. python 判断返回值是否是字典
  5. machine learning (3)---Linear Algebra Review
  6. 创建型模式(过渡模式) 简单工厂模式(Simple Factory)
  7. used to do 与be used to doing /n.
  8. 黄杉杉 --java第七次作业
  9. linux autofs自动挂载
  10. django使用redis