前言
Apache用着有一阵子了,该尝试一下新事物了
安装
sudo apt update
sudo apt install nginx -y
sudo systemctl status nginx
如果显示状态为Active: active (running)
则说明Nginx正常运行中。此时可以打开浏览器输入IP即可(有安全组的服务器需打开80、443端口),我用的是虚拟机在地址栏,输入http://localhost/
后回车即可看到,该网站根目录位于var/html/www
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 -v
#设置Nginx开机启动
sudo systemctl enable nginx
#启动Nginx
sudo systemctl start nginx
#重启Nginx
sudo systemctl restart nginx
#关闭Nginx
sudo systemctl stop nginx