在nginx中配置虚拟域名需要进行以下步骤:
1. 打开 nginx 配置文件,一般位于 "/etc/nginx/nginx.conf" 或 "/etc/nginx/conf.d" 目录下。
2. 在 http 块中添加一个新的 server 块,如下所示:
server {
listen 80;
server_name yourdomain.com;
location / {
root /path/to/your/website;
index index.html index.php;
}
}
其中,`yourdomain.com`是你要配置的虚拟域名,`/path/to/your/website`是你网站的根目录。
3. 保存配置文件并重新启动 nginx 服务。
sudo service nginx restart
现在,当你访问 `yourdomain.com` 时,nginx 将会将请求转发到指定的根目录中的文件。
查看详情
查看详情