GNU/Linux >> Linux Esercitazione >  >> Linux

Come installare NGINX su Ubuntu 20.04

Introduzione

Questo tutorial ti mostrerà come installare Nginx su Ubuntu 20.04 in modo da poter eseguire con successo un server Web basato su prestazioni superiori alleggerendo il carico sulle risorse di sistema. Nginx è un potente software per server web che può essere utilizzato sul tuo server.

Prerequisiti

È necessario un server Ubuntu 20.04 configurato con un indirizzo IP statico. Se non disponi già di un server, puoi visitare la nostra pagina di hosting VPS e avviare un nuovo server in meno di 30 secondi.

Preparazione del server

Assicuriamoci che il tuo server sia completamente aggiornato.

apt-get update

Con il server aggiornato, possiamo continuare il processo di installazione del tuo server.

Installa Nginx

Per installare Nginx, dovremo utilizzare il comando apt-get in modo da poter installare il software:

sudo apt-get install nginx -y

Ora avrai NGINX installato sul tuo server e potrai verificarlo digitando quanto segue con il tuo INDIRIZZO IP sul tuo browser (http://YOUR.IP.ADD.RESS )

Il tuo IP può essere recuperato dal server con il seguente comando:

ip addr show wlan0 | grep inet | awk '{ print $2 }'

Un esempio della pagina Web predefinita che Nginx ti offre quando è installato su Ubuntu 20.04

Configura Nginx

Ora configureremo Nginx aprendo il file di configurazione centrale e modificando la riga server_name con il tuo dominio.

nano /etc/nginx/sites-available/default
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name YOURDOMAIN.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page 500 502 503 504 /50x.html;
        #location = /50x.html {
        #       root /usr/share/nginx/html;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #       fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
        #       fastcgi_pass unix:/var/run/php5-fpm.sock;
        #       fastcgi_index index.php;
        #       include fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

Salva il file e riavvia il servizio Nginx in modo che le modifiche abbiano effetto.

systemctl restart nginx

Ora puoi creare/caricare il tuo contenuto web nella directory HTML di Nginx (ricorda di sostituire il file index.html esistente con il tuo index.html che è la tua home page) La directory predefinita per Ubuntu 20.04 è /usr/share/nginx/ html/. Aggiorna l'indice con il seguente comando:

nano /usr/share/nginx/html/

E poi?

Ora hai il tuo server Ubuntu 20.04 con Nginx installato, ora puoi iniziare a creare siti web ad alte prestazioni usando il tuo server web appena installato. Grazie per averci seguito e non esitare a ricontrollare con noi per ulteriori aggiornamenti.


Linux
  1. Come installare Nginx su Ubuntu 20.04

  2. Come installare Nginx su Ubuntu

  3. Come installare LEMP su Ubuntu 16.04

  4. Come installare Nginx su Ubuntu 18.04

  5. Come installare localizzare su un server Ubuntu

Come installare Nginx su Fedora 22

Come installare ownCloud su Ubuntu 14.04

Come installare Mumble Server su Ubuntu 15.04

Come installare Nginx su CentOS 7

Come installare Ansible Server su Ubuntu 18.04

Come installare NGINX su Ubuntu 18.04