Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTsikhonov/hw6 #592

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# PHP_2023
### Init Docker
```bash
cd app
docker-compose up --build -d
docker exec -it php-server bash
composer install
exit;
```

https://otus.ru/lessons/razrabotchik-php/?utm_source=github&utm_medium=free&utm_campaign=otus
- Add **mysite.local** in /etc/hosts

### Test
```bash
curl -d "[email protected],[email protected]" -X POST http://mysite.local
```
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
nginx/logs/*
vendor
21 changes: 21 additions & 0 deletions app/Docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.3'

services:
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/logs:/var/log/nginx
- ./www:/var/www
links:
- php

php:
build: ./php
container_name: php-server
hostname: php-server
volumes:
- ./www:/var/www

17 changes: 17 additions & 0 deletions app/nginx/conf/mysite.local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
index index.php;
server_name mysite.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
29 changes: 29 additions & 0 deletions app/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM php:8.2-fpm

RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
libmemcached-dev libssl-dev zlib1g-dev \
&& pecl install memcached-3.2.0 \
&& docker-php-ext-enable memcached \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN apt-get update && apt-get install -y \
zip libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip


# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Добавим свой php.ini, можем в нем определять свои значения конфига
ADD php.ini /usr/local/etc/php/conf.d/40-custom.ini

# Указываем рабочую директорию для PHP
WORKDIR /var/www

# Запускаем контейнер
CMD ["php-fpm"]
14 changes: 14 additions & 0 deletions app/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
;display_errors = of
display_errors = on
;Разрешить сокращенные теги
;short_open_tag = of
short_open_tag = on
;post_max_size = 8M
post_max_size = 200M
;upload_max_filesize = 2M
upload_max_filesize = 200M
;Если не указать тайм зону, то будут сыпаться ошибки.
;date.timezone =
date.timezone = Europe/Moscow
24 changes: 24 additions & 0 deletions app/www/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "root/www",
"type": "project",
"autoload": {
"psr-4": {
"Root\\Www\\": "src/"
}
},
"authors": [
{
"name": "MT"
}
],
"require": {
"slim/slim": "4.*",
"slim/psr7": "^1.6",
"nyholm/psr7": "^1.8",
"nyholm/psr7-server": "^1.0",
"guzzlehttp/psr7": "^2",
"laminas/laminas-diactoros": "^3.2",
"php-di/php-di": "^7.0",
"selective/basepath": "^2.2"
}
}
Loading
Loading