4.子系统WSL ubuntu18.04安装nginx

这操作简单,因为子系统直接用源安装,懒得使用编译安装。
后面章节的php和mysql也都是通过源直接安装。
也会提供编译安装的教程,但是因为php各版本插件模块不一,烧脑行为,请高手尝试。

安装nginx:
sudo apt-get install nginx
依赖会自动安装。
一波英文以后完成安装。
源直接安装后的目录通常好看,跟编译安装就是不一样。
默认的网站根目录:/var/www/html
nginx配置文件目录:/etc/nginx/
nginx主配置文件位置:/etc/nginx/nginx.conf

安装完成会在如下目录生成启动文件
/etc/init.d/nginx

开机启动服务配置
/lib/systemd/system/nginx.service
软链上面的
/etc/systemd/system/multi-user.target.wants/nginx.service

但是,不会开机自启,在后面章节会了解到。

nginx常用管理命令(子系统不支持systemctl ):
设置nginx开机启动:
sudo systemctl enable nginx
启动nginx:
sudo systemctl start nginx
sudo service nginx start
关闭nginx:
sudo systemctl stop nginx
sudo service nginx stop

nginx配置,等PHP安装时一并再说~

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注