In diesem Tutorial zeigen wir Ihnen, wie Sie LEMP auf Manjaro 20 installieren. Für diejenigen unter Ihnen, die es nicht wussten, LEMP steht für Linux, Nginx (ausgesprochen als Engine X), MySQL/MariaDB und PHP oder Perl oder Python. Alle Komponenten sind kostenlose Open-Source-Software und die Kombination eignet sich zum Erstellen dynamischer Webseiten. Der LEMP-Stack ist eine der beliebtesten Serverkonfigurationen der Welt.
Dieser Artikel geht davon aus, dass Sie zumindest über Grundkenntnisse in Linux verfügen, wissen, wie man die Shell verwendet, und vor allem, dass Sie Ihre Website auf Ihrem eigenen VPS hosten. Die Installation ist recht einfach und setzt Sie voraus im Root-Konto ausgeführt werden, wenn nicht, müssen Sie möglicherweise 'sudo
hinzufügen ‘ zu den Befehlen, um Root-Rechte zu erhalten. Ich zeige Ihnen Schritt für Schritt die Installation von LAMP Stack auf einem Manjaro 20 (Nibia).
LEMP auf Manjaro 20 Nibia installieren
Schritt 1. Bevor Sie das folgende Tutorial ausführen, vergewissern Sie sich, dass unser System auf dem neuesten Stand ist:
sudo pacman -Syu
Schritt 2. Nginx installieren.
Installieren Sie Nginx unter Manjaro Linux, indem Sie den folgenden Befehl ausführen:
sudo pacman -S nginx
Sobald Nginx installiert wurde, starte es und erlaube es, beim Systemstart zu starten:
sudo systemctl start nginx sudo systemctl enable nginx
Um die Einrichtung von Nginx zu überprüfen, öffnen Sie Ihren Browser und navigieren Sie zum Hostnamen oder der IP-Adresse des Servers, und Sie sollten die Standardtestseite von Nginx wie unten gezeigt sehen:
http://your-ip-address
Schritt 3. Installieren Sie MariaDB.
Führen Sie den folgenden Befehl aus, um MariaDB Server auf Manjaro zu installieren:
sudo pacman -S mariadb
Initialisieren Sie dann das MariaDB-Datenverzeichnis und erstellen Sie Systemtabellen wie unten gezeigt:
sudo mysql_install_db –user=mysql basedir=/usr –datadir=/var/lib/mysql
Als nächstes aktivieren und starten Sie es mit den folgenden Befehlen:
sudo systemctl start mariadb sudo systemctl enable mariadb
Standardmäßig ist MariaDB nicht gehärtet. Sie können MySQL mit mysql_secure_installation
sichern Skript. Sie sollten jeden Schritt sorgfältig lesen und befolgen, der ein Root-Passwort festlegt, anonyme Benutzer entfernt, Remote-Root-Login verbietet und die Testdatenbank und den Zugriff auf die sichere MariaDB entfernt:
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] Y Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Schritt 4. Installation von PHP.
Führen Sie den folgenden Befehl aus, um PHP zu installieren:
sudo pacman -S php php-fpm
Sobald die Installation abgeschlossen ist, starten und aktivieren Sie php-fpm
um beim Booten mit den folgenden Befehlen zu starten:
sudo systemctl start php-fpm sudo systemctl enable php-fpm
Wir müssen einige Änderungen an der Nginx-Konfigurationsdatei vornehmen:
sudo nano /etc/nginx/nginx.conf
Fügen Sie die folgenden Zeilen hinzu:
location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; root /usr/share/nginx/html; include fastcgi.conf; }
Speichern Sie die Datei und starten Sie sowohl Nginx als auch PHP-FPM neu, damit die Änderungen wirksam werden:
sudo systemctl restart nginx sudo systemctl restart php-fpm
Um die PHP-Installation zu testen, erstellen Sie eine info.php
Datei in /usr/share/nginx/html/
Pfad:
sudo nano /usr/share/nginx/html/info.php
Fügen Sie die folgenden Zeilen an und speichern Sie die Datei:
<?php phpinfo(); ?>
Schritt 5. Firewall konfigurieren.
Um externe Verbindungen zu unserem Manjaro-Linux-Webserver zuzulassen, müssen wir die Webports 80 und 443 öffnen. Aber zuerst installieren wir ufw
eine Firewall:
sudo pacman -S ufw sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable
Herzlichen Glückwunsch! Sie haben den LEMP-Server erfolgreich installiert. Vielen Dank, dass Sie dieses Tutorial zur Installation von LEMP (Nginx, MariaDB und PHP) in Manjaro 20-Systemen verwendet haben. Für zusätzliche Hilfe oder nützliche Informationen empfehlen wir Sie können die offiziellen Nginx-, MariaDB- und PHP-Websites besuchen.