腾讯云轻量应用服务器配置https踩坑

2023-05-16

服务器里有许多应用模板,这些应用装上应可以运行,非常方便,但配置https踩了许多坑,记录一下吧
在这里插入图片描述以WordPress 腾讯云插件版为例,应用信息如下
在这里插入图片描述
SSL证书安装
在这里插入图片描述
点击Nginx服务器证书安装,按照教程做,一般可以顺利安装成功。
坑 的地方在于怎么将网页跳到php应用上,教程中可以看到Https请求Nginx的欢迎页面,按照网上教程或Nginx官网文档怎么设置fastcgi_pass都不好使
解决方案:
/usr/local/lighthouse/softwares/nginx/conf/include 这个文件夹下有一个conf文件,需要修改这个文件(把域名改为你的域名)

server {
        #SSL 访问端口号为 443
        listen 443 ssl;
        #填写绑定证书的域名
        server_name 域名;
        #证书文件名称
        ssl_certificate /root/域名_bundle.crt;
        #私钥文件名称
        ssl_certificate_key /root/域名.key;
        ssl_session_timeout 5m;
        #请按照以下协议配置
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        server_tokens off;

    keepalive_timeout 5;

    root /usr/local/lighthouse/softwares/wordpress-plugin;
    index index.php index.html;

    access_log logs/wordpress.log combinediox;
    error_log logs/wordpress.error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {
        fastcgi_pass   127.0.0.1:9000;

        include fastcgi.conf;

        client_max_body_size 20m;
        fastcgi_connect_timeout 30s;
        fastcgi_send_timeout 30s;
        fastcgi_read_timeout 30s;
        fastcgi_intercept_errors on;
    }
    }




server {
    listen 80 default_server;
    server_tokens off;

    keepalive_timeout 5;

    root /usr/local/lighthouse/softwares/wordpress-plugin;
    index index.php index.html;

    access_log logs/wordpress.log combinediox;
    error_log logs/wordpress.error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {
        fastcgi_pass   127.0.0.1:9000;

        include fastcgi.conf;

        client_max_body_size 20m;
        fastcgi_connect_timeout 30s;
        fastcgi_send_timeout 30s;
        fastcgi_read_timeout 30s;
        fastcgi_intercept_errors on;
    }
}



配置好之后可以访问到WP主页了,但主页没有样式,还需要配置WP

vi /usr/local/lighthouse/softwares/wordpress-plugin/wp-config.php

在你的 wp-config.php 文件中粘贴这段代码,

define('WP_HOME','http://example.com');

define('WP_SITEURL','http://example.com');

如果配置http跳转https, /usr/local/lighthouse/softwares/nginx/conf/include 的conf文件使用下面的配置(把域名改为你的域名)

server {
        #SSL 访问端口号为 443
        listen 443 ssl;
        #填写绑定证书的域名
        server_name 域名;
        #证书文件名称
        ssl_certificate /root/域名_bundle.crt;
        #私钥文件名称
        ssl_certificate_key /root/域名.key;
        ssl_session_timeout 5m;
        #请按照以下协议配置
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        server_tokens off;

    keepalive_timeout 5;

    root /usr/local/lighthouse/softwares/wordpress-plugin;
    index index.php index.html;

    access_log logs/wordpress.log combinediox;
    error_log logs/wordpress.error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {


        fastcgi_pass   127.0.0.1:9000;

        include fastcgi.conf;

        client_max_body_size 20m;
        fastcgi_connect_timeout 30s;
        fastcgi_send_timeout 30s;
        fastcgi_read_timeout 30s;
        fastcgi_intercept_errors on;
    }

    }




server {
    listen 80 default_server;
    server_tokens off;

    keepalive_timeout 5;

    root /usr/local/lighthouse/softwares/wordpress-plugin;
    index index.php index.html;

    access_log logs/wordpress.log combinediox;
    error_log logs/wordpress.error.log;
  server_name 域名;
  server_name www.域名;
  rewrite ^ https://域名$request_uri? permanent;
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

腾讯云轻量应用服务器配置https踩坑 的相关文章

随机推荐

  • opengl实现俄罗斯方块

    include 34 Angel h 34 pragma comment lib 34 glew32 lib 34 include lt cstdlib gt include lt iostream gt include lt time h
  • Mysql学习日记:L20-insert(DML)

    目录 一 insert语法格式 二 insert插入日期 2 1 str to date函数 2 2 date format函数 2 3 date和datetime的区别 三 insert一次插入多条语句 一 insert语法格式 语法格式
  • 解决debian服务器中文显示乱码问题

    由于安装debian选择语言时选择了简体中文安装 xff0c 但内核没有中文字库 xff0c 导致某些字符显示为乱码 xff08 菱形 xff0c 方块 xff09 解决办法 xff1a 普通用户如果没有设置sudo权限 xff0c 首先切
  • 201609-3炉石传说——CCF试题2016年9月第三题

    问题描述 炉石传说 xff1a 魔兽英雄传 xff08 Hearthstone Heroes of Warcraft xff0c 简称炉石传说 xff09 是暴雪娱乐开发的一款集换式卡牌游戏 xff08 如下图所示 xff09 游戏在一个战
  • C语言打印宏定义/枚举变量 名称和变量值

    span class token macro property span class token directive hash span span class token directive keyword include span spa
  • File size exceeds....(文件大小超过限制处理)

    File size exceeds configured limit 2560000 Code insight features not available 原因 xff1a IDEA对能关联的文件大小做了限制 xff0c 主要是为了保护内
  • 第一章-介绍

    介绍 一般建议 什么是游戏引擎 什么是Godot 下载Godot 其他安装方法 Godot UI概述 Project Manager 选择文件名 编辑器窗口 关于节点和场景 Godot中的脚本 关于GDScript 总结 无论你是想要从事的
  • 安装ubuntu系统,报错WslRegisterDistribution failed with error: 0x8007019e

    在windows应用商店安装ubuntu系统 xff0c 报错WslRegisterDistribution failed with error 0x8007019e 1 报错 xff1a Installing this may take
  • 安装Anaconda后,发现文件缺少大量文件

    电脑崩溃修复后 xff0c 使用的Anaconda 居然也崩了 xff0c 重新安装后丢失很多文件 xff0c 然后就是重复的卸载 安装 卸载 xff0c 还是不行 xff0c 我的心态也快要崩了 xff0c 哎 xff0c 就下面图示一样
  • AutoMapping 9 使用入门

    AutoMapping 9语法更改 using AutoMapper using System using System Collections Generic using System Linq using System Text usi
  • Oracle在线练习

    oracle官方的服务 Live SQL xff0c 挺方便的 需要注册一个帐号 访问地址 xff1a https livesql oracle com apex livesql file index html https livesql
  • pyinstaller 打包取消命令行窗口弹出

    pyinstaller F w icon 61 photo ico test py w可以使得exe运行时不弹窗
  • c#有参构造函数中怎么调用其无参构造函数

    class A public A public A int A this 当A a 61 new A 1 时 会先调用无参数的构造函数 在调用有参数那个
  • 使用npm的一些问题

    npm切换为国内的数据源 npm config set registry https span class token punctuation span span class token operator span span class t
  • Caliburn.Micro将枚举 绑定到ComboBox

    参考 https stackoverflow com questions 47480725 caliburn micro enum binding in combobox 上面的文章详细地说明了CM的绑定原理和操作步骤 xff0c 但我需要
  • WPF DataGrid 获取多选项目

    解决方案 xff1a 先附上地址 xff1a https stackoverflow com questions 9880589 bind to selecteditems from datagrid or listbox in mvvm
  • 记一次netcore 3.1 发布失败

    VS版本 xff1a 2019 16 8 5 使用框架 xff1a netcore3 1 问题描述 xff1a 项目可以正常生成 xff0c 但部署模式为独立时 xff0c 不能发布 xff0c 部署模式为依赖框架 xff0c 可以发布 报
  • 在.NET中使用COM组件

    在 NET中使用COM组件 文章目录 在 NET中使用COM组件早期绑定COM对象为COM类型库生成互操作程序集使用COM组件 后期绑定COM对象通过与非托管代码互操作创建COM对象通过平台调用创建COM对象通过C 43 43 Intero
  • Go语言生成dll

    GO语言生成dll 环境dll代码编译调试 环境 操作系统 xff1a win7 64位 go版本 xff1a 1 17 gcc版本 xff1a Thread model win32 gcc version 8 1 0 x86 64 win
  • 腾讯云轻量应用服务器配置https踩坑

    服务器里有许多应用模板 xff0c 这些应用装上应可以运行 xff0c 非常方便 xff0c 但配置https踩了许多坑 xff0c 记录一下吧 以WordPress 腾讯云插件版为例 xff0c 应用信息如下 SSL证书安装 点击Ngin