Ubuntu18 mounting Nginx (rpm)

Nginx pronounced "engine x" is a free open source high performance HTTP server and reverse proxy, is responsible for some of the largest processing load on the internet site. This tutorial overview Ubuntu  installation and management of the machine 18.04 Nginx steps.

Install Nginx

Nginx packages available in the default Ubuntu software repositories. Installation is very simple, just type the following command:

sudo apt update
sudo apt install nginx

After the installation is complete, check the status of services and Nginx version:

@ linuxidc linuxidc: ~ $ sudo systemctl Status nginx
[sudo] linuxidc password:

Output:

● 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

5月 05 21:54:17 linuxidc systemd[1]: Starting A high performance web server and 
5月 05 21:54:24 linuxidc nginx[2032]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc nginx[2187]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc systemd[1]: Started A high performance web server and a
linuxidc@linuxidc:~$

How to install Nginx on Ubuntu 18.04

Sudo nginx -V

Output:

nginx version: nginx/1.14.0 (Ubuntu)

How to install Nginx on Ubuntu 18.04

Configure the firewall

If you are running a firewall, you also need to open ports 80 and 443.

@ linuxidc linuxidc: ~ $ sudo ufw the allow 'Nginx Full'
[sudo] linuxidc password: 
firewall rules are updated
rules that have been updated (v6)

How to install Nginx on Ubuntu 18.04

You can verify the change in the following ways:

@ linuxidc linuxidc: ~ $ sudo ufw Status
[sudo] linuxidc password:

Output:

Status: Active

至                          动作          来自
-                          --          --
Nginx Full                ALLOW      Anywhere                  
Nginx Full (v6)            ALLOW      Anywhere (v6)           

linuxidc@linuxidc:~$

How to install Nginx on Ubuntu 18.04

测试安装

在您选择的浏览器中打开http://YOUR_IP,您应该能够看到默认的Nginx登录页面,如下所示:

 How to install Nginx on Ubuntu 18.04

使用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

以下编辑推荐:

如果您想要在服务器上托管多个域,可以查看以下指南:

如何在Ubuntu 18.04上设置Nginx服务器  https://www.linuxidc.com/Linux/2018-05/152258.htm

如果您想用免费的LetsEncrypt SSL证书保护您的网站,可以查看以下指南:

Let's Encrypt protection using Nginx 18.04 on Ubuntu   https://www.linuxidc.com/Linux/2018-05/152259.htm

 

Transfer: https://www.linuxidc.com/Linux/2018-05/152257.htm

Guess you like

Origin www.cnblogs.com/helios-fz/p/10932568.html