GNU/Linux >> Tutoriales Linux >  >> Cent OS

Cómo instalar Lighttpd con PHP-FPM y MariaDB en CentOS 7

Lighttpd es un servidor web seguro, rápido y compatible con los estándares diseñado para entornos de velocidad crítica. Este tutorial muestra cómo puede instalar Lighttpd en un servidor Centos 7 con soporte PHP (a través de PHP-FPM) y soporte MySQL. PHP-FPM (Administrador de procesos FastCGI) es una implementación alternativa de PHP FastCGI con algunas características adicionales útiles para sitios de cualquier tamaño, especialmente sitios más ocupados. Uso PHP-FPM en este tutorial en lugar de spawn-fcgi de Lighttpd.

1 nota preliminar

En este tutorial, utilizo el nombre de host server1.example.com con la dirección IP 192.168.1.100. Estas configuraciones pueden diferir para usted, por lo que debe reemplazarlas cuando corresponda.

2 Instalación de MariaDB como reemplazo directo de MySQL

Primero, instalamos MySQL así:

yum -y install mariadb mariadb-server

Luego creamos los enlaces de inicio del sistema para MySQL (para que MySQL se inicie automáticamente cada vez que se inicia el sistema) e iniciamos el servidor MySQL:

systemctl enable  mariadb.service
systemctl start  mariadb.service

Establecer contraseñas para la cuenta raíz de MarisDB:

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 Instalación de Lighttpd

Debido a que Lighttpd y PHP-FPM no están disponibles en los repositorios oficiales de CentOS, debemos habilitar el repositorio EPEL:

yum -y install epel-release

Importe la clave EPEL GPG:

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

y luego ejecuta:

yum update

Posteriormente, podemos instalar Lighttpd así:

yum -y install lighttpd

Luego creamos los enlaces de inicio del sistema para Lighttpd (para que Lighttpd se inicie automáticamente cada vez que se inicia el sistema) y lo iniciamos:

systemctl enable  lighttpd.service
systemctl start  lighttpd.service

Si Lighttpd no se inicia con el siguiente mensaje de error...

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

... abra /etc/lighttpd/lighttpd.conf...

nano /etc/lighttpd/lighttpd.conf

... y cambie server.use-ipv6 de activado a desactivado:

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

Luego intente iniciar Lighttpd nuevamente; ahora debería funcionar sin ningún problema:

systemctl start  lighttpd.service

Lighttpd tiene su documento raíz en /var/www/ htdocs (directorio base /var/www más htdocs como subdirectorio según el archivo lighttpd.conf) pero instala los archivos predeterminados en /var/www/ luztpd. Eso es inconsistente, así que tenemos que cambiar el nombre del directorio de esta manera.

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

Ahora dirija su navegador a http://192.168.1.100 y debería ver la siguiente página:

La raíz del documento predeterminada de Lighttpd es /var/www/htdocs/ en CentOS 7, y el archivo de configuración es /etc/lighttpd/lighttpd.conf.

4 Instalación de PHP

Podemos hacer que PHP funcione en Lighttpd a través de PHP-FPM que instalamos así:

yum -y install php-fpm lighttpd-fastcgi

PHP-FPM es un proceso daemon que ejecuta un servidor FastCGI en el puerto 9000.

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

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

... y configure el usuario y el grupo en 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
[...]

Cree los enlaces de inicio del sistema para PHP-FPM e inícielo:

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

Cent OS
  1. Cómo instalar ownCloud 9.1 con Nginx y MariaDB en CentOS 7

  2. Cómo instalar WordPress con HHVM y Nginx en CentOS 7

  3. Cómo instalar Lighttpd con PHP5 FastCGI y MySQL en CentOS 6 / RHEL 6

  4. Cómo instalar Varnish y phpMyAdmin en un VPS CentOS 7 con Nginx, MariaDB y PHP-FPM

  5. Instale Magento en CentOS 7, con Nginx, PHP-FPM y MariaDB

Cómo instalar Lighttpd con PHP FPM y MariaDB en CentOS 7 / RHEL 7

Cómo instalar y configurar Cacti en CentOS 7

Cómo instalar OwnCloud 8 con Nginx y PHP-FPM en CentOS 6

Cómo instalar Lighttpd con PHP y MariaDB en CentOS 7

Cómo instalar Lighttpd con PHP y MariaDB en Ubuntu 15.04

Cómo instalar Apache con PHP-FPM en CentOS 8