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
...
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service -> /lib/systemd/system/mysql.service.
Setting up mysql-server (5.7.41-0ubuntu0.18.04.1) ...
nginx -v
output
nginx version: nginx/1.14.0 (Ubuntu)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
nginx version: nginx/1.18.0 (Ubuntu)
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
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.0