在Debian系统上安装和卸载Nginx可以通过以下步骤完成:
更新包列表:
sudo apt update
安装Nginx:
sudo apt install nginx
启动Nginx服务:
sudo systemctl start nginx
设置Nginx开机自启动:
sudo systemctl enable nginx
检查Nginx状态:
sudo systemctl status nginx
访问Nginx默认页面:
打开浏览器,访问 http://your_server_ip,你应该能看到Nginx的默认欢迎页面。
停止Nginx服务:
sudo systemctl stop nginx
禁用Nginx开机自启动:
sudo systemctl disable nginx
卸载Nginx:
sudo apt remove nginx
清理残留配置文件(可选):
sudo apt autoremove
sudo rm -rf /etc/nginx
sudo rm -rf /var/log/nginx
sudo rm -rf /var/www/html
sudo apt --purge remove nginx
通过以上步骤,你可以在Debian系统上轻松地安装和卸载Nginx。