GNU/Linux >> Tutoriales Linux >  >> Linux

Cómo instalar la pila Apache, MariaDB y PHP (FAMP) en FreeBSD 11

En este tutorial, le mostraremos cómo instalar Apache, MariaDB y PHP en FreeBSD 11. Si no sabe, FAMP es el acrónimo de FreeBSD, Apache, MySQL/MariaDB, PHP. FreeBSD 11 es la última versión en este momento cuando se hizo este artículo.

Requisitos

Antes de comenzar con esta guía, al menos debe tener conocimientos básicos de Linux o Unix, conocer el comando básico de shell para Linux o Unix, iniciar sesión como usuario raíz y, por supuesto, necesita tener FreeBSD 11 instalado en su PC o servidor.

Paso 1:actualice su FreeBSD

Antes de continuar con la instalación de cualquier software, primero debemos actualizar nuestro sistema operativo FreeBSD 11.

Ejecute el siguiente comando en su servidor FreeBSD.

$ su
# freebsd-update fetch
# freebsd-update install

Si ha instalado una actualización reciente, debería obtener resultados como estos

# freebsd-update fetch
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching public key from update5.freebsd.org... done.
Fetching metadata signature for 11.0-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Preparing to download files... done.

No updates needed to update system to 11.0-RELEASE-p0.
# freebsd-update install
src component not installed, skipped
No updates are available to install.
Run '/usr/sbin/freebsd-update fetch' first.

Paso 2:instalar el servidor web Apache

Instalaremos apache 2.4 usando el comando pkg.

# pkg install apache24

Si es la primera vez que usa el comando pkg en su sistema operativo, debería recibir una notificación para instalar la herramienta de administración de paquetes, simplemente elija y

# pkg install apache24
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y

Luego, habilitamos apache para que se ejecute en el momento del arranque usando este comando:

# sysrc apache24_enable=yes

Inicie el servicio de apache usando este comando:

# service apache24 start

Probar el servicio web de apache:

Antes de probar apache, necesitamos configurar la configuración de apache. Edite este archivo usando nano /usr/local/etc/apache24/httpd.conf .

# nano /usr/local/etc/apache24/httpd.conf

Busque y edite esta variable como estas según su dirección IP o nombre de host, en este ejemplo usamos la dirección IP 192.168.14.126:

ServerName 192.168.14.126:80

Salga y guarde el archivo. Luego reinicie el servicio de apache usando el siguiente comando:

# service apache24 restart

Ahora, abra su navegador web y navegue hasta:http://dirección-IP/ o http://localhost/. Debería ver la página de prueba de Apache.

Paso 3:instalar MariaDB

MariaDB es un reemplazo directo de MySQL. Tiene el mismo nombre de proceso, la misma sintaxis y configuración. Para instalar, ejecute el siguiente comando pkg:

# pkg install mariadb100-server

Copie la configuración de ejemplo de MariaDB del directorio '/usr/local/share/mysql/ ' a '/usr/local/etc/ ':

# cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf

Habilite e inicie el servicio MariaDB:

# sysrc mysql_enable=yes
# service mysql-server start

Por defecto, la contraseña raíz de la instalación de MariaDB estaba vacía. Por razones de seguridad, crearemos una contraseña de root usando este comando:

# mysql_secure_installation

Cuando se le solicite "Ingrese la contraseña actual para root", simplemente presione la tecla ENTER y configure la contraseña dos veces. Luego simplemente presione Y para aceptar los valores predeterminados.

Salida de muestra:

# 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): 
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: 
Re-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] 
 ... 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] 
 ... 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] 
 - 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] 
 ... 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!

Paso 4:instalar PHP

Necesitamos php para el contenido dinámico del servidor, para instalar PHP ejecute el siguiente comando:

# pkg install mod_php56 php56-mysql php56-mysqli

Después del éxito de la instalación, necesitamos copiar php.ini configuración de muestra:

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Actualice los cambios con este comando:

# rehash

Necesitamos configurar PHP con el servidor web apache, por lo que necesitamos editar el archivo de configuración de apache usando nano:

# nano /usr/local/etc/apache24/httpd.conf

Busque la sección DirectoryIndex y agregue index.php delante del index.html existente como se muestra a continuación.

[...]

<IfModule dir_module>
 DirectoryIndex index.php index.html
</IfModule>

[...]

Y luego, agregue las siguientes líneas al final del archivo de configuración de Apache

<FilesMatch "\.php$">
 SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
 SetHandler application/x-httpd-php-source
</FilesMatch>

Guarde y cierre el archivo. Necesitamos reiniciar el servidor web Apache para cambiar la configuración:

# service apache24 restart

Paso 5:Prueba PHP

Para probar PHP, crearemos un script php de muestra usando nano:

# nano /usr/local/www/apache24/data/test.php

Agregue la siguiente línea:

<?php phpinfo(); ?>

Guarde y cierre el archivo. Abra el navegador web y navegue hasta la dirección de su servidor http://IP-Address/test.php.

Paso 6:instalar módulos PHP (extensiones)

Para que su secuencia de comandos PHP funcione por completo, a veces necesitamos instalar algunos módulos PHP adicionales (extensiones), puede omitir este paso si no necesita instalar ninguna extensión. Para ver la lista de módulos disponibles, simplemente ejecute:

# pkg search php56

Salida de muestra:

# pkg search php56
mod_php56-5.6.26               PHP Scripting Language
php56-5.6.26                   PHP Scripting Language
php56-bcmath-5.6.26            The bcmath shared extension for php
php56-bz2-5.6.26               The bz2 shared extension for php
php56-calendar-5.6.26          The calendar shared extension for php
php56-ctype-5.6.26             The ctype shared extension for php
php56-curl-5.6.26              The curl shared extension for php
php56-dba-5.6.26               The dba shared extension for php
php56-dom-5.6.26               The dom shared extension for php
php56-exif-5.6.26              The exif shared extension for php
php56-extensions-1.0           "meta-port" to install PHP extensions
php56-fileinfo-5.6.26          The fileinfo shared extension for php
php56-filter-5.6.26            The filter shared extension for php
php56-ftp-5.6.26               The ftp shared extension for php
php56-gd-5.6.26                The gd shared extension for php
php56-gettext-5.6.26           The gettext shared extension for php
php56-gmp-5.6.26               The gmp shared extension for php
php56-hash-5.6.26              The hash shared extension for php
php56-iconv-5.6.26             The iconv shared extension for php
php56-imap-5.6.26              The imap shared extension for php
php56-interbase-5.6.26         The interbase shared extension for php
php56-json-5.6.26              The json shared extension for php
php56-ldap-5.6.26              The ldap shared extension for php
php56-mbstring-5.6.26          The mbstring shared extension for php
php56-mcrypt-5.6.26            The mcrypt shared extension for php
php56-mssql-5.6.26             The mssql shared extension for php

Puede verificar lo que hace cada módulo desde la sección de comentarios en el resultado anterior, o simplemente ejecute el siguiente comando:

# pkg search -f php56-curl

Salida de muestra:

# pkg search -f php56-curl
php56-curl-5.6.26
Name           : php56-curl
Version        : 5.6.26
Origin         : ftp/php56-curl
Architecture   : freebsd:11:x86:64
Prefix         : /usr/local
Repository     : FreeBSD [pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly]
Categories     : ftp
Licenses       : PHP301
Maintainer     : [email protected]
WWW            : http://www.php.net/
Comment        : The curl shared extension for php
Shared Libs required:
	libcurl.so.4
Annotations    :
	cpe            : cpe:2.3:a:php:php:5.6.26:::::freebsd11:x64
Flat size      : 90.1KiB
Pkg size       : 26.3KiB
Description    :
PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open
Source general-purpose scripting language that is especially suited for
Web development and can be embedded into HTML.  Its syntax draws upon C,
Java, and Perl, and is easy to learn.  The main goal of the language is to
allow web developers to write dynamically generated webpages quickly, but
you can do much more with PHP.

WWW: http://www.php.net/

Para instalar la extensión php, por ejemplo, instalaremos php56-curl, ejecute este siguiente comando:

# pkg install php56-curl

Para realizar cambios después de la instalación, es necesario reiniciar el servicio web de apache:

# service apache24 restart

Felicitaciones, ha instalado con éxito la pila de Apache, MariaDB y PHP (FAMP) en FreeBSD 11, ahora está listo para alojar sus sitios web o cualquier aplicación basada en web.


Linux
  1. Cómo instalar Nginx con PHP y MySQL (LEMP Stack) en CentOS 7

  2. Cómo instalar Nginx, MariaDB y PHP (FEMP) Stack en FreeBSD

  3. Cómo instalar Apache, MariaDB y PHP (FAMP) Stack en FreeBSD

  4. Cómo instalar y configurar PHP y Apache (pila LAMP) en Ubuntu 20.04

  5. Cómo instalar y configurar PHP y Apache (pila LAMP) en Debian 11

Cómo instalar Apache y PHP en OpenSUSE 15.1

Cómo configurar la pila LAMP (Apache, MariaDB y PHP) en Debian 11

Cómo instalar Apache, MariaDB, PHP (LAMP) en Fedora 32

Cómo instalar FAMP (FreeBSD 10, Apache, MySQL, PHP) en una nube o servidor VPS

Cómo instalar una pila LAMP (Apache, MariaDB, PHP) en CentOS 7

Cómo instalar LAMP en Fedora 23 (Linux, Apache, MySQL y PHP)