{"id":4635,"date":"2025-07-26T13:24:09","date_gmt":"2025-07-26T19:24:09","guid":{"rendered":"https:\/\/linuxitos.com\/main\/?p=4635"},"modified":"2025-07-26T13:24:11","modified_gmt":"2025-07-26T19:24:11","slug":"php-mariadb-docker-fedora","status":"publish","type":"post","link":"https:\/\/linuxitos.com\/main\/php-mariadb-docker-fedora\/","title":{"rendered":"PHP &amp; MariaDB &amp; Docker | Fedora"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxitos.com\/main\/wp-content\/uploads\/2025\/07\/php-docker-like-xampp.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"380\" src=\"https:\/\/linuxitos.com\/main\/wp-content\/uploads\/2025\/07\/php-docker-like-xampp.png\" alt=\"\" class=\"wp-image-4636\" srcset=\"https:\/\/linuxitos.com\/main\/wp-content\/uploads\/2025\/07\/php-docker-like-xampp.png 800w, https:\/\/linuxitos.com\/main\/wp-content\/uploads\/2025\/07\/php-docker-like-xampp-300x143.png 300w, https:\/\/linuxitos.com\/main\/wp-content\/uploads\/2025\/07\/php-docker-like-xampp-768x365.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Contexto<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">XAMPP era el entorno de desarrollo para PHP favorito de muchos, ya que inclu\u00eda en empaquetados Base de datos, PHP, Perl, phpMyAdmin para la gesti\u00f3n de base de datos.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sin embargo, XAMPP se qued\u00f3 hasta la versi\u00f3n 8.2.12, aparentemente est\u00e1 descontinuado, por lo que es necesario buscar nuevas formas de probar y desarrollar PHP<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Aqu\u00ed entra en juego Docker, la idea es sencilla, instalar docker en fedora, crear un contenedor con PHP y MariaDB. De lado del host en \u00e9ste caso Fedora, crear una carpeta donde estar\u00e1n todos los proyectos, enviarlos a docker y desde el host abrir los proyectos en un navegador.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Instalar Docker en Fedora<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">La instalaci\u00f3n de docker se explica en \u00e9ste otro post: <a href=\"https:\/\/blog.linuxitos.com\/post\/instalar-docker-fedora-42\" target=\"_blank\" rel=\"noreferrer noopener\">Instalaci\u00f3n de docker en Fedora<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Configurar en Host<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Crear una carpeta llamada www en la carpeta personal:<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">mkdir ~\/www<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Crear dentro del directorio ~\/www los directorios de devs y docker<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">cd ~\/www\nmkdir devs\nmkdir docker<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Dentro del director docker crear  los siguientes archivos:<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">gnome-text-editor docker-compose.yml<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Y a\u00f1adir el siguiente texto:<\/p>\n\n\n\n<pre style=\"background: rgb(242, 242, 242); border-radius: 2px; border: 1px solid #aaa; box-sizing: border-box; color: #222; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">services:\n  web:\n    build:\n      context: .\n      dockerfile: Dockerfile\n    container_name: php-web\n    ports:\n      - \"81:80\"\n    volumes:\n      - ..\/devs:\/var\/www\/html\/devs\n    networks:\n      - backend\n\n  mariadb:\n    image: mariadb:11\n    container_name: mariadb\n    restart: always\n    ports:\n      - \"3308:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: d7yMyRVFGybbPDcF\n      MYSQL_DATABASE: defaultdb\n    volumes:\n      - mariadb_data:\/var\/lib\/mysql\n      - .\/initdb:\/docker-entrypoint-initdb.d\n    networks:\n      - backend\n\n  phpmyadmin:\n    image: phpmyadmin\/phpmyadmin\n    container_name: phpmyadmin\n    restart: always\n    ports:\n      - \"8081:80\"\n    environment:\n      PMA_HOST: mariadb\n      PMA_PORT: 3306\n      PMA_USER: root\n      PMA_PASSWORD: d7yMyRVFGybbPDcF\n    networks:\n      - backend\n\nvolumes:\n  mariadb_data:\n\n\nnetworks:\n  backend:\n<\/pre>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">gnome-text-editor Dockerfile<\/pre>\n\n\n\n<pre style=\"background: rgb(242, 242, 242); border-radius: 2px; border: 1px solid #aaa; box-sizing: border-box; color: #222; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">FROM php:8.4-apache\n\nRUN apt-get update && apt-get install -y \\\n\tlibpng-dev libjpeg-dev libfreetype6-dev \\\n\tlibonig-dev libxml2-dev zip unzip git curl \\\n\tlibicu-dev mariadb-client \\\n\t&& docker-php-ext-install intl pdo pdo_mysql\n\nRUN a2enmod rewrite\n\nRUN echo '<VirtualHost *:80>\\n\\\n\tDocumentRoot \/var\/www\/html\\n\\\n\t<Directory \/var\/www\/html>\\n\\\n\tOptions Indexes FollowSymLinks\\n\\\n\tAllowOverride All\\n\\\n\tRequire all granted\\n\\\n\t<\/Directory>\\n\\\n\t<\/VirtualHost>' > \/etc\/apache2\/sites-available\/000-default.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Crear una carpeta llamada initdb crear el siguiente archivo y pegar el contenido:<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">gnome-text-editor root-remote<\/pre>\n\n\n\n<pre style=\"background: rgb(242, 242, 242); border-radius: 2px; border: 1px solid #aaa; box-sizing: border-box; color: #222; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY 'd7yMyRVFGybbPDcF';\nGRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;\nFLUSH PRIVILEGES;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Para ejecutar el contenedor en segundo plano usar:<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">docker compose up --build -d<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Para ejecutar el contenedor no en segundo plano:<\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\"> docker compose up --build<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Configurar proyectos<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Cada proyecto que ese cree dentro del directorio ~\/www\/devs\/ deber\u00e1 contener el sigueinte htaccess. Para \u00e9sto, entrar al proyecto creado, por ejemplo, para un proyecto de laravel, a\u00f1adir lo siguiente: <\/p>\n\n\n\n<pre style=\"background: rgb(54, 63, 72); border-radius: 6px; border: 0px; box-sizing: border-box; color: white; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">gnome-text-editor .htaccess<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Options All -Indexes\n\n&lt;IfModule mod_rewrite.c>\n\tOptions +FollowSymlinks\n\tRewriteEngine On\n\n\tRewriteCond %{REQUEST_FILENAME} !-d\n    \tRewriteRule ^(.*)\/$ \/$1 &#91;L,R=301]\n\n\tRewriteCond %{HTTPS} !=on\n\tRewriteCond %{HTTP_HOST} ^www\\.(.+)$ &#91;NC]\n\tRewriteRule ^ http:\/\/%1%{REQUEST_URI} &#91;R=301,L]\n\n\tRewriteCond %{REQUEST_FILENAME} !-f\n\tRewriteCond %{REQUEST_FILENAME} !-d\n\tRewriteRule ^(.*)$ index.php\/$1 &#91;L]\n\n    RewriteCond %{HTTP:Authorization} .\n    RewriteRule .* - &#91;E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\n&lt;\/IfModule>\n\n&lt;IfModule !mod_rewrite.c>\n    ErrorDocument 404 index.php\n&lt;\/IfModule>\n\n\nServerSignature Off\n\n&lt;Files .env>\norder allow,deny\nDeny from all\n&lt;\/Files><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Si es un proyecto de laravel o codeigniter modificar el archivo .env para el acceso de la base de datos:<\/p>\n\n\n\n<pre style=\"background: rgb(242, 242, 242); border-radius: 2px; border: 1px solid #aaa; box-sizing: border-box; color: #222; font-family: menlo, monaco, monospace; font-style: inherit; font-weight: inherit; line-height: 15.68px; margin-bottom: 1.1em; max-width: 100%; outline: 0px; overflow: auto; padding: 13.125px 16.4062px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;\">DB_CONNECTION=mysql\n#para acceder a los datos desde la aplicacion usar esta linea, y para migraciones, comentar esta linea\nDB_HOST=mariadb\nDB_PORT=3306\n#para migraciones se descomenta la linea de abajo\n#DB_HOST=127.0.0.1\nDB_DATABASE=dashtool\nDB_USERNAME=root\nDB_PASSWORD=d7yMyRV\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Y listo, eso ser\u00eda todo. Ahora los proyecto se lanzar\u00e1n directo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contexto XAMPP era el entorno de desarrollo para PHP favorito de muchos, ya que inclu\u00eda en empaquetados Base de datos, PHP, Perl, phpMyAdmin para la gesti\u00f3n de base de datos. Sin embargo, XAMPP se qued\u00f3 hasta la versi\u00f3n 8.2.12, aparentemente est\u00e1 descontinuado, por lo que es necesario buscar nuevas formas de probar y desarrollar PHP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4636,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1540,1543,7,137,929,1511],"tags":[1694,1690,1556,1587],"class_list":["post-4635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-develepmet","category-developer","category-fedora","category-mariadb","category-mysql-server","category-server","tag-docker","tag-mariadb","tag-php","tag-xampp"],"_links":{"self":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/4635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/comments?post=4635"}],"version-history":[{"count":6,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/4635\/revisions"}],"predecessor-version":[{"id":4642,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/4635\/revisions\/4642"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/media\/4636"}],"wp:attachment":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/media?parent=4635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/categories?post=4635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/tags?post=4635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}