window下nginx怎样添加模块

window下nginx怎样添加模块,第1张

从nginx官网下载相应的安装包

建议下载 下载稳定版

解压到相应的目录,比如我是e盘 然后修改目录名字为nginx

进入nginx目录 双击nginx.exe 来启动nginx

此时 直接在浏览器地址栏输入:localhost 便能看到 欢迎页面,说明你虚拟主机已经搭建好了

但是有时候 我们需要配置路径 在默认情况下 他的root是 nginx目录下的html文件夹

如若修改 则打开conf目录下的nginx.conf

找到server 选项 修改咯location 中的root 选项。

比如我修改到D:/webroot

则修改为

有台服务器为windows,现在要通过远程管理,但该服务器是在内网,只能通过前置机跳转,而前置机为linux,需要用到tcp代理,该服务器已安装了nginx-1.2.9,打算使用nginx的tcp代理模块来做,以下是安装配置过程

在root目录下载解压软件,得到nginx_tcp_proxy_module-master目录

wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip

unzip master.zip

进入nginx原安装路径 ,将nginx进程停止,安装和编译模块

cd /root/nginx-1.2.9

killall nginx

patch -p1 </root/nginx_tcp_proxy_module-master

./configure --add-module=/root/nginx_tcp_proxy_module

make

make install

/usr/local/nginx/sbin/nginx -V

安装完成后,配置tcp代理,在nginx.conf文件最后添加如下内容,需要注意的是http和tcp不能使用相同端口

tcp {

upstream cluster {

# simple round-robin

server 192.168.1.23:3389

check interval=3000 rise=2 fall=5 timeout=1000

#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello

#check interval=3000 rise=2 fall=5 timeout=1000 type=http

#check_http_send "GET / HTTP/1.0\r\n\r\n"

#check_http_expect_alive http_2xx http_3xx

}

server {

listen 3389

proxy_pass cluster

access_log logs/3389_access.log

}

}

添加完成后,测试配置文件,运行nginx

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx

即可访问远程桌面。

找到安装nginx的源码根目录,如果没有的话下载新的源码

http://nginx.org

tar xvzf nginx-1.3.2.tar.gz

查看ngixn版本极其编译参数

/usr/local/nginx/sbin/nginx -V

进入nginx源码目录

cd nginx-1.3.2

以下是重新编译的代码和模块

./configure --prefix=/usr/local/nginx--with-http_stub_status_module

--with-http_ssl_module --with-file-aio --with-http_realip_module

make 千万别make install,否则就覆盖安装了

make完之后在objs目录下就多了个nginx,这个就是新版本的程序了

备份旧的nginx程序

cp /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak

把新的nginx程序覆盖旧的

cp objs/nginx /usr/local/nginx/sbin/nginx

测试新的nginx程序是否正确

/usr/local/nginx/sbin/nginx -t

nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx:configuration file /usr/local/nginx/conf/nginx.conf test issuccessful

平滑重启nginx

/usr/local/nginx/sbin/nginx -s reload

查看ngixn版本极其编译参数

/usr/local/nginx/sbin/nginx -V

这是我重新编译的代码:

./configure --prefix=/usr/local/nginx --with-google_perftools_module

--user=www --group=www --with-http_stub_status_module

--with-http_gzip_static_module --with-openssl=/usr/

--with-pcre=/mydata/soft/pcre-8.31


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7951360.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-11
下一篇2023-04-11

发表评论

登录后才能评论

评论列表(0条)

    保存