-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b6f99
commit 7fd354a
Showing
6 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM php:8.0.0-apache | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN docker-php-ext-install mysqli | ||
# Include alternative DB driver | ||
# RUN docker-php-ext-install pdo | ||
# RUN docker-php-ext-install pdo_mysql | ||
RUN apt-get update \ | ||
&& apt-get install -y sendmail libpng-dev \ | ||
&& apt-get install -y libzip-dev \ | ||
&& apt-get install -y zlib1g-dev \ | ||
&& apt-get install -y libonig-dev \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& docker-php-ext-install zip | ||
|
||
RUN docker-php-ext-install mbstring | ||
RUN docker-php-ext-install zip | ||
RUN docker-php-ext-install gd | ||
|
||
RUN a2enmod rewrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Watch the video 👇 | ||
|
||
[![Watch the video](https://img.youtube.com/vi/v-r_12oezds/maxresdefault.jpg)](https://youtu.be/v-r_12oezds) | ||
|
||
# docker-lamp | ||
|
||
Docker with Apache, MySQL 8.0, PHPMyAdmin and PHP. | ||
|
||
I use docker-compose as an orchestrator. To run these containers: | ||
|
||
``` | ||
docker-compose up -d | ||
``` | ||
|
||
Open phpmyadmin at [http://127.0.0.1:8000](http://127.0.0.1:8000) | ||
Open web browser to look at a simple php example at [http://127.0.0.1:80](http://127.0.0.1:80) | ||
|
||
Clone YourProject on `www/` and then, open web [http://127.0.0.1/YourProject](http://127.0.0.1/YourProject) | ||
|
||
Run MySQL client: | ||
|
||
- `docker-compose exec db mysql -u root -p` | ||
|
||
Infrastructure as code! | ||
|
||
You can read this a Spanish article in Crashell platform: [Apache, PHP, MySQL y PHPMyAdmin con Docker LAMP](https://www.crashell.com/estudio/apache_php_mysql_y_phpmyadmin_con_docker_lamp). | ||
|
||
|
||
### Infrastructure model | ||
|
||
![Infrastructure model](.infragenie/infrastructure_model.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: "3.1" | ||
services: | ||
db: | ||
image: mysql | ||
expose: | ||
- "3306" | ||
command: --default-authentication-plugin=mysql_native_password | ||
environment: | ||
MYSQL_DATABASE: dbname | ||
MYSQL_PASSWORD: test | ||
MYSQL_ROOT_PASSWORD: test | ||
volumes: | ||
- ./dump:/docker-entrypoint-initdb.d | ||
- ./conf:/etc/mysql/conf.d | ||
- persistent:/var/lib/mysql | ||
networks: | ||
- default | ||
apache1: | ||
build: . | ||
expose: | ||
- "80" | ||
volumes: | ||
- ./www/apache1:/var/www/html | ||
links: | ||
- db | ||
networks: | ||
- default | ||
- web | ||
labels: | ||
- traefik.http.routers.lamp1.rule=Host(`lamp.systeminfo.es`) | ||
- traefik.http.routers.lamp1.tls=true | ||
- traefik.http.routers.lamp1.tls.certresolver=lets-encrypt | ||
phpmyadmin: | ||
image: phpmyadmin/phpmyadmin | ||
links: | ||
- db:db | ||
expose: | ||
- 80 | ||
environment: | ||
MYSQL_USER: root | ||
MYSQL_PASSWORD: test | ||
MYSQL_ROOT_PASSWORD: test | ||
volumes: | ||
persistent: | ||
|
||
networks: | ||
web: | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
SET time_zone = "+00:00"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8mb4 */; | ||
|
||
|
||
CREATE TABLE `Person` ( | ||
`id` int(11) NOT NULL, | ||
`name` varchar(20) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
|
||
INSERT INTO `Person` (`id`, `name`) VALUES | ||
(1, 'William'), | ||
(2, 'Marc'), | ||
(3, 'John'), | ||
(4, 'Antonio Moreno'); | ||
|
||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<html> | ||
<head> | ||
<title>Welcome to LAMP Infrastructure</title> | ||
<meta charset="utf-8"> | ||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.c> | ||
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<?php | ||
$server_ip = $_SERVER["SERVER_ADDR"]; | ||
echo "<h1>¡Hola, RAUL MORALES te da la bienvenida al contenedor con ip interna ".$server_ip."</h1>"; | ||
|
||
$conn = mysqli_connect('db', 'root', 'test', "dbname"); | ||
|
||
$query = 'SELECT * From Person'; | ||
$result = mysqli_query($conn, $query); | ||
|
||
echo '<table class="table table-striped">'; | ||
echo '<thead><tr><th></th><th>id</th><th>name</th></tr></thead>'; | ||
while($value = $result->fetch_array(MYSQLI_ASSOC)){ | ||
echo '<tr>'; | ||
echo '<td><a href="#"><span class="glyphicon glyphicon-search"></span></a></td>'; | ||
foreach($value as $element){ | ||
echo '<td>' . $element . '</td>'; | ||
} | ||
|
||
echo '</tr>'; | ||
} | ||
echo '</table>'; | ||
|
||
$result->close(); | ||
mysqli_close($conn); | ||
?> | ||
</div> | ||
</body> | ||
</html> |