方法一:
# Run these commands as your normal login (e.g. "michael")
# Remove any existing versions of nginx
sudo apt-get remove '^nginx.*$'
# Setup a sources.list.d file for the nginx repository
cat << 'EOF' | sudo tee /etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/ubuntu/ precise nginx
deb-src http://nginx.org/packages/ubuntu/ precise nginx
EOF
# Add nginx key
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
# install nginx
sudo apt-get update && sudo apt-get -y install nginx
方法二:
rm -rf /etc/nginx
rm -rf /usr/sbin/nginx
rm /usr/share/man/man1/nginx.1.gz
apt-get remove nginx* (apt-get remove --purge nginx)
sudo apt-get remove nginx #Removes all but config files.
sudo apt-get purge nginx #Removes everything.
重新安装:
To recreate it, first uninstall using purge to remove even configuration files and records:
apt-get purge nginx nginx-common nginx-full
then reinstall:
apt-get install nginx
if above doesn't work for you
You can also try using --force-confmiss option of dpkg.
sudo dpkg --force-confmiss -i /var/cache/apt/archives/nginx-common_*.deb