install Nginx
os:Ubuntu 18.04.3 LTS
# lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
Use apt-get to install Nginx. The installer creates a systemd init script that runs Nginx as daemon on system startup. Follow the installation instructions for Ubuntu as follow:
sudo apt update
sudo apt install nginx
output
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Fetched 252 kB in 0s (531 kB/s)
Reading package lists... Done
...
Setting up nginx-core (1.14.0-0ubuntu1.7) ...
Not attempting to start NGINX, port 80 is already in use.
Setting up nginx (1.14.0-0ubuntu1.7) ...
nginx -v
output
nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
uninstall Nginx on Ubuntu 18.04(aliyun)
step 1:
sudo apt-get remove nginx nginx-common # Removes all but config files.
or
sudo apt-get purge nginx nginx-common # Removes everything
step 2:
sudo apt-get autoremove # After using any of the above commands, use this in order to remove dependencies used by nginx which are no longer required.
reinstall
To recreate it, first uninstall using purge to remove even configuration files and records:
# 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
then reinstall:
apt-get install nginx
Host ASP.NET Core on Linux with Nginx