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

杭州做美妆的网站网站的基本功能

杭州做美妆的网站,网站的基本功能,免费的网站开发软件,wordpress怎么添加导航分类项目里面有一个需求,就是需要用让nginx进程提供给系统管理一个start,stop和getPid方法,这样系统管理可以自动拉起来nginx,达到自动部署的目的。离线部署同样适用 这样一来,我就需要提供windows版本linux不同版本的nginx源码包&am…

项目里面有一个需求,就是需要用让nginx进程提供给系统管理一个start,stop和getPid方法,这样系统管理可以自动拉起来nginx,达到自动部署的目的。离线部署同样适用

这样一来,我就需要提供windows版本linux不同版本的nginx源码包,windows版本的好办,就直接从官网下载的,我下载的是nginx1.24.0的稳定版本的,linux版本的就需要自己编译源码包了,因为wget下载的nginx首先产物目录就很不一样,我需要就是跟windows差不多的目录结构,便于我写nginx.conf配置文件

window的产物目录如下

linux产物目录如下

linux的这个产物只需要编译一次,后面部署就直接拷贝这个就可以了,编译的过程如下:

官网下载nginx源码,新建一个文件夹叫Nginx

进入到源码目录 

./configure --prefix=新建的产物目录地址
make -j12
make install 

可能中间需要装 pcre库,wget 下载一下好了。

pcre是因为我的nginx配置需要用到正则,就是html下面有不同文件夹,每个文件夹是一个项目,部署的时候有多少个文件夹部署多少个项目。

这个过程比较曲折,首先nginx没有地方写日志是不会启动成功的,所以配置文件需要指定日志的生成位置,还有配置文件的启动位置,pid等

贴一份windows的配置文件:

worker_processes  1;
error_log  D:/code/system/run/nginx/logs/error.log error;
pid        D:/code/system/run/nginx/logs/nginx.pid;
events { worker_connections  1024; 
} 
http { include       mime.types; default_type  application/octet-stream; sendfile        on; keepalive_timeout  65; access_log D:/code/system/run/nginx/logs/access.log; map $_FilePath $_FilePathForUse { "" "index.html"; "/" "index.html";default $filePathFromRemote; }client_body_temp_path D:/code/system/run/nginx/temp/client_temp; proxy_temp_path D:/code/system/run/nginx/temp/proxy_temp; fastcgi_temp_path D:/code/system/run/nginx/temp/fastcgi_temp; uwsgi_temp_path D:/code/system/run/nginx/temp/uwsgi_temp;scgi_temp_path D:/code/system/run/nginx/temp/scgi_temp; server { listen 8090; location /{ gzip on; gzip_static on; root  D:/code/system/run/nginx/html/; add_header X-URI-Part1 $1; add_header X-URI-Part2 $2; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; set $module $1; set $filePathFromRemote $2; set $_FilePath "$filePathFromRemote"; } error_page 500 502 503 504 /50x.html; } server { listen 9000; location / {  root  D:/code/system/run; autoindex on;  add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With;  add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;  }  } 
} 

两个server是因为还用到了nginx做文件服务

linux版本的配置文件:

  worker_processes  1;error_log  ${ROOT_DIR}/run/nginx/logs/error.log error;pid         ${ROOT_DIR}/run/nginx/logs/nginx.pid;events {worker_connections  1024;}http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;access_log  ${ROOT_DIR}/run/nginx/logs/access.log; map $_FilePath $_FilePathForUse {"" "index.html";"/" "index.html";default $filePathFromRemote;}client_body_temp_path ${ROOT_DIR}/run/nginx/client_temp;proxy_temp_path ${ROOT_DIR}/run/nginx/proxy_temp;fastcgi_temp_path ${ROOT_DIR}/run/nginx/fastcgi_temp;uwsgi_temp_path ${ROOT_DIR}/run/nginx/uwsgi_temp;scgi_temp_path ${ROOT_DIR}/run/nginx/scgi_temp;server {listen 8090;server_name localhost;location ~ ^/([^/]+)(/?.*)$ {root  ${ROOT_DIR}/run/nginx/html/;add_header 'Access-Control-Allow-Origin' '*';add_header 'Access-Control-Allow-Credentials' 'true';set $module $1;set $filePathFromRemote $2;set $_FilePath "$filePathFromRemote";}error_page 500 502 503 504 /50x.html;location = /50x.html {root ${ROOT_DIR}/run/nginx/html;}}server {listen 9000;server_name localhost;location / {root ${ROOT_DIR}/run;autoindex on;add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Headers X-Requested-With;add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;}}}

这两个配置文件的生成是通过脚本自动写入的,用到了各自系统的环境变量

下面就是启动程序了

start方法

#ifdef _WIN64cmd = fmt::format("{}/nginx/nginx -c {}/nginx/conf/nginx.conf -e {}/nginx/logs/error.log",根目录,根目录);#endif #ifdef __linux__cmd = fmt::format("{}/nginx/sbin/nginx -c {}/nginx/conf/nginx.conf -e {}/nginx/logs/error.log",根目录,根目录,根目录);#endif

大概就是通过命令行启动nginx进程,涉及到一些公司里面封装的底层方法,就不方便写了。。

stop方法同理

getPid方法比较复杂,nginx每次启动成功都会往nginx.pid文件写入一个进程号,需要把文件读出来然后返回出去,而且需要自己判断进程是不是存活,不能返回一个没有启动的进程出去。

启动成功之后浏览器输入当前机器的ip地址:8090就能访问到内容

系统管理界面可以管理nginx的启停

http://www.sczhlp.com/news/98397/

相关文章:

  • 西安的电商网站设计网站宣传册
  • 做原型网站高校廉洁文化建设网站
  • 餐饮公司做网站的好处四川省城乡与建设厅网站首页
  • 网站开发客户阿里云案例泉州设计网站
  • 简单的网站建设找哪个公司北京网站建设分析论文
  • 汽车公司网站建设舟山注册公司
  • 性价比高的seo网站优化工程造价信息网电子版
  • 网站编程教学群晖nas安装wordpress
  • 网站播放视频速度优化网站开发工程是待遇
  • 帮别人做网站备案怎么在58同城上做网站
  • 中小企业建网站注意北京网页设计公司招聘
  • 地产公司做网站维护写代码么6世界工厂采购网官网
  • 阅读 |《虚空》观后感以及一些想法——万物简史
  • 火狐 网站开发威海建设集团网站首页
  • 网泰网站建设网络网站突然不能访问
  • 营销型网站怎么收费做动漫头像的网站
  • 北京软装设计公司有哪些wordpress新手优化
  • 网络营销服务公司seo技术蜘蛛屯
  • 成都门户网站建设上海网站推广
  • 营销型网站的三元素网站ftp查询
  • 江苏网络公司网站建设线上维护需要做什么
  • 沈阳火车站wish跨境电商平台
  • wordpress 文章评论数重庆seo整站优化外包服务
  • 河北地矿建设集团官方网站长沙专业网站制作
  • 个人网站可以做自媒体吗上海wordpress网站建设
  • Python进阶必看:深入解析yield的强大功能
  • 做任务什么网站怎么查看网站ftp地址
  • 做一个网站的建设过程淘宝手机网站模板下载安装
  • 江苏平台网站建设价位微信社群运营工具
  • wordpress热门文章查询嘉兴seo优化