首页 帮助中心 新加坡服务器 如何在Ubuntu18.04上安装Nginx
如何在Ubuntu18.04上安装Nginx
时间 : 2023-01-13 09:53:04 编辑 : 华纳云 阅读量 : 316

  安装Nginx
  Nginx的软件包在Ubuntu默认软件仓库中可用。 安装非常简单,只需键入以下命令:
  安装完成后,请检查Nginx服务的状态和版本:
  输出:

  ● nginx.service – A high performance web server and a reverse proxy server
    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
    Active: active (running) since Sat 2018-05-05 21:54:25 CST; 1 day 7h ago
      Docs: man:nginx(8)
   Main PID: 2188 (nginx)
      Tasks: 5 (limit: 4471)
    CGroup: /system.slice/nginx.service
            ├─2188 nginx: master process /usr/sbin/nginx -g daemon on; master_pro
            ├─2189 nginx: worker process
            ├─2190 nginx: worker process
            ├─2191 nginx: worker process
            └─2192 nginx: worker process
  sudo nginx -v

       输出:

  nginx version: nginx/1.14.0 (Ubuntu)

       配置防火墙
  如果您正在运行防火墙,则还需要打开端口80和443。
  您可以通过以下方式验证更改:
  输出:

  状态: 激活
  至                          动作          来自
  –                          —          —
  Nginx Full                ALLOW      Anywhere                 
  Nginx Full (v6)            ALLOW      Anywhere (v6)      

      测试安装
  在您选择的浏览器中打开http://YOUR_IP,您应该能够看到默认的Nginx登录页面,如下所示:
  使用systemctl管理Nginx服务
  您可以像任何其他systemd单位一样管理Nginx服务。 要停止Nginx服务,请运行:

  sudo systemctl stop nginx

       要再次启动,请键入:

  sudo systemctl start nginx

       重新启动Nginx服务:

  sudo systemctl restart nginx

         在进行一些配置更改后重新加载Nginx服务:

  $sudo systemctl reload nginx

        如果你想禁用Nginx服务在启动时启动:

  $sudo systemctl disable nginx

        并重新启用它:

  $sudo systemctl enable nginx

        就这样! 如果您遇到任何问题,请随时发表评论。

华纳云 推荐文章
Ubuntu18.04系统中如何安装logwatch日志监控程序 linux如何安装Nginx-RTMP流媒体服务器 如何在Ubuntu18.04系统安装golang 如何在ubuntu18.04系统搭建ftp服务 如何在Ubuntu18.04系统搭建FTP 如何在Ubuntu18.04系统挂载磁盘 如何在Ubuntu18.04系统配置和修改IP 如何在Ubuntu18.04系统安装docker Ubuntu18.04系统如何安装宝塔面板? Ubuntu18.04如何解决执行文件脚本提示python错误
活动
客服咨询
7*24小时技术支持
技术支持
渠道支持