如何搭建自己的Web服务器(一)

2025-11-06 11:29:28

1、以管理员权限运行PowerShell,如图所示。

如何搭建自己的Web服务器(一)

2、安装chocolatey:

    在power shell中执行:

Set-ExecutionPolicy AllSigned; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 

如何搭建自己的Web服务器(一)

3、其中遇到两个提问:

是否要更改执行策略?选:A

是否要运行来自此不可信发布者的软件?选:A

如何搭建自己的Web服务器(一)

如何搭建自己的Web服务器(一)

4、安装nginx

在power shell 中输入:choco install nginx -y

如何搭建自己的Web服务器(一)

5、打开nginx/tools文件夹:

在power shell 中输入:explorer C:\ProgramData\chocolatey\lib\nginx\tools

如何搭建自己的Web服务器(一)

6、在文件夹内: 打开nginx-1.12.1 --打开conf文件夹--用非记事本的编辑器(没有的话,choco install notepadplusplus )打开nginx.conf 文件

如何搭建自己的Web服务器(一)

7、在nginx-1.12.1文件夹下,找到html文件夹,并重命名为html_

8、在pawer shell里面输入:

 cd C:\ProgramData\chocolatey\lib\nginx\tools 

再输入:

 choco install pstools 

如何搭建自己的Web服务器(一)

9、Do you want to run the script?([Y]es/[N]o/[P]rint): Y

如何搭建自己的Web服务器(一)

10、powershell里面执行:cd C:\ProgramData\chocolatey\lib\nginx\tools\nginx-1.12.1cmd /c mklink /d html 项目的绝对路径

如何搭建自己的Web服务器(一)

11、power shell里执行:

cd ..

nginx

如何搭建自己的Web服务器(一)

12、power shell里执行:

cd nginx-1.12.1nginx 

如何搭建自己的Web服务器(一)

13、在弹出的网络防火墙页面 两个框都打勾,允许访问。

如何搭建自己的Web服务器(一)

14、最后试试访问localhost:80、试试访问你的ngrok。

到这里,我们的web服务器已经顺利搭建完毕,并成功添加了我们的项目在服务器上。

15、附1:在桌面建立个后辍为bat的文件,内容为:

 cd C:\ProgramData\chocolatey\lib\nginx\tools\nginx-1.12.1nginx 

注:

关闭这个窗口服务器就停止运行 ;

打开bat就运行。

如何搭建自己的Web服务器(一)

16、附2:改项目的话,cmd  以管理员身份运行

cd C:\ProgramData\chocolatey\lib\nginx\tools\nginx-1.12.1del /f /q htmlmklink /d html 项目绝对位置 

17、今天就给大家介绍这些,谢谢大家的支持!

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢