1、更新源,Nginx 在默认的 Ubuntu 源仓库中可用
sudo apt update
2、安装Nginx
sudo apt install nginx
3、验证Nginx是否自动启动
sudo systemctl status nginx
● 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 Wed 2024-03-27 01:36:37 UTC; 2min 4s ago
Docs: man:nginx(8)
Main PID: 9717 (nginx)
Tasks: 5 (limit: 4594)
Memory: 7.6M
CGroup: /system.slice/nginx.service
├─9717 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─9718 nginx: worker process
├─9719 nginx: worker process
├─9720 nginx: worker process
└─9721 nginx: worker process
4、输出类似上面的,就代表安装成功,此时如果开通了80端口,那么便可以通过http://IP 去访问,如果没有开通80和443端口,就需要进行下一步操作
5、配置防火墙
sudo ufw allow 'Nginx Full'
6、验证端口状态
sudo ufw status
7、如果在输出中,有类似下面的,就代表成功了
状态: 激活
至 动作 来
--- --- ---
22/tcp ALLOW Anywhere
Nginx Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
8、接下来就用http://你的IP 去访问,就会出现Nginx的默认页面
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
Nginx命令
这个命令会检查 Nginx 配置文件的语法。
sudo nginx -t
重新启动nginx
sudo systemctl reload nginx
创建文件夹
mkdir 文件夹名称
复制文件到某处
cp 文件路径 文件路径

Comments NOTHING