Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 47af86d

Browse files
Added basic LAMP setup
1 parent 3c54d66 commit 47af86d

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed

‎lamp/db/dump.sql

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 5.1.3
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Host: db:3306
6+
-- Generation Time: Mar 15, 2022 at 01:57 PM
7+
-- Server version: 8.0.28
8+
-- PHP Version: 8.0.15
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
START TRANSACTION;
12+
SET time_zone = "+00:00";
13+
14+
15+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18+
/*!40101 SET NAMES utf8mb4 */;
19+
20+
--
21+
-- Database: `lamp_demo`
22+
--
23+
24+
-- --------------------------------------------------------
25+
26+
--
27+
-- Table structure for table `blog`
28+
--
29+
30+
CREATE TABLE `blog` (
31+
`id` int NOT NULL,
32+
`title` varchar(50) NOT NULL,
33+
`content` text NOT NULL,
34+
`date` date NOT NULL
35+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
36+
37+
--
38+
-- Dumping data for table `blog`
39+
--
40+
41+
INSERT INTO `blog` (`id`, `title`, `content`, `date`) VALUES
42+
(1, 'Integer Dapibus Odio', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In suscipit ante nec arcu laoreet scelerisque. Aenean maximus molestie massa. Nunc mollis accumsan scelerisque.', '2022年03月02日'),
43+
(2, 'Quisque id Maximus Metus', 'Quisque sit amet aliquet erat, vel rhoncus ipsum. Integer malesuada tortor nec ultrices faucibus. Sed rhoncus, augue et ultrices fermentum, nisl augue egestas justo, ac malesuada dui arcu non nisl. Nullam in lorem pretium, euismod turpis placerat, vestibulum risus.', '2022年03月10日');
44+
45+
--
46+
-- Indexes for dumped tables
47+
--
48+
49+
--
50+
-- Indexes for table `blog`
51+
--
52+
ALTER TABLE `blog`
53+
ADD PRIMARY KEY (`id`);
54+
55+
--
56+
-- AUTO_INCREMENT for dumped tables
57+
--
58+
59+
--
60+
-- AUTO_INCREMENT for table `blog`
61+
--
62+
ALTER TABLE `blog`
63+
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
64+
COMMIT;
65+
66+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
67+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
68+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

‎lamp/docker-compose.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: '3'
2+
services:
3+
db:
4+
image: mysql:latest
5+
command: --default-authentication-plugin=mysql_native_password
6+
environment:
7+
MYSQL_DATABASE: lamp_demo
8+
MYSQL_USER: lamp_demo
9+
MYSQL_PASSWORD: password
10+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
11+
networks:
12+
- lamp-demo
13+
volumes:
14+
- ./db:/docker-entrypoint-initdb.d
15+
www:
16+
depends_on:
17+
- db
18+
image: php:8.0.2-apache-buster
19+
volumes:
20+
- "./:/var/www/html"
21+
build:
22+
context: ./www
23+
dockerfile: Dockerfile
24+
ports:
25+
- 80:80
26+
- 443:443
27+
networks:
28+
- lamp-demo
29+
phpmyadmin:
30+
depends_on:
31+
- db
32+
image: phpmyadmin/phpmyadmin
33+
restart: always
34+
environment:
35+
- PMA_HOST=db
36+
- PMA_PORT=3306
37+
ports:
38+
- 8001:80
39+
networks:
40+
- lamp-demo
41+
networks:
42+
lamp-demo:
43+
driver: bridge

‎lamp/index.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
$connect = mysqli_connect(
4+
'db',
5+
'lamp_demo',
6+
'password',
7+
'lamp_demo'
8+
);
9+
10+
$query = 'SELECT *
11+
FROM blog';
12+
$result = mysqli_query($connect, $query);
13+
14+
echo '<h1>MySQL Content:</h1>';
15+
16+
while($record = mysqli_fetch_assoc($result))
17+
{
18+
echo '<h2>'.$record['title'].'</h2>';
19+
echo '<p>'.$record['content'].'</p>';
20+
echo 'Posted: '.$record['date'];
21+
echo '<hr>';
22+
}
23+
24+
?>

‎lamp/phpinfo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
phpinfo();
4+
5+
?>

‎lamp/www/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM php:8.0.2-apache-buster
2+
RUN docker-php-ext-install mysqli

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /