Installing Nginx on Debian
Guide to install and start Nginx on Linux systems based on Debian.
Requirements
Operating System | Version |
---|---|
Debian | 10 |
Installation
Refresh the package index.
sudo apt-get update
Optional: remove previous installations.
sudo apt-get purge nginx nginx-common
Install the latest version available in the repositories.
sudo apt install nginx
Start the service.
sudo service nginx start
Verification
Check the service status.
sudo service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-06-06 12:17:20 -04; 3s ago
Docs: man:nginx(8)
Process: 3954 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3955 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3956 (nginx)
Tasks: 7 (limit: 4915)
Memory: 6.5M
...
Visit http://localhost in your browser or run the following command in the terminal.
curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
</p>
<p>
For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br />
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.
</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Auto-start
Control whether the service starts automatically.
sudo systemctl enable nginx
To disable auto-start:
sudo systemctl disable nginx
References
Published: June 6, 2020