Über Nginx, eine leistungsstarke, leichte Webservice-Software
Umfeld
1. Geben Sie das komprimierte Softwarepaket frei, das von LAMP unter Windows benötigt wird (wenn Sie hier Fragen haben, lesen Sie bitte die vorherigen Blog-Artikel). Zweitens verwenden Sie Remote-Sharing unter Linux, um Dateien abzurufen und sie im Verzeichnis mnt bereitzustellen. [root@localhost ~]# smbclient -L //192.168.100.3/ ##Remote-Freigabezugriff Geben Sie das Kennwort von SAMBA\root ein: Freigabename Typ Kommentar --------- ---- ------- LAMP-C7-Diskette [root@localhost ~]# mount.cifs //192.168.100.3/LAMP-C7 /mnt ##In das Verzeichnis /mnt einbinden 3. Kompilieren und installieren Sie Nginx 1. Entpacken Sie das Quellpaket nach /opt und überprüfen Sie [root@localhost ~]# cd /mnt ##Zum Einhängeverzeichnis wechseln [root@localhost mnt]# ls apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txt apr-util-1.6.0.tar.gz Fehler.png mysql-5.6.26.tar.gz awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 nginx-1.12.0.tar.gz cronolog-1.6.2-14.el7.x86_64.rpm kali.jpg php-5.6.11.tar.bz2 [root@localhost mnt]# tar zxvf nginx-1.12.0.tar.gz -C /opt ##Entpacken Sie das Nginx-Quellpaket nach /opt [root@localhost mnt]# cd /opt/ ##Wechseln Sie in das entpackte Verzeichnis [root@localhost opt]# ls nginx-1.12.0 rh 2. Installieren Sie das für die Kompilierung erforderliche Umgebungskomponentenpaket [root@localhost opt]# yum -y install \ gcc \ //C-Sprache gcc-c++ \ //C++-Sprache pcre-devel \ //PCRE-Sprachtool zlib-devel //Bibliothek zur Datenkomprimierung 3. Programmbenutzer nginx erstellen und Nginx kompilieren [root@localhost opt]# useradd -M -s /sbin/nologin nginx ##Erstellen Sie einen Programmbenutzer, der sicher und für die Anmeldung nicht verfügbar ist [root@localhost opt]# id nginx UID = 1001 (nginx) GID = 1001 (nginx) Gruppe = 1001 (nginx) [root@localhost opt]# cd nginx-1.12.0/ ##Wechseln Sie zum nginx-Verzeichnis [root@localhost nginx-1.12.0]# ./configure \ ##nginx konfigurieren > --prefix=/usr/local/nginx \ ##Installationspfad> --user=nginx \ ##Benutzername> --group=nginx \ ##Benutzergruppe> --with-http_stub_status_module ##Statusstatistikmodul 4. Kompilieren und installieren [root@localhost nginx-1.12.0]# make ##Kompilieren… [root@localhost nginx-1.12.0]# make install ##Installieren… 5. Optimieren Sie das Nginx-Startskript, um die Systemerkennung zu erleichtern [root@localhost nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##Erstellen Sie einen Softlink, damit das System das Nginx-Startskript erkennt. [root@localhost nginx]# nginx -t ##Überprüfen Sie die Syntax der Konfigurationsdatei nginx: Die Syntax der Konfigurationsdatei /usr/local/nginx/conf/nginx.conf ist in Ordnung. nginx: Test der Konfigurationsdatei /usr/local/nginx/conf/nginx.conf ist erfolgreich [root@localhost nginx]# nginx ##Öffnen Sie ngnix [root@localhost nginx]# netstat -ntap | grep 80 ##Überprüfen Sie den Port. nginx hat tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 39620/nginx: master geöffnet [root@localhost nginx]# systemctl stop firewalld.service ##Firewall ausschalten [root@localhost nginx]# setenforce 0 6. Installieren Sie das elinks Web-Testtool und führen Sie Tests durch [root@localhost nginx]# yum install elinks -y ##Elinks-Software installieren [root@localhost nginx]# elinks http://localhost ##Nginx-Webseite testen 7. Serviceöffnung, Nachladen und Schließung [root@localhost nginx]# killall -s QUIT nginx ##Stoppen oder killall -3 nginx verwenden [root@localhost nginx]# killall -s HUP nginx ##Neustarten oder killall -1 nginx verwenden [root@localhost nginx]# nginx ##Öffnen 8. Erstellen Sie Management-Skripte, um das Service-Management zu erleichtern [root@localhost nginx]# killall -s QUIT nginx ##Stoppen oder killall -3 nginx verwenden [root@localhost nginx]# killall -s HUP nginx ##Neustarten oder killall -1 nginx verwenden [root@localhost nginx]# nginx ##Öffnen Nginx-Zugriffsstatusstatistiken Aktivieren Sie das Statusstatistikmodul HTTP_STUB_STATUS 1. Ändern Sie die Nginx-Konfigurationsdatei [root@localhost ~]# cd /usr/local/nginx/conf ##Zum Konfigurationsdateiverzeichnis wechseln [root@localhost conf]# vim nginx.conf ##Die Nginx-Konfigurationsdatei server ändern { hören Sie 80; Servername www.kgc.com; ##Geben Sie einen Domänennamen an. Zeichensatz utf-8; ##Chinesischer Zeichensatz #access_log logs/host.access.log main; Standort / { Stamm-HTML; Index Index.html Index.htm; } Standort /status { ##Statusstatistiken hinzufügen stub_status on; Zugriff_Abmeldung; } Zweitens installieren Sie den DNS-Server für die Domänennamenauflösung 1. Bind-Dienst installieren [root@localhost conf]# yum install bind -y ##DNS-Dienst installieren 2. Konfigurieren Sie die Hauptkonfigurationsdatei /etc/named.conf [root@localhost conf]# vim /etc/named.conf ##Hauptkonfigurationsdateioptionen { listen-on port 53 { any; }; ##Richten Sie die lokale Maschine so ein, dass sie auf allem hört. listen-on-v6 port 53 { ::1; }; Verzeichnis "/var/named"; Dump-Datei "/var/named/data/cache_dump.db"; Statistikdatei "/var/named/data/named_stats.txt"; Memstatistik-Datei "/var/named/data/named_mem_stats.txt"; Rekursionsdatei "/var/named/data/named.recursing"; Secroots-Datei "/var/named/data/named.secroots"; allow-query { any; }; ##Alles zulassen 3. Konfigurieren Sie die Zonenkonfigurationsdatei (etc/named.rfc1912.zones). [root@localhost conf]# vim /etc/named.rfc1912.zones ##Konfigurieren Sie die Zonenkonfigurationsdatei zone "localhost" IN { ##Kopieren Sie die Vorlage in den folgenden Typ master; Datei "named.localhost"; Aktualisierung zulassen { keine; }; }; zone "kgc.com" IN { ##Ändern Sie localhost in kgc.com Typ Master; Datei "kgc.com.zone"; ##Erstellen Sie eine Zonendaten-Konfigurationsdatei allow-update { none; }; }; 4. Bearbeiten Sie die Zonendaten-Konfigurationsdatei ( kgc.com.zone ) [root@localhost conf]# cd /var/named [root@localhost benannt]# cp -p benannt.localhost kgc.com.zone ##Kopieren Sie die Vorlage als kgc.com.zone [root@localhost named]# vim kgc.com.zone ##Bearbeiten Sie die Zonendaten-Konfigurationsdatei $TTL 1D @ IN SOA @ rname.ungültig. ( 0; Seriennummer 1D; aktualisieren 1H; erneut versuchen 1W; ablaufen 3H ) ; Minimum @NEIN Eine 127.0.0.1 www IN A 192.168.13.128 ##IPv6 löschen und diesem Computer eine Domänennamenauflösungsadresse hinzufügen 5. Schalten Sie die Firewall aus und starten Sie den Dienst [root@localhost named]# systemctl start named ##DNS-Dienst starten [root@localhost named]# systemctl stop firewalld.service ##Firewall schließen [root@localhost named]# setenforce 0 ##Erweiterte Funktion schließen 6. Verwenden Sie zum Testen die Win10-Testmaschine Autorisierungsbasierte Zugriffskontrolle Die Konfigurationsschritte sind grundsätzlich die gleichen wie bei Apache Generieren Sie eine Benutzerkennwort-Authentifizierungsdatei, ändern Sie die Hauptkonfigurationsdatei in das entsprechende Verzeichnis, fügen Sie Authentifizierungskonfigurationselemente hinzu, starten Sie den Dienst neu und greifen Sie auf den Test zu 1. Ändern Sie die Hauptkonfigurationsdatei [root@localhost ~]# cd /usr/local/nginx/conf ##Zum Konfigurationsdateiverzeichnis wechseln [root@localhost conf]# vim nginx.conf ##Speicherort der Nginx-Konfigurationsdatei ändern / { auth_basic "geheim"; ##Verifizierungstyp auth_basic_user_file /usr/local/nginx/passwd.db; ##Verifizierungsdateipfad root html; Index Index.html Index.htm; } 2. Installieren Sie das httpd-tools-Toolkit und legen Sie die Kennwortauthentifizierungsdatei fest [root@localhost conf]# yum install httpd-tools -y ##Tool-Paket installieren[root@localhost conf]# htpasswd -c /usr/local/nginx/passwd.db test ##Passwort-Authentifizierungsdatei festlegenNeues Passwort: ##Passwort eingebenNeues Passwort erneut eingeben: ##Passwort bestätigenPasswort für Benutzertest hinzufügen [root@localhost conf]# cat /usr/local/nginx/passwd.db ##Kennwortauthentifizierungsdatei anzeigen test:$apr1$LqqHZeX3$24E7/HeacTVRzKA7nvSgY/ [root@localhost conf]# service nginx stop ##Dienst beenden [root@localhost conf]# service nginx start ##Dienst starten 3. Testen mit einer Win10-Testmaschine Das Obige ist der vollständige Inhalt dieses Artikels. Ich hoffe, er wird für jedermanns Studium hilfreich sein. Ich hoffe auch, dass jeder 123WORDPRESS.COM unterstützen wird. Das könnte Sie auch interessieren:
|
>>: Vue3.0+vite2 implementiert dynamisches asynchrones Lazy Loading von Komponenten
Vorwort Um Dateiberechtigungen im Terminal eines ...
Inhaltsverzeichnis Vorwort Methode 1: Hoher Kontr...
Vorwort Ich glaube, dass jeder auf einem Remote-S...
Inhaltsverzeichnis 1. Übersicht 2. Definieren Sie...
Dieser Artikel zeichnet das Installationstutorial...
Manchmal ist es notwendig, bei Benutzereingaben e...
Herunterladen Download-Adresse: https://dev.mysql...
Inhaltsverzeichnis Schritt 1: Installieren Sie no...
Dieser Artikel stellt ein interessantes Pseudoele...
Inhaltsverzeichnis 1. Szenario 2. Vereinfachen Si...
Vorwort: Die verteilte Master-Slave-Architektur v...
Inhaltsverzeichnis 1. Szenario 2. Implementieren ...
Für die Arbeit muss ich einen adaptiven Webseitene...
Zeigen Sie je nach Benutzerberechtigung unterschi...
Inhaltsverzeichnis Tutorial-Reihe 1. Installieren...