GNU/Linux >> LINUX-Kenntnisse >  >> Cent OS

So installieren Sie Lighttpd mit PHP-FPM und MariaDB unter CentOS 7

Lighttpd ist ein sicherer, schneller, standardkonformer Webserver, der für geschwindigkeitskritische Umgebungen entwickelt wurde. Dieses Tutorial zeigt, wie Sie Lighttpd auf einem Centos 7-Server mit PHP-Unterstützung (über PHP-FPM) und MySQL-Unterstützung installieren können. PHP-FPM (FastCGI Process Manager) ist eine alternative PHP-FastCGI-Implementierung mit einigen zusätzlichen Funktionen, die für Websites jeder Größe nützlich sind, insbesondere für stark frequentierte Websites. Ich verwende in diesem Tutorial PHP-FPM anstelle von Lighttpds spawn-fcgi.

1 Vorbemerkung

In diesem Tutorial verwende ich den Hostnamen server1.example.com mit der IP-Adresse 192.168.1.100. Diese Einstellungen können für Sie abweichen, daher müssen Sie sie gegebenenfalls ersetzen.

2 MariaDB als Drop-in-Ersatz für MySQL installieren

Zuerst installieren wir MySQL wie folgt:

yum -y install mariadb mariadb-server

Dann erstellen wir die Systemstart-Links für MySQL (damit MySQL automatisch startet, wenn das System hochfährt) und starten den MySQL-Server:

systemctl enable  mariadb.service
systemctl start  mariadb.service

Legen Sie Passwörter für das MarisDB-Root-Konto fest:

mysql_secure_installation
[[email protected] ~]# mysql_secure_installation
/usr/bin/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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): <-- press enter
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] <-- y
New password: <-- enter new password
Re-enter new password: <-- enter new password
Password updated successfully!
Reloading privilege tables..
... Success!

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!

3 Installieren von Lighttpd

Da Lighttpd und PHP-FPM nicht in den offiziellen CentOS-Repositorys verfügbar sind, müssen wir das EPEL-Repository aktivieren:

yum -y install epel-release

Importieren Sie den EPEL GPG-Schlüssel:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

und dann ausführen:

yum update

Danach können wir Lighttpd wie folgt installieren:

yum -y install lighttpd

Dann erstellen wir die Systemstart-Links für Lighttpd (damit Lighttpd automatisch startet, wenn das System hochfährt) und starten es:

systemctl enable  lighttpd.service
systemctl start  lighttpd.service

Wenn Lighttpd mit der folgenden Fehlermeldung nicht gestartet werden kann...

(network.c.203) socket failed: Address family not supported by protocol

... öffnen Sie /etc/lighttpd/lighttpd.conf...

nano /etc/lighttpd/lighttpd.conf

... und ändern Sie server.use-ipv6 von enable auf disable:

[...]
##
## Use IPv6?
##
server.use-ipv6 = "disable"
[...]

Versuchen Sie dann erneut, Lighttpd zu starten - es sollte jetzt ohne Probleme funktionieren:

systemctl start  lighttpd.service

Lighttpd hat seinen Dokumentenstamm in /var/www/ htdocs (Basisverzeichnis /var/www plus htdocs als Unterverzeichnis gemäß der lighttpd.conf-Datei), aber es installiert die Standarddateien nach /var/www/ lighttpd. Das ist inkonsistent, also müssen wir das Verzeichnis wie folgt umbenennen.

mv /var/www/lighttpd /var/www/htdocs

Richten Sie nun Ihren Browser auf http://192.168.1.100, und Sie sollten die folgende Seite sehen:

Lighttpds standardmäßiger Dokumentenstamm ist /var/www/htdocs/ unter CentOS 7, und die Konfigurationsdatei ist /etc/lighttpd/lighttpd.conf.

4 Installation von PHP

Wir können PHP in Lighttpd durch PHP-FPM zum Laufen bringen, das wir wie folgt installieren:

yum -y install php-fpm lighttpd-fastcgi

PHP-FPM ist ein Daemon-Prozess, der einen FastCGI-Server auf Port 9000 ausführt.

Öffnen Sie /etc/php-fpm.d/www.conf...

nano /etc/php-fpm.d/www.conf

... und setze Benutzer und Gruppe auf lighttpd:

[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = lighttpd
; RPM: Keep a group allowed to write in log dir.
group = lighttpd
[...]

Erstellen Sie die Systemstartlinks für PHP-FPM und starten Sie es:

systemctl enable  php-fpm.service
systemctl start  php-fpm.service

Cent OS
  1. So installieren Sie ownCloud 9.1 mit Nginx und MariaDB auf CentOS 7

  2. So installieren Sie WordPress mit HHVM und Nginx unter CentOS 7

  3. So installieren Sie Lighttpd mit PHP5 FastCGI und MySQL unter CentOS 6 / RHEL 6

  4. So installieren Sie Varnish und phpMyAdmin auf einem CentOS 7 VPS mit Nginx, MariaDB und PHP-FPM

  5. Installieren Sie Magento auf CentOS 7 mit Nginx, PHP-FPM und MariaDB

So installieren Sie Lighttpd mit PHP FPM und MariaDB unter CentOS 7 / RHEL 7

So installieren und konfigurieren Sie Cacti unter CentOS 7

So installieren Sie OwnCloud 8 mit Nginx und PHP-FPM auf CentOS 6

So installieren Sie Lighttpd mit PHP und MariaDB unter CentOS 7

So installieren Sie Lighttpd mit PHP und MariaDB unter Ubuntu 15.04

So installieren Sie Apache mit PHP-FPM auf CentOS 8