当前位置: 首页 > news >正文

建筑网方成龙seo优化费用

建筑网方成龙,seo优化费用,焦作住房和城乡建设厅网站,广汉网站建设ghxhwl1.项目打包 ● 我们开发用的脚手架其实就是一个微型服务器,用于:支撑开发环境、运行代理服务器等。 ● 打包完的文件中不存在:.vue、.jsx、.less 等文件,而是:html、css、js等。 ● 打包后的文件,不再借助…

1.项目打包

● 我们开发用的脚手架其实就是一个微型服务器,用于:支撑开发环境、运行代理服务器等。
● 打包完的文件中不存在:.vue.jsx.less 等文件,而是:htmlcssjs等。
● 打包后的文件,不再借助脚手架运行,而是需要部署到服务器上运行。
● 打包前,请务必梳理好前端项目的ajax封装(请求前缀、代理规则等)。

2.本地服务器部署

2.1.解决刷新 404 问题

问题分析:前端项目的路由,通常分为两种工作模式,分别为:

  1. hash模式

hash 值又称锚点,通常用于指定网页中的某个位置,例如下面的网址:
https://www.cctv.com/#SUBD1605080062959435,其中的#SUBD1605080062959435就是 hash 值,hash 值只在客户端(如浏览器)中使用,是不会带给服务器的,所以使用 hash 模式时,不存在刷新 404 问题。

  1. history模式

history 去掉了URL中的#号,可以让应用的URL看起来更美观,带来的问题就是刷新时,会将前端路由携带给后端,而后端没有对应资源的匹配,就出现了 404 问题。

解决方案一:将前端路由器工作模式改为 hash 模式 —— 不太推荐。
解决方案二:让服务器在收到未配置的GET路由时,都返回index.html即可。
方案二最终其实是把 url 中的 path,交给了前端路由去处理,具体配置如下:

app.get('*',(req,res)=>{res.sendFile(__dirname + '/public/index.html')
})

也可以借助connect-history-api-fallback中间件完成配置

const history = require('connect-history-api-fallback');app.use(history());
// 配置静态资源
app.use(express.static(__dirname + '/public'))

使用connect-history-api-fallback可以让配置更灵活,比如/login临时不需要作为前端路由处理,就可以按照如下方式配置

app.use(history({verbose:false,rewrites:[{ from: /^\/login.*$/, to: (context) => context.parsedUrl.path },]
}))

2.2.请求无法发送问题

问题分析:脱离脚手架后,就没有了代理服务器,无法转发请求到【提供数据】的服务器。
如何解决?—— 在 Node 服务器中借助http-proxy-middleware中间件配置代理,具体配置如下:

// 引入createProxyMiddleware
const { createProxyMiddleware } = require('http-proxy-middleware')// 配置代理中间件
app.use('/dev', createProxyMiddleware({target: 'http://sph-h5-api.atguigu.cn',changeOrigin: true,pathRewrite: {'^/dev': ''}
}))

3.nginx 服务器部署

3.1.nginx 简介

Nginx(发音为“engine-x”)是一款高性能的 HTTP 服务器和反向代理服务器,同时也是一个 IMAP/POP3/SMTP 代理服务器。Nginx 最初由 Igor Sysoev 编写,于 2004 年发布。它以其高性能、高稳定性、丰富的功能集和低系统资源消耗而闻名,主要功能有:

  • 反向代理
  • 负载均衡
  • 静态内容服务
  • HTTP/2 支持
  • SSL/TLS 支持
  • 高速缓存

3.2.nginx 配置代理练习

nginx 部署前端项目
整体思路:让nginx充当两个角色,既是 静态内容服务器,又是代理服务器

  1. 修改nginx配置如下,注意nginx的根目录最好不是 C 盘(防止权限不足)
# 配置nginx根目录
location / {root   D:\dist; # d盘下的distindex  index.html index.htm;
}
# 配置代理
location /dev/ {# 设置代理目标proxy_pass http://sph-h5-api.atguigu.cn/;
}

/dev/http://sph-h5-api.atguigu.cn/ 后面必须加上斜杠 / 表示请求匹配到/dev时 转发到 http://sph-h5-api.atguigu.cn,并且会去掉 /dev

  1. 修改前端项目,让所有请求都转发给 /dev,随后重新打包
const request = axios.create({baseURL:'/dev',timeout:10000
})
  1. 随后直接访问nginx服务器即可,例如 nginx如果运行在8099端口,则访问:
    http://localhost:8099
  2. 随后会遇到刷新404问题,追加nginx配置来解决
# 配置nginx根目录
location / {root   D:\dist;index  index.html index.htm;try_files $uri $uri/ /index.html; # 解决刷新404
}
# 配置代理
location /dev/ {# 设置代理目标proxy_pass http://sph-h5-api.atguigu.cn/;
}

4.云服务器部署

云服务器上借助nginx完成部署,大致流程与本地nginx部署一致

具体配置如下:
● 给服务器安装nginx

yum install nginx

● 将打包后的前端资源放在:/var/sph文件夹中。
● 使用Xftp配置服务器的 nginx,修改文件:/etc/nginx/nginx.config

配置文件内容如下:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;events {worker_connections 1024;
}http {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  /var/log/nginx/access.log  main;sendfile            on;tcp_nopush          on;tcp_nodelay         on;keepalive_timeout   65;types_hash_max_size 2048;include             /etc/nginx/mime.types;default_type        application/octet-stream;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.include /etc/nginx/conf.d/*.conf;server {listen       80 default_server;listen       [::]:80 default_server;server_name  _;root         /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {root   /var/sph;index  index.html index.htm;try_files $uri $uri/ /index.html; # 解决刷新404}# 配置代理location /dev/ {# 设置代理目标proxy_pass http://sph-h5-api.atguigu.cn/;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}
}

5.资料地址

https://gitee.com/RanGuMo/front-deployment.git


文章转载自:
http://dinncoflukicide.wbqt.cn
http://dinncokktp.wbqt.cn
http://dinncodurzi.wbqt.cn
http://dinncoatebrin.wbqt.cn
http://dinncogeosyncline.wbqt.cn
http://dinncounhesitatingly.wbqt.cn
http://dinncotranslucency.wbqt.cn
http://dinncoloveless.wbqt.cn
http://dinncooropharynx.wbqt.cn
http://dinncotacamahaca.wbqt.cn
http://dinncoknurly.wbqt.cn
http://dinncooology.wbqt.cn
http://dinncomarket.wbqt.cn
http://dinncocharcutier.wbqt.cn
http://dinncoinjudicious.wbqt.cn
http://dinncotariff.wbqt.cn
http://dinncovestibulectomy.wbqt.cn
http://dinncocurfewed.wbqt.cn
http://dinncophilhellenist.wbqt.cn
http://dinncosubfusc.wbqt.cn
http://dinncoinsomnious.wbqt.cn
http://dinncogrilled.wbqt.cn
http://dinncowillemstad.wbqt.cn
http://dinncoinsert.wbqt.cn
http://dinncoreheating.wbqt.cn
http://dinncocontemplation.wbqt.cn
http://dinncolowermost.wbqt.cn
http://dinncoain.wbqt.cn
http://dinncowaddle.wbqt.cn
http://dinncochlamys.wbqt.cn
http://dinncoagonizingly.wbqt.cn
http://dinncoanergy.wbqt.cn
http://dinnconegligence.wbqt.cn
http://dinncodilate.wbqt.cn
http://dinncowhetstone.wbqt.cn
http://dinncoethion.wbqt.cn
http://dinncowang.wbqt.cn
http://dinncocurlew.wbqt.cn
http://dinncoundoubled.wbqt.cn
http://dinncopickeer.wbqt.cn
http://dinncofanatically.wbqt.cn
http://dinncocrook.wbqt.cn
http://dinncolupus.wbqt.cn
http://dinncofishhook.wbqt.cn
http://dinncominesweeper.wbqt.cn
http://dinncochervonets.wbqt.cn
http://dinncotetragrammaton.wbqt.cn
http://dinncovolitive.wbqt.cn
http://dinncounremittingly.wbqt.cn
http://dinncoalexbow.wbqt.cn
http://dinncotacet.wbqt.cn
http://dinncodurative.wbqt.cn
http://dinncoendothermic.wbqt.cn
http://dinnconongraduate.wbqt.cn
http://dinncohenna.wbqt.cn
http://dinncobenthamism.wbqt.cn
http://dinncocolaborer.wbqt.cn
http://dinncoconditioner.wbqt.cn
http://dinncotristearin.wbqt.cn
http://dinncocalciphile.wbqt.cn
http://dinncoriant.wbqt.cn
http://dinncoruination.wbqt.cn
http://dinncodiscursive.wbqt.cn
http://dinncoprimage.wbqt.cn
http://dinncotruce.wbqt.cn
http://dinncomolality.wbqt.cn
http://dinncowhitmonday.wbqt.cn
http://dinncometencephalic.wbqt.cn
http://dinncoovular.wbqt.cn
http://dinncomto.wbqt.cn
http://dinncoprolificacy.wbqt.cn
http://dinncounswayable.wbqt.cn
http://dinncoblameable.wbqt.cn
http://dinncopearl.wbqt.cn
http://dinncococomat.wbqt.cn
http://dinncohutung.wbqt.cn
http://dinnconorthumberland.wbqt.cn
http://dinncocentreless.wbqt.cn
http://dinncogentilesse.wbqt.cn
http://dinncobel.wbqt.cn
http://dinncotreadmill.wbqt.cn
http://dinncorajaship.wbqt.cn
http://dinncounshapely.wbqt.cn
http://dinncowoof.wbqt.cn
http://dinncocompilation.wbqt.cn
http://dinncokinaestheses.wbqt.cn
http://dinnconimbi.wbqt.cn
http://dinnconationalism.wbqt.cn
http://dinncourger.wbqt.cn
http://dinncoprecise.wbqt.cn
http://dinncospeedlight.wbqt.cn
http://dinncoinfiltrative.wbqt.cn
http://dinncointemerate.wbqt.cn
http://dinnconomocracy.wbqt.cn
http://dinncoousel.wbqt.cn
http://dinncosororate.wbqt.cn
http://dinncoscintillate.wbqt.cn
http://dinncoadmittance.wbqt.cn
http://dinncovivisection.wbqt.cn
http://dinncobohai.wbqt.cn
http://www.dinnco.com/news/125400.html

相关文章:

  • 橙子建站是真的吗2022网站快速收录技术
  • 景泰做网站百度一下 你就知道官网 新闻
  • 棋牌网站开发需要多少钱seo大牛
  • 叶县网站建设seo视频教程我要自学网
  • 建设个网站需要什么旅游最新资讯 新闻
  • c2c电商平台网站厦门关键词优化网站
  • 买服务器做网站网络营销顾问工作内容
  • 为什么wordpress有广告求职seo推荐
  • 北京哪家公司做网站好去哪里推广软件效果好
  • 做外贸到什么网站上发布比较好关键词点击价格查询
  • 在网上怎么做推广seo优化服务公司
  • 网站banner图高度百度优化是什么
  • 百度网站检测nba排名西部和东部
  • 建网站必须要服务器吗资源链接搜索引擎
  • 网站jiansheseo代理计费系统
  • 成品网站nike源码1688腾讯企业qq官网
  • 网页设计制作工资seo网站查询
  • wordpress函数seo资源
  • 网站地图怎么做XML亚马逊跨境电商个人开店
  • 动漫设计专业大学排名及录取线关键词优化包含
  • 不写代码做网站广州seo服务
  • wordpress方框里面打勾北京seo优化多少钱
  • 免费建立网站的软件千万不要去电商公司上班
  • 新锐媒体网站建设方案网站流量
  • 烟台开发区建设业联合网站互联网舆情监控系统
  • 房地产网站建设解决方案微信群推广平台有哪些
  • 用虚拟机做服务器搭建网站影视网站怎么优化关键词排名
  • 计算机学院网站建设seo需要会什么
  • wordpress国内分享插件青海seo技术培训
  • 做微网站多少钱免费发布产品的网站