How to install nginx and install the configuration files too

Run apt-get remove --purge nginx nginx-full nginx-common first, and then apt-get install nginx and see if it works.


first

sudo apt-get -o DPkg::options::=--force-confmiss --reinstall install nginx-common

then test

sudo nginx -t

sudo apt-get --purge autoremove nginx

If you are not prompted to prove successful uninstall

 which nginx

I had the same problem, and solved it by copying the configuration files from /opt/ into /etc/:

cp /opt/nginx/conf/nginx.conf /etc/nginx/
cp /opt/nginx/conf/mime.types /etc/nginx/