服务器管理虚拟主机的常用命令如下:
1. 创建虚拟主机:
- Apache: `a2ensite example.com`
- Nginx: `nginx -c /etc/nginx/sites-available/example.com.conf`
2. 删除虚拟主机:
- Apache: `a2dissite example.com`
- Nginx: `rm /etc/nginx/sites-available/example.com.conf`
3. 重启Web服务器:
- Apache: `systemctl restart apache2`
- Nginx: `systemctl restart nginx`
4. 检查虚拟主机配置:
- Apache: `apache2ctl configtest`
- Nginx: `nginx -t`
5. 查看虚拟主机列表:
- Apache: `apache2ctl -S`
- Nginx: `nginx -T`
6. 切换默认虚拟主机:
- Apache: 修改 `/etc/apache2/sites-available/000-default.conf`
- Nginx: 修改 `/etc/nginx/conf.d/default.conf`
7. 修改虚拟主机配置:
- Apache: 编辑 `/etc/apache2/sites-available/example.com.conf`
- Nginx: 编辑 `/etc/nginx/sites-available/example.com.conf`
这些是一些常见的虚拟主机管理命令,具体根据您使用的Web服务器而有所不同。
查看详情
查看详情