So installieren Sie Nginx, MySQL und PHP (FEMP) Stack unter FreeBSD 12.0

Ein FEMP-Stack, der mit einem LEMP-Stack unter Linux vergleichbar ist, ist eine Sammlung von Open-Source-Software, die normalerweise zusammen installiert wird, damit ein FreeBSD-Server dynamische Websites und Webanwendungen hosten kann. FEMP ist eine Abkürzung für FreeBSD, Nginx, MySQL und PHP.

In diesem Handbuch stellen wir Elemente eines FEMP-Stacks auf einer FreeBSD 12.0 Vultr-Instanz mithilfe pkgdes FreeBSD-Paketmanagers bereit .

Bedarf

Bevor Sie mit diesem Handbuch beginnen, benötigen Sie Folgendes:

  • Ein FreeBSD 12.0 VPS.
  • Ein Benutzer mit Root-Rechten oder ein sudoBenutzer, der Konfigurationsänderungen vornimmt.
  • Grundlegende Kenntnisse des FreeBSD-Systems und der Befehlszeilenschnittstelle werden empfohlen.

Bevor Sie beginnen

Überprüfen Sie die FreeBSD-Version.

uname -ro
# FreeBSD 12.0-RELEASE-p6

Stellen Sie sicher, dass Ihr FreeBSD-System auf dem neuesten Stand ist.

freebsd-update fetch install
pkg update && pkg upgrade -y

Installieren Sie die erforderlichen Pakete.

pkg install -y sudo vim bash curl

Erstellen Sie ein neues Benutzerkonto mit Ihrem bevorzugten Benutzernamen. Wir benutzen johndoe.

adduser

# Username: johndoe
# Full name: John Doe
# Uid (Leave empty for default): <Enter>
# Login group [johndoe]: <Enter>
# Login group is johndoe. Invite johndoe into other groups? []: wheel
# Login class [default]: <Enter>
# Shell (sh csh tcsh nologin) [sh]: bash
# Home directory [/home/johndoe]: <Enter>
# Home directory permissions (Leave empty for default): <Enter>
# Use password-based authentication? [yes]: <Enter>
# Use an empty password? (yes/no) [no]: <Enter>
# Use a random password? (yes/no) [no]: <Enter>
# Enter password: your_secure_password
# Enter password again: your_secure_password
# Lock out the account after creation? [no]: <Enter>
# OK? (yes/no): yes
# Add another user? (yes/no): no
# Goodbye!

Führen Sie den visudoBefehl aus und kommentieren Sie die %wheel ALL=(ALL) ALLZeile aus, damit Mitglieder der wheelGruppe einen beliebigen Befehl ausführen können.

visudo

# Uncomment by removing hash (#) sign
# %wheel ALL=(ALL) ALL

Wechseln Sie nun zu Ihrem neu erstellten Benutzer mit su:

su - johndoe

HINWEIS: Ersetzen Sie johndoedurch Ihren Benutzernamen.

Richten Sie die Zeitzone ein:

sudo tzsetup

Hauptleitung Nginx installieren

You can install Nginx using FreeBSD's package manager, pkg. A package manager allows you to install most software effortlessly from a repository maintained by FreeBSD. You can learn more about how to use pkg here.

To install the latest mainline Nginx, issue the following command:

sudo pkg install -y nginx-devel

Check the version:

nginx -v
# nginx version: nginx/1.17.1

This command will install the latest mainline version, which can reliably be used on a production server. If you want to install the latest stable release, just use nginx package instead of nginx-devel.

Now, enable and start Nginx:

sudo sysrc nginx_enable=yes
sudo service nginx start

To check that Nginx has started you can run the following command:

sudo service nginx status

As a result, you will see something similar to the following:

# Output
nginx is running as pid 17607.

You can verify that Nginx was installed and working without errors by visiting your server's public IP address in your web browser. Navigate to your_server_IP. You will see the default "Welcome to nginx!" page.

Installing MySQL

Again, you can utilize pkg to obtain and install your software.

Install MySQL using pkg:

sudo pkg install -y mysql80-client mysql80-server

Check the version:

mysql --version
# mysql  Ver 8.0.16 for FreeBSD12.0 on amd64 (Source distribution)

Now, enable and start MySQL:

sudo sysrc mysql_enable=yes
sudo service mysql-server start

To check that MySQL has started you can run the following command:

sudo service mysql-server status

You'll view something similar to the following:

# Output
mysql is running as pid 19066.

As a good practice, you should run the mysql_secure_installation security script that will remove some insecure defaults and slightly limit access to your database system.

sudo mysql_secure_installation

You will be asked to set a password, followed by some other questions. Enter a strong password and then for the rest of the questions press ENTER to select the defaults.

Installing PHP 7.3

To install PHP 7.3 with pkg, run this command:

sudo pkg install -y php73

Check the version.

php --version
# PHP 7.3.7 (cli) (built: Jul 18 2019 01:14:37) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies

Soft-link php.ini-production to php.ini.

sudo ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Now, enable and start PHP-FPM:

sudo sysrc php_fpm_enable=yes
sudo service php-fpm start

To check that PHP-FPM has started you can run the following command:

sudo service php-fpm status

As a result, you'll see something similar:

# Output
php_fpm is running as pid 23005.

Installing PHP Modules (Optional)

To enhance the functionality of PHP, you can optionally install some additional modules.

To see currently compiled in PHP modules, you can run this:

php -m
# [PHP Modules]
# Core
# date
# libxml
# mysqlnd
# pcre
# Reflection
# SPL
# standard

# [Zend Modules]

To search for available PHP modules, you can use this command:

pkg search ^php73-*

The results will be mostly PHP 7.3 modules that you can install:

# Output
# php73-7.3.7                    PHP Scripting Language
# php73-Ice37-3.7.2              Modern alternative to object middleware such as CORBA/COM/DCOM/COM+
# php73-aphpbreakdown-2.2.2      Code-Analyzer for PHP for Compatibility Check-UP
# php73-aphpunit-1.8             Testing framework for unit tests
# php73-bcmath-7.3.7             The bcmath shared extension for php
# php73-brotli-0.7.0             Brotli extension for PHP
# php73-bsdconv-11.5.0           PHP wrapper for bsdconv
# php73-bz2-7.3.7                The bz2 shared extension for php
# php73-calendar-7.3.7           The calendar shared extension for php
# php73-composer-1.8.6           Dependency Manager for PHP
# php73-ctype-7.3.7              The ctype shared extension for php
# php73-curl-7.3.7               The curl shared extension for php
# . . .

If, after researching, you decide that you need to install a package, you can do so by using the pkg install command. Most PHP web applications will require additional modules, so it's good to know how to search for them.

Configuring Nginx to use PHP module

Before using PHP, you must configure it to work with Nginx.

Run sudo vim /usr/local/etc/nginx/test.conf and populate the file with the following content:

server {

  listen 80;
  server_name SERVER_IP; # Replace with your IP or hostname
  root /usr/local/www/nginx-dist;
  index index.php index.html index.htm;

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

}

Save the file and exit with :+W+Q

Now we need to include test.conf in the main nginx.conf file. The main configuration file for Nginx lives under /usr/local/etc/nginx as nginx.conf.

Run sudo vim /usr/local/etc/nginx/nginx.conf to open the main configuration file in Vim and add the following line to the http {} block.

include test.conf;

Test Nginx configuration:

sudo nginx -t

Because you've made configuration changes in Nginx, you have to reload the service for those to be applied. Otherwise, Nginx will still work with the earlier configuration.

sudo service nginx reload

Testing PHP processing

To test that your system is configured correctly for PHP, you can create a very basic PHP script. You'll call this script info.php. By default, the root is set to /usr/local/www/nginx-dist. You can create the info.php file under that location:

sudo vim /usr/local/www/nginx-dist/info.php

Add this code to that file:

<?php phpinfo(); ?>

Navigate to http://your_server_IP/ìnfo.php and you will see the following page:

So installieren Sie Nginx, MySQL und PHP (FEMP) Stack unter FreeBSD 12.0

After installation and setup you should remove info.php file to avoid disclosing information about the server to the public.

sudo rm /usr/local/www/nginx-dist/info.php

Conclusion

Congratulations, you've successfully installed a FEMP stack on your FreeBSD 12.0 VPS. Now you have multiple choices for what to do next. You've installed a platform that will allow you to install most kinds of websites and web software on top of it.



Leave a Comment

So installieren Sie Blacklistd unter FreeBSD 11.1

So installieren Sie Blacklistd unter FreeBSD 11.1

Einführung Jeder Dienst, der mit dem Internet verbunden ist, ist ein potenzielles Ziel für Brute-Force-Angriffe oder ungerechtfertigten Zugriff. Es gibt Tools wie fail2ba

So installieren Sie Osclass unter FreeBSD 12

So installieren Sie Osclass unter FreeBSD 12

Verwenden Sie ein anderes System? Osclass ist ein Open Source-Projekt, mit dem Sie auf einfache Weise eine klassifizierte Site ohne technisches Wissen erstellen können. Seine Quelle

So installieren Sie Couch CMS 2.0 auf einem FreeBSD 11 FAMP VPS

So installieren Sie Couch CMS 2.0 auf einem FreeBSD 11 FAMP VPS

Verwenden Sie ein anderes System? Couch CMS ist ein einfaches und flexibles, kostenloses und Open-Source-Content-Management-System (CMS), mit dem Webdesigner entwerfen können

So installieren Sie Lychee 3.1 Photo Album auf einem FreeBSD 11 FAMP VPS

So installieren Sie Lychee 3.1 Photo Album auf einem FreeBSD 11 FAMP VPS

Verwenden Sie ein anderes System? Lychee 3.1 Photo Album ist ein einfaches und flexibles, kostenloses Open-Source-Tool zur Fotoverwaltung, das auf einem VPS-Server ausgeführt wird. Es wird installiert

Installieren von Fork CMS unter FreeBSD 12

Installieren von Fork CMS unter FreeBSD 12

Verwenden Sie ein anderes System? Fork ist ein Open-Source-CMS, das in PHP geschrieben wurde. Der Forks-Quellcode wird auf GitHub gehostet. Diese Anleitung zeigt Ihnen, wie Sie Fork CM installieren

Erstellen Sie eine Auslagerungsdatei unter FreeBSD 10

Erstellen Sie eine Auslagerungsdatei unter FreeBSD 10

Vultr FreeBSD-Server sind standardmäßig nicht so konfiguriert, dass sie Swap Space enthalten. Wenn Sie eine Einweg-Cloud-Instanz beabsichtigen, brauchen Sie diese wahrscheinlich nicht

So ändern Sie die Größe einer Festplatte in FreeBSD

So ändern Sie die Größe einer Festplatte in FreeBSD

Das FreeBSD-Betriebssystem verwendet UFS (Unix File System) für sein Root-Partitions-Dateisystem. sonst bekannt als freebsd-ufs Im Falle eines Upgrades

So installieren Sie Matomo Analytics unter FreeBSD 11

So installieren Sie Matomo Analytics unter FreeBSD 11

Verwenden Sie ein anderes System? Matomo (ehemals Piwik) ist eine Open Source-Analyseplattform, eine offene Alternative zu Google Analytics. Matomo Quelle wird gehostet o

So aktivieren Sie TLS 1.3 in Nginx unter FreeBSD 12

So aktivieren Sie TLS 1.3 in Nginx unter FreeBSD 12

Verwenden Sie ein anderes System? TLS 1.3 ist eine Version des TLS-Protokolls (Transport Layer Security), das 2018 als vorgeschlagener Standard in RFC 8446 veröffentlicht wurde

So installieren Sie Backdrop CMS auf einem FreeBSD 11 FAMP VPS

So installieren Sie Backdrop CMS auf einem FreeBSD 11 FAMP VPS

Verwenden Sie ein anderes System? Hintergrund CMS 1.8.0 ist ein einfaches und flexibles, mobilfreundliches, kostenloses und Open Source Content Management System (CMS), das es uns ermöglicht

So installieren Sie ImpressPages CMS 5.0 auf einem FreeBSD 11 FAMP VPS

So installieren Sie ImpressPages CMS 5.0 auf einem FreeBSD 11 FAMP VPS

Verwenden Sie ein anderes System? ImpressPages CMS 5.0 ist ein einfaches und effektives, kostenloses und Open Source, benutzerfreundliches, MVC-basiertes Content Management System (CMS).

Installieren Sie eSpeak unter FreeBSD 12

Installieren Sie eSpeak unter FreeBSD 12

Verwenden Sie ein anderes System? ESpeak kann TTS-Audiodateien (Text-to-Speech) generieren. Diese können aus vielen Gründen nützlich sein, z. B. um Ihr eigenes Turin zu erstellen

So installieren Sie LimeSurvey CE unter FreeBSD 12

So installieren Sie LimeSurvey CE unter FreeBSD 12

Verwenden Sie ein anderes System? LimeSurvey ist eine Open-Source-Umfragesoftware, die in PHP geschrieben wurde. Der LimeSurvey-Quellcode wird auf GitHub gehostet. Diese Anleitung zeigt Ihnen

So installieren Sie Monica unter FreeBSD 12

So installieren Sie Monica unter FreeBSD 12

Verwenden Sie ein anderes System? Monica ist ein Open-Source-System für das persönliche Beziehungsmanagement. Stellen Sie sich das als CRM vor (ein beliebtes Tool, das von Verkaufsteams in th verwendet wird

So installieren Sie Automad CMS unter FreeBSD 12

So installieren Sie Automad CMS unter FreeBSD 12

Verwenden Sie ein anderes System? Automad ist ein Open Source File-basiertes Content Management System (CMS) und eine in PHP geschriebene Template Engine. Der Automad-Quellcode i

Auswählen eines Betriebssystems: CentOS, Ubuntu, Debian, FreeBSD, CoreOS oder Windows Server

Auswählen eines Betriebssystems: CentOS, Ubuntu, Debian, FreeBSD, CoreOS oder Windows Server

Dieser Artikel enthält eine kurze Übersicht über die Server-Betriebssysteme, die als Vorlagen für Vultr angeboten werden. CentOS CentOS ist eine Open-Source-Version von RHEL (Re

Radio-Streaming auf FreeBSD 10 mit IceCast und Ices

Radio-Streaming auf FreeBSD 10 mit IceCast und Ices

Im folgenden Tutorial wird erläutert, wie Sie einen IceCast-Radio-Streaming-Server einrichten und Audiodateien (Musik oder Podcasts) auf der FreeBSD-Plattform abspielen. Diese Tutoria

So installieren Sie Omeka Classic 2.4 CMS auf einem FreeBSD 11 FAMP VPS

So installieren Sie Omeka Classic 2.4 CMS auf einem FreeBSD 11 FAMP VPS

Verwenden Sie ein anderes System? Omeka Classic 2.4 CMS ist eine kostenlose Open-Source-Plattform für digitales Publizieren und Content Management System (CMS) für den Austausch von Digita

So sichern Sie FreeBSD mit der PF Firewall

So sichern Sie FreeBSD mit der PF Firewall

Dieses Tutorial zeigt Ihnen, wie Sie Ihren FreeBSD-Server mithilfe der OpenBSD PF-Firewall schützen. Wir gehen davon aus, dass Sie eine saubere FreeBSD-Installation bereitgestellt haben. B.

So installieren Sie WonderCMS unter FreeBSD 12

So installieren Sie WonderCMS unter FreeBSD 12

Verwenden Sie ein anderes System? WonderCMS ist ein Open Source, schnelles und kleines Flatfile-CMS, das in PHP geschrieben wurde. WonderCMS-Quellcode wird auf Github gehostet. Dieser Leitfaden wird

Kann KI mit zunehmender Anzahl von Ransomware-Angriffen kämpfen?

Kann KI mit zunehmender Anzahl von Ransomware-Angriffen kämpfen?

Ransomware-Angriffe nehmen zu, aber kann KI helfen, den neuesten Computervirus zu bekämpfen? Ist KI die Antwort? Lesen Sie hier, ob KI boone oder bane ist

ReactOS: Ist das die Zukunft von Windows?

ReactOS: Ist das die Zukunft von Windows?

ReactOS, ein quelloffenes und kostenloses Betriebssystem, ist hier mit der neuesten Version. Kann es den Anforderungen moderner Windows-Benutzer genügen und Microsoft zu Fall bringen? Lassen Sie uns mehr über dieses alte, aber neuere Betriebssystem erfahren.

Bleiben Sie in Verbindung über die WhatsApp Desktop App 24*7

Bleiben Sie in Verbindung über die WhatsApp Desktop App 24*7

Whatsapp hat endlich die Desktop-App für Mac- und Windows-Benutzer auf den Markt gebracht. Jetzt können Sie ganz einfach von Windows oder Mac auf WhatsApp zugreifen. Verfügbar für Windows 8+ und Mac OS 10.9+

Wie kann KI die Prozessautomatisierung auf die nächste Stufe heben?

Wie kann KI die Prozessautomatisierung auf die nächste Stufe heben?

Lesen Sie dies, um zu erfahren, wie Künstliche Intelligenz bei kleinen Unternehmen beliebt wird und wie sie die Wahrscheinlichkeit erhöht, sie wachsen zu lassen und ihren Konkurrenten einen Vorsprung zu verschaffen.

macOS Catalina 10.15.4 Supplement Update verursacht mehr Probleme als sie zu lösen

macOS Catalina 10.15.4 Supplement Update verursacht mehr Probleme als sie zu lösen

Vor kurzem hat Apple macOS Catalina 10.15.4 als Ergänzungsupdate veröffentlicht, um Probleme zu beheben, aber es scheint, dass das Update mehr Probleme verursacht, die zum Bricking von Mac-Computern führen. Lesen Sie diesen Artikel, um mehr zu erfahren

13 Tools zur kommerziellen Datenextraktion von Big Data

13 Tools zur kommerziellen Datenextraktion von Big Data

13 Tools zur kommerziellen Datenextraktion von Big Data

Was ist ein Journaling-Dateisystem und wie funktioniert es?

Was ist ein Journaling-Dateisystem und wie funktioniert es?

Unser Computer speichert alle Daten in einer organisierten Weise, die als Journaling-Dateisystem bekannt ist. Es ist eine effiziente Methode, die es dem Computer ermöglicht, Dateien zu suchen und anzuzeigen, sobald Sie auf die Suche klicken.https://wethegeek.com/?p=94116&preview=true

Technologische Singularität: Eine ferne Zukunft der menschlichen Zivilisation?

Technologische Singularität: Eine ferne Zukunft der menschlichen Zivilisation?

Da sich die Wissenschaft schnell weiterentwickelt und einen Großteil unserer Bemühungen übernimmt, steigt auch das Risiko, uns einer unerklärlichen Singularität auszusetzen. Lesen Sie, was Singularität für uns bedeuten könnte.

Ein Einblick in 26 Big-Data-Analysetechniken: Teil 1

Ein Einblick in 26 Big-Data-Analysetechniken: Teil 1

Ein Einblick in 26 Big-Data-Analysetechniken: Teil 1

Der Einfluss künstlicher Intelligenz im Gesundheitswesen 2021

Der Einfluss künstlicher Intelligenz im Gesundheitswesen 2021

KI im Gesundheitswesen hat in den letzten Jahrzehnten große Fortschritte gemacht. Somit wächst die Zukunft der KI im Gesundheitswesen immer noch von Tag zu Tag.