1.WSL2上安装Ubuntu,详见本作者另一篇文章《win11下的WSL2安装Redis》;
2.打开dos窗口,输入wsl -u root 进入ubuntu环境;
3.输入命令:sudo apt-get update
用于更新包管理器;
4.输入命令:sudo apt-get install nginx
用于安装Nginx,提示时候输入Y;
5.输入命令:sudo systemctl restart nginx
用于重新启动Nginx服务;
6.输入命令:sudo systemctl status nginx
查看Nginx服务状态;
7.输入命令:ps -ef |grep nginx
查看Nginx进程状态;
8..输入命令:sudo systemctl enable nginx
将Nginx服务设为开机自启;
9.输入命令:sudo systemctl list-unit-files --type=service | grep enabled | grep -vE 'disabled|masked'
查看开机自启服务列表;
10.输入命令:cat /etc/nginx/nginx.conf
用于查看Nginx配置文件;