Instalar la pila FAMP que significa FreBSD Apache MySQL PHP en la jail www
1.- Creación de la Jail www con Bastille
3.- Instalar Wordpress. Activar rdr en Firewall PF
pkg search apache2
apache24-2.4.55 Version 2.4.x of Apache web server
p5-Apache2-SOAP-0.73_4 Apache2 mod_perl2 SOAP Server
p5-Apache2-SiteControl-1.05_3 Perl web site authentication/authorization system
Instalar el servidor web Aapache
pkg install apache24
Activar Apache usando sysrc
sysrc apache24_enable=YES
apache24_enable: NO -> YES
Iniciar el servicio
service apache24 onestart
starting apache24
Editar el archivo de configuración de Apache
cd /usr/local/etc/apache24
Hacer una copia del archivo original
cp httpd.conf httpd.conf-original
Editar /usr/local/etc/apache24/httpd.conf
ServerName 10.10.10.2
Listen 80
Reiniciar Apache
service apache24 restart
Comprobar que esta funcionando
ps aux | grep httpd
root 10186 0.0 0.2 195432 30168 - SsJ 15:27 0:00.07 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 10195 0.0 0.2 195432 30180 - IJ 15:27 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 10196 0.0 0.2 195432 30180 - IJ 15:27 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 10198 0.0 0.2 195432 30180 - IJ 15:27 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 10199 0.0 0.2 195432 30180 - IJ 15:27 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
www 10200 0.0 0.2 195432 30180 - IJ 15:27 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
Status de Apache
apachectl status
apache24 is running as pid 12118.
Instalar el sistema de gestión de base de datos MariaDB, MySQL, o Percona
pkg install mariadb104-server
Activar MySQL
sysrc mysql_enable=YES
mysql_enable: NO -> YES
Iniciar el servicio
service mysql-server onestart
Installing MariaDB/MySQL system tables in '/var/db/mysql' ...
OK
Comprobar que está en marcha
ps aux | grep mysql
mysql 16574 0.0 0.0 13596 3132 - IsJ 07:28 0:00.01 /bin/sh /usr/local/bin
mysql 29646 0.0 0.5 601752 83468 - IJ 07:28 0:00.10 /usr/local/libexec/mar
root 34451 0.0 0.0 12840 2324 4 S+J 07:30 0:00.00 grep mysql
Proceder con la correcta instalación y despliegue de la base de datos. Como es la primera instalación, se establece la contraseña raíz de la base de datos y responder las preguntas con los valores predeterminados.
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.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
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!
Instalar PHP Scripting Language
pkg install php80
Configurar PHP
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Instalar módulos o dependencias de PHP para que Wordpress funcione correctamente
pkg install mod_php80 php80-bz2 php80-ctype php80-curl php80-dom php80-exif \
php80-extensions php80-fileinfo php80-filter php80-gd php80-iconv php80-intl \
php80-mbstring php80-mysqli php80-opcache php80-pdo php80-pdo_mysql php80-pdo_sqlite \
php80-pear php80-pear-Services_JSON php80-pecl-mcrypt php80-phar php80-posix \
php80-session php80-simplexml php80-sqlite3 php80-tokenizer php80-xmlphp80-xmlreader \
php80-xmlwriter php80-zip php80-zlib
Puede listar los módulos instalados con el comando
php -m
La instalación de mod_php80 contiene un mensaje para usar el módulo de forma correcta, editando el archivo de configuración principal de Apache.
cd /usr/local/etc/apache24
Editar /usr/local/etc/apache24/httpd.conf cerca de la línea 285 añadir index.php
vim /usr/local/etc/apache24/httpd.conf
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
284 <IfModule dir_module>
285 DirectoryIndex index.html
286 </IfModule>
Quedaría como se ve a continuación
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Agregar las líneas de configuración que le permiten a Apache comunicarse con PHP
cd /usr/local/etc/apache24/modules.d/
touch 001_mod-php.conf
vim 001_mod-php.conf
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
Listar el directorio
root@www:/usr/local/etc/apache24/modules.d # ls
001_mod-php.conf README_modules.d
Comprobar errores de sintaxis en el archivo de configuración de Apache
apachectl configtest
...
Syntax OK
Reiniciar Aapache
apachectl graceful
...
Performing a graceful restart
Cambiar AllowOverride none por AllowOverride All httpd.conf, cerca de la línea número 272
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
#AllowOverride None
AllowOverride All
Habilitar modulo rewrite
cat /usr/local/etc/apache24/httpd.conf | nl | grep rewrite
177 #LoadModule rewrite_module libexec/apache24/mod_rewrite.so
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
LoadModule alias_module libexec/apache24/mod_alias.so
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
LoadModule php_module libexec/apache24/libphp.so
Activar módulo PHP-FPM, para que PHP pueda comunicarse con el servidor Apache
sysrc php_fpm_enable=YES
php_fpm_enable: -> YES
service php-fpm start
Performing sanity check on php-fpm configuration:
[23-Jan-2023 09:20:27] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
Realizamos la comprobación
ps aux | grep php
root 53873 0.0 0.2 193764 28628 - SsJ 10:17 0:00.06 php-fpm: master proces
www 54234 0.0 0.2 193764 28640 - IJ 10:17 0:00.00 php-fpm: pool www (php
www 54393 0.0 0.2 193764 28640 - IJ 10:17 0:00.00 php-fpm: pool www (php
root 30063 0.0 0.0 12840 2312 1 S+J 10:47 0:00.00 grep php
Revisar archivo de configuración de Apache
apachectl configtest
Performing sanity check on apache24 configuration:
Syntax OK
Creamos el archivo info.php para asegurarnos que todo funciona como debería
vim /usr/local/www/apache24/data/info.php
<?php
phpinfo();
?>
Salir del jail www
root@www: # exit
logout
Desde Firefox
http://10.10.10.2/info.php
FreeBSD es genial!.
No hay comentarios:
Publicar un comentario