时间:2023-05-19 00:03:01 | 来源:网站运营
时间:2023-05-19 00:03:01 来源:网站运营
Ubuntu nginx 配置虚拟主机:Ubuntu 20.10 Nginx1.18sudo gedit /etc/hosts
#在最后添加一行sudo gedit /etc/nginx/sites-available/localhost
直接复制下面代码到配置文件中# server 配置server { listen 80; listen [::]:80; #域名(虚拟主机的访问地址) server_name localhost; #项目主入口文件路径 root /home/[your name]/localhost/public; #查找默认入口的先后顺序 index index.php index.html index.htm; location / { try_files $uri $uri/ =404; }}
创建一个软链接到 /etc/nginx/sites-enabled/ 目录下,使配置文件生效 sudo ln -s /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled/
注意: sudo service nginx restart
关键词:主机,虚拟,配置