Skip to content

Commit dbc698f

Browse files
author
Eduard Muradov
committed
Initial commit
0 parents  commit dbc698f

File tree

8 files changed

+183
-0
lines changed

8 files changed

+183
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea
2+
.env
3+
4+
data/*
5+
!data/start

data/start/index.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Welcome to <?= $_SERVER['HTTP_HOST'] ?>!</title>
5+
<style>
6+
body {
7+
width: 40em;
8+
margin: 0 auto;
9+
font-family: Tahoma, Verdana, Arial, sans-serif;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<?php if ($_SERVER['REQUEST_URI'] === '/info') : ?>
15+
<h1>PHP Info</h1>
16+
<?php phpinfo(); ?>
17+
<?php else : ?>
18+
<h1>Welcome to <?= $_SERVER['HTTP_HOST'] ?>!</h1>
19+
<p>This's example of using <a target="_blank" href="">this repository</a>. PHP info is <a href="/info">here</a>.</p>
20+
21+
<p>To add new .local domain just create new directory in <b>data</b> dir of project root.</p>
22+
<p>If your need to additional NGINX configuration, create in domain folder <b>nginx.conf</b> with your server config and restart nginx container.</p>
23+
<p>This domain has own nginx config <b>nginx.conf</b>, which is located in <b>data/start</b> directory.</p>
24+
25+
<p><em>Feel free to contact me on <a target="_blank" href="">GitHub</a></em></p>
26+
<?php endif; ?>
27+
</body>
28+
</html>

data/start/nginx.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
index index.php;
2+
client_max_body_size 500M;
3+
4+
root /var/www/$subd;
5+
6+
location / {
7+
try_files $uri /index.php$is_args$args;
8+
}
9+
10+
location ~ ^/index\.php(/|$) {
11+
fastcgi_pass fastcgi_backend;
12+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
13+
include fastcgi_params;
14+
15+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
16+
fastcgi_param DOCUMENT_ROOT $realpath_root;
17+
18+
internal;
19+
}
20+
21+
location ~ \.php$ {
22+
return 404;
23+
}

docker-compose.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: '3.7'
2+
3+
services:
4+
php-backend:
5+
image: edspc/php-fpm-alpine:7.2
6+
environment:
7+
- PHP_IDE_CONFIG=serverName=php-backend.docker
8+
- XDEBUG_CONFIG=remote_host=172.30.0.1 remote_port=9000 remote_enable=on idekey=PHPSTORM
9+
volumes:
10+
- ./data:/var/www:rw
11+
- ./docker/php-backend/etc/php-fpm.conf:/usr/local/etc/php-fpm.conf:ro
12+
- ./docker/php-backend/etc/conf.d:/usr/local/etc/conf.d:ro
13+
14+
database:
15+
image: mysql:8
16+
environment:
17+
- MYSQL_ROOT_PASSWORD=azzTPLYbnTsRUG8EHHTn
18+
ports:
19+
- 127.0.0.1:3306:3306
20+
command: --innodb-use-native-aio=0
21+
volumes:
22+
- db-data:/var/lib/mysql
23+
24+
nginx:
25+
image: edspc/nginx-alpine
26+
ports:
27+
- 80:80
28+
depends_on:
29+
- php-backend
30+
volumes:
31+
- ./data:/var/www:rw
32+
- ./docker/nginx/etc/nginx.conf:/etc/nginx/nginx.conf:ro
33+
- ./docker/nginx/etc/conf.d:/etc/nginx/conf.d
34+
35+
networks:
36+
default:
37+
ipam:
38+
driver: default
39+
config:
40+
- subnet: 172.30.0.0/16
41+
42+
volumes:
43+
db-data:

docker/nginx/etc/conf.d/default.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
server {
2+
charset utf-8;
3+
listen 80;
4+
5+
server_name "~^(?<subd>.+)\.local";
6+
include /var/www/*/nginx.conf;
7+
}

docker/nginx/etc/nginx.conf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
user www-data;
2+
worker_processes auto;
3+
pid /run/nginx.pid;
4+
5+
events {
6+
worker_connections 2048;
7+
multi_accept on;
8+
use epoll;
9+
}
10+
11+
http {
12+
server_tokens off;
13+
sendfile on;
14+
tcp_nopush on;
15+
tcp_nodelay on;
16+
keepalive_timeout 30;
17+
types_hash_max_size 2048;
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
access_log /var/log/nginx/access.log;
21+
error_log /var/log/nginx/error.log;
22+
23+
upstream fastcgi_backend {
24+
server php-backend:9000;
25+
}
26+
27+
include /etc/nginx/conf.d/*.conf;
28+
29+
gzip on;
30+
gzip_comp_level 4;
31+
gzip_min_length 80;
32+
gzip_types text/css
33+
text/plain
34+
text/javascript
35+
text/xml
36+
application/javascript
37+
application/json
38+
application/x-javascript
39+
application/xml
40+
application/xml+rss
41+
application/xhtml+xml
42+
application/x-font-ttf
43+
application/x-font-opentype
44+
application/vnd.ms-fontobject
45+
application/rss+xml
46+
image/svg+xml
47+
image/x-icon
48+
font/ttf
49+
font/opentype;
50+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[opcache]
2+
opcache.enable=1
3+
opcache.max_accelerated_files=20000
4+
opcache.memory_consumption=256
5+
opcache.max_wasted_percentage=10
6+
opcache.interned_strings_buffer=16
7+
opcache.fast_shutdown=1
8+
9+
[fpm]
10+
memory_limit = 756M
11+
post_max_size = 50M
12+
upload_max_filesize = 50M

docker/php-backend/etc/php-fpm.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[global]
2+
daemonize = no
3+
4+
[www]
5+
user = www-data
6+
group = www-data
7+
8+
listen = [::]:9000
9+
pm = dynamic
10+
pm.max_children = 10
11+
pm.start_servers = 4
12+
pm.min_spare_servers = 2
13+
pm.max_spare_servers = 6
14+
clear_env = no
15+
catch_workers_output = yes

0 commit comments

Comments
 (0)