网站建设饣首选金手指,北京logo设计,推广网站怎么做,网络营销推广方法和手段一、Nginx
Nginx是一款高性能的开源Web服务器和反向代理服务器#xff0c;被广泛用于构建现代化的Web应用和提供静态内容。
nginx官网 这里下载nginx-1.24.0-zip
Nginx是一款高性能的开源Web服务器和反向代理服务器#xff0c;被广泛用于构建现代化的Web应用和提供静态内…一、Nginx
Nginx是一款高性能的开源Web服务器和反向代理服务器被广泛用于构建现代化的Web应用和提供静态内容。
nginx官网 这里下载nginx-1.24.0-zip
Nginx是一款高性能的开源Web服务器和反向代理服务器被广泛用于构建现代化的Web应用和提供静态内容。 Nginx是位于互联网和后端基础设置之间的网关当你访问网络应用程序时请求(request)会首先发送到网络服务器Nginx会查看请求的资源并确定资源在服务器上的位置然后将其作为响应response发送回客户端浏览器。
在浏览器的开发者工具中依次点击NetworkHeaders和Name中的资源即可在Response headers中即响应的服务器标头找到Server:nginx。2023-11-17_181848-server为nginx.png
Nginx在高流量站点中非常受欢迎因为它的事件驱动架构大概可以同时处理超过10000个同时连接。 Nginx常用来做反向代理充当指挥中心(红绿灯)将负载合理分配到多个后端服务器同时还提供安全性和缓存以实现更好的性能。
二、CentOS7.9 2009下安装配置nginx
CentOS7.9 2009下安装配置nginx可参考我这篇文章 Windows11与CentOS7.9 2009下安装配置nginx后启动整个项目中的 二、CentOS7.9 2009下安装配置nginx
完整安装命令如下(完整安装命令的执行过程截图见上方博客链接)
//1-安装依赖项
sudo yum install gcc pcre-devel zlib-devel openssl-devel//2-下载Nginx源码包
//2-1-下载Nginx源码包
从https://nginx.org/en/download.html查找最新的版本使用Stable version版本。
nginx-1.24.0.tar.gz
//2-2--将下载好的tar包上传到centos701的目录中 /usr/local nginx-1.24.0.tar.gz或者//2-下载Nginx源码包
//或者直接复制tar包链接(在Windows中右击复制tar包下载链接)//2-1 CentOS系统安装wget
yum install wget -y
//2-2 Debian/Ubuntu系统安装wget需要执行以下命令
apt-get install -y wget//2-2-使用wget获取nginx-1.24.0.tar.gz
wget https://nginx.org/download/nginx-1.24.0.tar.gz3、安装
//3-1、解压安装包nginx-1.24.0.tar.gz
tar -zxvf nginx-1.24.0.tar.gz//3-2、进入解压后的目录nginx-1.24.0
cd nginx-1.24.0/4、 配置编译选项包括启用HTTPS支持
//注意这里的目录就是/usr/local/nginx1.24.0
//如果报错就执行4-1、安装依赖项
//说明因为后续需要安装SSL证书所以添加了几个模块如果不需要可以执行./configure 。
./configure --prefix/usr/local/nginx1.24.0 --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module参数说明
--prefixpath默认路径为/usr/local/nginx可不配置。
--with-http_ssl_module配置Nginx以启用HTTPS模块。
--with-http_v2_module配置Nginx以启用HTTP2模块。
--with-http_stub_status_module启用状态监控模块允许查看Nginx的运行状态和统计信息。说明因为后续需要安装SSL证书所以添加了几个模块如果不需要可以执行./configure 。//4-1、安装依赖项
执行yum -y install gcc openssl-devel pcre-devel zlib-devel
----
报错2023-9-5 02:33:41
[rootlocalhost nginx-1.24.0]# ./configure --prefix/usr/local/nginx1.24.0 --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module
checking for OS Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... not found./configure: error: C compiler cc is not found执行yum -y install gcc openssl-devel pcre-devel zlib-devel 后
再次执行./configure --prefix/usr/local/nginx1.24.0 --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module
不会再报错。
----//4-2、编译和安装Nginx
//编译安装完成后会发现多了一个nginx1.24.0文件夹
make make install 或者分别执行//4-2、编译和安装Nginx
//编译安装完成后会发现多了一个nginx1.24.0文件夹
//编译
make
//安装
sudo make install//5、启动Nginx
//关闭防火墙
systemctl stop firewalld或systemctl stop firewalld.service//进入nginx-1.24.0编译和安装生成的目录nginx1.24.0/sbin
cd /usr/local/nginx1.24.0/sbin//启动nginx
./nginx或者
sudo nginx//6、查看nginx的进程
yum install net-tools -y
netstat -lntup | grep nginx//查看启动的nginx进程
ps -ef | grep nginxyum install lsof
lsof -i :80//7、关闭nginx
./nginx -s stop
三、nginx.conf的配置
3.1 用户名和日志
在大多数情况下Nginx安装在linux服务器上配置文件nginx.conf位于conf目录下(例如/usr/local/nginx1.24.0/conf/nginx.conf)可以在nginx.conf文件中通过配置指令值来指定服务器的行为。
指令值是键值对key value,后跟大括号例如http{ }则为上下文context内部包含更多指令。
在全局上下文main或者global context(即http{}外面部分)中可以设置用户名user和错误日志error_log等内容。但大多数配置都在http{}上下文context中完成。 注意在nginx.conf中#号表示注释不生效。
#user值为用户名
user nobody;
#error_log 为错误日志
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;3.2 配置静态内容
Nginx提供静态内容例如图像和HTML,可以在http上下文context中处理这个问题。在其中定义一个或者多个服务器每个服务器通过端口来区分。
Nginx将跟踪对服务器的每个请求可以将其写入访问日志access.log。最重要的是告诉服务器在那里可以找到原始文件在位置上下文location{}中配置此操作。
现在当用户导航到我们的服务器域名或者服务器IP时知道文件系统哪里可以找到index.html文件并且我们可以根据需要设置第二个位置来将任何图像的格式与目录相匹配。
#user值为用户名
#在全局上下文main或者global context(即http{}外面部分)
#user nobody;
#error_log 为错误日志
#error_log logs/error.log;#此处为http上下文context外在全局上下文main或者global context(即http{}外面部分) 中http{#此处为http上下文context中server{#端口listen 80;#访问日志access.logaccess_log /var/log/nginx/access.loglocation / {#/app/www 文件夹有index.html文件。root /app/www }location ~ \.(gif|jpg|png)${#并且我们可以需要设置第二个位置来将任何图像的格式与目录相匹配。#/app/images目录中有png等格式的图片root /app/images}}
}在服务器配置nginx.conf中处理的其他常见事项大概包括配置SSL证书重写和路由到代理服务器 当使用代理服务器(proxy_pass)替换root时可以指向不同的服务器。
#user值为用户名
#在全局上下文main或者global context(即http{}外面部分)
#user nobody;
#error_log 为错误日志
#error_log logs/error.log;#此处为http上下文context外在全局上下文main或者global context(即http{}外面部分) 中http{#此处为http上下文context中server{#端口listen 80;#访问日志access.logaccess_log /var/log/nginx/access.loglocation / {#/app/www 文件夹有index.html文件。#root /app/www #当使用代理服务器(proxy_pass)替换root时可以指向不同的服务器proxy_pass http://192.66.55.44:2096}}}//2023-11-17 19:07:14
//创建一个反向代理可以处理缓存匿名和负载平衡。server {listen 2096;root /app/www;location /{}}
四、nginx.conf
4.1 默认的nginx.conf的配置
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main $remote_addr - $remote_user [$time_local] $request # $status $body_bytes_sent $http_referer # $http_user_agent $http_x_forwarded_for;#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
4.2 /目录中html目录下的dist的nginx.conf配置
在服务器的/目录下新建文件夹html,将dist文件夹上传到此html目录中 dist文件夹为前端打好的包。
dist,即distribution,是Vue打包后生成的默认目录名称,里面包含了前端项目所需要的HTML、CSS、JavaScript等资源文件。
npm run build 一般来说都是这个打包命令。
打包命令根据package.json文件中的命令中的配置来写下面的打包命令就是npm run build:prodprod是production的缩写意思是打生产环境的包其中的 SET NODE_OPTIONS--openssl-legacy-provider 是为了解决Node.js版本过高的问题(Error:0308010C:digital envelope routines::unsupported)而添加的。 详情见我这篇文章 IDEA中Node.js环境下npm报错Error:0308010C:digital envelope routines:unsupported
npm相关安装配置等参考我这篇文章 安装配置nvm-windows对Node.js与npm进行版本控制
package.json文件中的命令中配置的打包命令 scripts: {dev: SET NODE_OPTIONS--openssl-legacy-provider vue-cli-service serve,build:prod: SET NODE_OPTIONS--openssl-legacy-provider vue-cli-service build,preview: node build/index.js --preview,lint: eslint --ext .js,.vue src},注意yarn init或者npm init执行输入信息后会生成package.json文件。 参考我这篇文章安装并配置使用包管理工具-Yarn
启动防火墙同时开放nginx80端口 参考我这篇 查看CentOS版本及系统位数与设置CentOS 7.9 2009 防火墙配置放开端口的命令与过程
//禁止防火墙开机启动。这种方法方便但不安全。
systemctl disable firewalld下面 设置CentOS7.9 2009 防火墙配置放开端口80//1-防火墙设置开机自启
systemctl enable firewalld//2-查询防火墙状态
systemctl status firewalld//3-启动防火墙
systemctl start firewalld
//关闭防火墙
systemctl stop firewalld//4-查询防火墙状态确保已经启动active(running)
systemctl status firewalld//5-查看防火墙是否放行nginx80端口 no代表没开80端口,yes表示已开nginx80端口。
firewall-cmd --query-port80/tcp//6-设置永久放行Nginx80端口”–permanent“参数表示永久生效没有此参数重启后失效表示重启后80端口无法通过。
firewall-cmd --add-port80/tcp --permanent//7-【设置永久放行Nginx80端口重启防火墙后才能查询到防火墙已经放行Nginx80端口。】
//返回no,需要重启防火墙才能更新为yes
firewall-cmd --query-port80/tcp
//#重启防火墙
systemctl restart firewalld
//返回yes表示永久放行Nginx80端口
//重启防火墙后再次查看就是yes,表示80端口已经永久放行
firewall-cmd --query-port80/tcp
/目录中html目录下的dist的nginx.conf配置如下 #user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main $remote_addr - $remote_user [$time_local] $request # $status $body_bytes_sent $http_referer # $http_user_agent $http_x_forwarded_for;#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {#多个nginx指定不同端口(设置访问端口)listen 8083;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root /html/dist;index index.html index.htm;try_files $uri $uri/ /index.html;}#2023-8-9 02:30:13location /api{rewrite ^/api/(.*)$ /$1 break;proxy_pass http://localhost:9092;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}访问成功
4.3 将dist包上传到指定目录/deploy/ruoyicloud_ui/中
参考我的这篇博客[Windows11与CentOS7.9 2009下安装配置nginx后启动整个项目] 中的 三、配置CentOS7.9 2009中nginx开机自启 与 4.4 部署dist包 。
4.3.1 配置CentOS7.9 2009中nginx开机自启
参考我的这篇博客[Windows11与CentOS7.9 2009下安装配置nginx后启动整个项目] 中的 三、配置CentOS7.9 2009中nginx开机自启 。
4.3.1.1 命令
//1-修改rc.local文件的配置
//rc.local是个文件
//在/etc/rc.d/rc.local文件的末尾添加 /usr/local/nginx1.24.0/sbin/nginx此程序文件的配置//查看系统是否安装完整vim如果正常安装肯定不止一行
rpm -qa|grep vim
//安装vim所有相关的包yum -y install vim*//2-修改rc.local文件
vim /etc/rc.d/rc.local//查看是否配置成功 cat /etc/rc.d/rc.local//3-赋予执行权限必须运行这个命令来确保boot时脚本能够被执行
chmod x /etc/rc.d/rc.local
4.3.1.2 截图 修改rc.local文件 : vim /etc/rc.d/rc.local
查看是否配置成功 : cat /etc/rc.d/rc.local 3-赋予执行权限必须运行这个命令来确保boot时脚本能够被执行 目前所有用户均无执行权限。 chmod x /etc/rc.d/rc.local 赋予执行权限 赋予执行权限后rc.local文件名称颜色会变成绿色变深 所有用户都拥有了执行权限 重新启动服务器CentOS7.9 2009后nginx已经可以开机自启直接访问了不需要再去执行./nginx 启动命令了(此处在nginx中部署了前端的dist包)
//启动nginx
cd /usr/local/nginx1.24.0/sbin
./nginx
或
./nginx -c /usr/local/nginx1.24.0/conf/nginx.conf查看nginx的进程 :
//查看nginx的进程
yum install net-tools -y
netstat -lntup | grep nginx//查看启动的nginx进程
ps -ef | grep nginxyum install lsof
lsof -i :804.3.2 将dist包上传到指定目录/deploy/ruoyicloud_ui/中
参考我的这篇博客[Windows11与CentOS7.9 2009下安装配置nginx后启动整个项目] 中的 4.4 部署dist包 。 查看/deploy/ruoyicloud_ui/dist的项目结构 修改nginx.conf中的配置
配置nginx.conf /usr/local/nginx1.24.0/conf /usr/local/nginx1.24.0/conf/nginx.conf
文件内容太多为了便于修改以及避免错误建议下载到Windows中配置配置好再上传回去。
//命令修改 vim /usr/local/nginx1.24.0/conf/nginx.conf
修改nginx.conf中root html为root /deploy/ruoyicloud_ui/dist 访问打好的dist包即我们刚刚上传的dist包所在的位置。
修改nginx.conf中的server_name localhost为server_name 192.168.1.16。
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main $remote_addr - $remote_user [$time_local] $request # $status $body_bytes_sent $http_referer # $http_user_agent $http_x_forwarded_for;#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;#server_name localhost;server_name 192.168.1.16;#charset koi8-r;#access_log logs/host.access.log main;location / {#root html;root /deploy/ruoyicloud_ui/dist;index index.html index.htm;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apaches document root# concurs with nginxs one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
重新加载配置文件nginx.conf : 因为刚刚修改了配置文件nginx.conf(修改nginx.conf中root html为root /deploy/ruoyicloud_ui/dist 访问打好的dist包和修改nginx.conf中的server_name localhost为server_name 192.168.1.16。)所以要重新加载配置文件nginx.conf。
//检查Nginx配置是否正确,如果配置没有错误将显示一条成功消息
cd /usr/local/nginx1.24.0/sbin
./nginx -t
或者/usr/local/nginx1.24.0/sbin/nginx -t//如果需要修改配置文件 修改之后要重新加载配置文件
cd /usr/local/nginx1.24.0/sbin
./nginx -s reload//启动nginx
cd /usr/local/nginx1.24.0/sbin
./nginx
或
./nginx -c /usr/local/nginx1.24.0/conf/nginx.conf#关闭nginx
cd /usr/local/nginx1.24.0/sbin
./nginx -s stop # 停止检查Nginx配置是否正确 //检查Nginx配置是否正确,如果配置没有错误将显示一条成功消息 cd /usr/local/nginx1.24.0/sbin ./nginx -t 或者/usr/local/nginx1.24.0/sbin/nginx -t
到这一步前端dist包就部署到了nginx中nginx还设置了nginx开机自启意味着打开服务器就可以直接访问到前端界面(地址http://192.168.1.16:80)。
五、Nginx 服务器 SSL 证书安装部署(参考腾讯云官方文章)
参考Nginx 服务器 SSL 证书安装部署 最近更新时间2023-11-13 10:26:11 (现在是2023-11-18 19:05:37 5天前更新的) 参考的腾讯云文章链接中有视频进一步介绍在 Nginx 服务器安装 SSL 证书的操作过程。
5.1 证书安装
参考Nginx 服务器 SSL 证书安装部署 本文档指导您如何在 Nginx 服务器中安装 SSL 证书。 说明 本文档以证书名称 cloud.tencent.com 为例。 Nginx 版本以 nginx/1.18.0 为例。 当前服务器的操作系统为 CentOS 7由于操作系统的版本不同详细操作步骤略有区别。 安装 SSL 证书前请您在 Nginx 服务器上开启 HTTPS 默认端口 443避免证书安装后无法启用 HTTPS。具体可参考 服务器如何开启443端口 SSL 证书文件上传至服务器方法可参考 如何将本地文件拷贝到云服务器。 SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全Transport Layer SecurityTLS是为网络通信提供安全及数据完整性的一种安全协议SSL端口号是443。TLS与SSL在传输层对网络连接进行加密。 第6步.编辑 Nginx 根目录下的 nginx.conf 文件。修改内容如下 说明如找不到以下内容可以手动添加。可执行命令 nginx -t 找到nginx的配置文件路径。 此操作可通过执行 vim /etc/nginx/nginx.conf 命令行编辑该文件。 由于版本问题配置文件可能存在不同的写法。 例如Nginx 版本为 nginx/1.15.0 以上请使用 listen 443 ssl 代替 listen 443 和 ssl on。 server {#SSL 默认访问端口号为 443listen 443 ssl; #请填写绑定证书的域名server_name cloud.tencent.com; #请填写证书文件的相对路径或绝对路径ssl_certificate cloud.tencent.com_bundle.crt; #请填写私钥文件的相对路径或绝对路径ssl_certificate_key cloud.tencent.com.key; ssl_session_timeout 5m;#请按照以下协议配置ssl_protocols TLSv1.2 TLSv1.3; #请按照以下套件配置配置加密套件写法遵循 openssl 标准。ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on;location / {#网站主页路径。此路径仅供参考具体请您按照实际目录操作。#例如您的网站主页在 Nginx 服务器的 /etc/www 目录下则请修改 root 后面的 html 为 /etc/www。root html; index index.html index.htm;}}通过执行以下命令验证配置文件问题。若存在错误重新配置或者根据提示修改存在问题。
nginx -t通过执行以下命令重载 Nginx。重载成功即可使用。
nginx -s reload5.2 HTTP 自动跳转 HTTPS 的安全配置可选
如果您需要将 HTTP 请求自动重定向到 HTTPS。您可以通过以下操作设置 1. 根据实际需求选择以下配置方式 在页面中添加 JS 脚本。 在后端程序中添加重定向。 通过 Web 服务器实现跳转。
Nginx 支持 rewrite 功能。若您在编译时没有去掉 pcre您可在 HTTP 的 server 中增加 return 301 https://$host$request_uri;即可将默认80端口的请求重定向为 HTTPS。 修改如下内容 说明 1、未添加注释的配置语句您按照下述配置即可。 2、由于版本问题配置文件可能存在不同的写法。例如Nginx 版本为 nginx/1.15.0 以上请使用 listen 443 ssl 代替 listen 443 和 ssl on。 server {#SSL 默认访问端口号为 443listen 443 ssl;#请填写绑定证书的域名server_name cloud.tencent.com; #请填写证书文件的相对路径或绝对路径ssl_certificate cloud.tencent.com_bundle.crt; #请填写私钥文件的相对路径或绝对路径ssl_certificate_key cloud.tencent.com.key; ssl_session_timeout 5m;#请按照以下套件配置配置加密套件写法遵循 openssl 标准。ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;#请按照以下协议配置ssl_protocols TLSv1.2 TLSv1.3;ssl_prefer_server_ciphers on;location / {#网站主页路径。此路径仅供参考具体请您按照实际目录操作。 #例如您的网站主页在 Nginx 服务器的 /etc/www 目录下则请修改 root 后面的 html 为 /etc/www。root html;index index.html index.htm;}
}
server {listen 80;#请填写绑定证书的域名server_name cloud.tencent.com; #把http的域名请求转成httpsreturn 301 https://$host$request_uri;
}通过执行以下命令验证配置文件问题。若存在错误重新配置或者根据提示修改存在问题。
nginx -t通过执行以下命令重载 Nginx。重载成功即可使用。
nginx -s reload如果浏览器地址栏显示安全锁标识则说明证书安装成功。 如果网站访问异常可参考以下常见问题解决方案进行处理 无法使用 HTTPS 访问网站 部署 SSL 证书后浏览器提示 “网站连接不安全” 访问站点提示连接不安全 SSL 证书过期后重新申请部署依然提示 HTTPS 不安全 在服务器上部署 SSL 证书后访问资源出现 404 报错
5.3 实操截图
六、参考
nginx官网 Nginx 服务器 SSL 证书安装部署 Nginx 服务器 SSL 证书安装部署-pdf Windows11与CentOS7.9 2009下安装配置nginx后启动整个项目
我的相关博客 打包命令根据package.json文件中的命令中的配置来写下面的打包命令就是npm run build:prodprod是production的缩写意思是打生产环境的包其中的 SET NODE_OPTIONS--openssl-legacy-provider 是为了解决Node.js版本过高的问题(Error:0308010C:digital envelope routines::unsupported)而添加的。 详情见我这篇文章 IDEA中Node.js环境下npm报错Error:0308010C:digital envelope routines:unsupported
npm相关安装配置等参考我这篇文章 安装配置nvm-windows对Node.js与npm进行版本控制
注意yarn init或者npm init执行输入信息后会生成package.json文件。 参考我这篇文章安装并配置使用包管理工具-Yarn
启动防火墙同时开放nginx80端口 参考我这篇 查看CentOS版本及系统位数与设置CentOS 7.9 2009 防火墙配置放开端口的命令与过程 文章转载自: http://www.morning.qsy41.cn.gov.cn.qsy41.cn http://www.morning.zhiheliuxue.com.gov.cn.zhiheliuxue.com http://www.morning.trlhc.cn.gov.cn.trlhc.cn http://www.morning.hwljx.cn.gov.cn.hwljx.cn http://www.morning.kzrbn.cn.gov.cn.kzrbn.cn http://www.morning.cljpz.cn.gov.cn.cljpz.cn http://www.morning.yrnrr.cn.gov.cn.yrnrr.cn http://www.morning.lmfmd.cn.gov.cn.lmfmd.cn http://www.morning.qwqzk.cn.gov.cn.qwqzk.cn http://www.morning.brwp.cn.gov.cn.brwp.cn http://www.morning.bfrsr.cn.gov.cn.bfrsr.cn http://www.morning.xdjwh.cn.gov.cn.xdjwh.cn http://www.morning.bfmq.cn.gov.cn.bfmq.cn http://www.morning.rnds.cn.gov.cn.rnds.cn http://www.morning.yrlfy.cn.gov.cn.yrlfy.cn http://www.morning.shawls.com.cn.gov.cn.shawls.com.cn http://www.morning.klpwl.cn.gov.cn.klpwl.cn http://www.morning.gywfp.cn.gov.cn.gywfp.cn http://www.morning.lpnb.cn.gov.cn.lpnb.cn http://www.morning.rmfw.cn.gov.cn.rmfw.cn http://www.morning.fstesen.com.gov.cn.fstesen.com http://www.morning.rchsr.cn.gov.cn.rchsr.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.nqrfd.cn.gov.cn.nqrfd.cn http://www.morning.nkjkh.cn.gov.cn.nkjkh.cn http://www.morning.wdykx.cn.gov.cn.wdykx.cn http://www.morning.zpstm.cn.gov.cn.zpstm.cn http://www.morning.rzczl.cn.gov.cn.rzczl.cn http://www.morning.msgrq.cn.gov.cn.msgrq.cn http://www.morning.dkqr.cn.gov.cn.dkqr.cn http://www.morning.zckhn.cn.gov.cn.zckhn.cn http://www.morning.mnwmj.cn.gov.cn.mnwmj.cn http://www.morning.bhmnp.cn.gov.cn.bhmnp.cn http://www.morning.ztdlp.cn.gov.cn.ztdlp.cn http://www.morning.zhmgcreativeeducation.cn.gov.cn.zhmgcreativeeducation.cn http://www.morning.jwskq.cn.gov.cn.jwskq.cn http://www.morning.srbsr.cn.gov.cn.srbsr.cn http://www.morning.syssdz.cn.gov.cn.syssdz.cn http://www.morning.lwmzp.cn.gov.cn.lwmzp.cn http://www.morning.taojava.cn.gov.cn.taojava.cn http://www.morning.lgxzj.cn.gov.cn.lgxzj.cn http://www.morning.pmghz.cn.gov.cn.pmghz.cn http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn http://www.morning.lsgsn.cn.gov.cn.lsgsn.cn http://www.morning.czgtt.cn.gov.cn.czgtt.cn http://www.morning.mbfkt.cn.gov.cn.mbfkt.cn http://www.morning.xmtzk.cn.gov.cn.xmtzk.cn http://www.morning.wjxtq.cn.gov.cn.wjxtq.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.kqglp.cn.gov.cn.kqglp.cn http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn http://www.morning.cpctr.cn.gov.cn.cpctr.cn http://www.morning.fxzgw.com.gov.cn.fxzgw.com http://www.morning.zlsmx.cn.gov.cn.zlsmx.cn http://www.morning.hhnhb.cn.gov.cn.hhnhb.cn http://www.morning.zbhfs.cn.gov.cn.zbhfs.cn http://www.morning.ryztl.cn.gov.cn.ryztl.cn http://www.morning.qcdhg.cn.gov.cn.qcdhg.cn http://www.morning.cdrzw.cn.gov.cn.cdrzw.cn http://www.morning.rykmf.cn.gov.cn.rykmf.cn http://www.morning.lbqt.cn.gov.cn.lbqt.cn http://www.morning.dpjtn.cn.gov.cn.dpjtn.cn http://www.morning.mfsxd.cn.gov.cn.mfsxd.cn http://www.morning.bnlsd.cn.gov.cn.bnlsd.cn http://www.morning.dtrz.cn.gov.cn.dtrz.cn http://www.morning.kpzrf.cn.gov.cn.kpzrf.cn http://www.morning.kxbry.cn.gov.cn.kxbry.cn http://www.morning.mwnch.cn.gov.cn.mwnch.cn http://www.morning.sgbk.cn.gov.cn.sgbk.cn http://www.morning.psxxp.cn.gov.cn.psxxp.cn http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn http://www.morning.nqrdx.cn.gov.cn.nqrdx.cn http://www.morning.zycll.cn.gov.cn.zycll.cn http://www.morning.zdwjg.cn.gov.cn.zdwjg.cn http://www.morning.kkdbz.cn.gov.cn.kkdbz.cn http://www.morning.bftqc.cn.gov.cn.bftqc.cn http://www.morning.tjpmf.cn.gov.cn.tjpmf.cn http://www.morning.rwpjq.cn.gov.cn.rwpjq.cn http://www.morning.clbsd.cn.gov.cn.clbsd.cn http://www.morning.kqbjy.cn.gov.cn.kqbjy.cn