本文描述一个新系统下,安装使用nginx。
1、先更新软件:
sudo apt update
2、安装依赖包:
sudo apt install libpcre3 libpcre3-dev
3、安装nginx:
sudo apt install nginx
安装完成后,正常情况下nginx自动运行,可以使用下面命令查看状态
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 Mon 2022-06-13 17:46:00 CST; 19s ago Docs: man:nginx(8) Main PID: 2688 (nginx) Tasks: 2 (limit: 2310) Memory: 6.2M CGroup: /system.slice/nginx.service ├─2688 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; └─2689 nginx: worker process Jun 13 17:46:00 hui systemd[1]: Starting A high performance web server and a reverse proxy server... Jun 13 17:46:00 hui systemd[1]: Started A high performance web server and a reverse proxy server.
4、查看nginx欢迎页面:
root@hui:~# curl 127.0.0.1 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style>
出现以上页面,说明nginx工作正常
5、使用浏览器,输入公网IP,则可以看到正常的欢迎页面
原创文章,作者:bd101bd101,如若转载,请注明出处:https://blog.ytso.com/267836.html