Commit 2d98dab6 authored by deathstar's avatar deathstar

Initial commit

parents
# Контейнеры Docker для разворачивания окружения под сайт на 1С Битрикс
Контейнеры Docker для разворачивания окружения под сайт на 1С Битрикс ( Nginx + PHP-FPM 7.2 + MariaDB 10.3 + Memcached)
## Требования
Сервер с ОС CentOS 7 X64 и установленным на него docker
## Установка и запуск Docker
yum install epel-release
### Обновляем систему и ПО
yum update -y
yum upgrade -y
### Перезапускаем сервер
reboot
### Устанавливаем Docker и запускаем его
yum install -y mc nano wget git docker docker-compose && chkconfig docker on && service docker restart
## Скачивание , сборка и запуск контейнеров
cd ~
git clone https://gitlab.deathstar.name/deathstar/docker_for_bitrix.git
cd ~/docker_for_bitrix
mkdir ~/docker_for_bitrix/www
cd ~/docker_for_bitrix/www
wget https://www.1c-bitrix.ru/download/business_encode.tar.gz
tar -xvzf business_encode.tar.gz
chown -R 33:33 ../www ../tmp
### Запускаем контейнеры
cd ../
docker-compose up -d
### Проверяем работоспособность и настраиваем сайт на битриксе
Сайт доступен по ссылке http://IP_SERVER
phpMyAdmin доступен по ссылке http://IP_SERVER:8183
Данные к MySQL:
root /secret ( пароль прописывается в файле docker-compose.yml )
в качестве сервера подключения к БД указать mysql вместо localhost
\ No newline at end of file
# Версия docker-compose
version: '2'
# Список наших сервисов (контейнеров)
services:
nginx:
# используем последний стабильный образ nginx
image: nginx:latest
# маршрутизируем порты
ports:
- "80:80"
- "443:443"
# монтируем директории, слева директории на основной машине, справа - куда они монтируются в контейнере
volumes:
- ./hosts:/etc/nginx/conf.d
- ./www:/var/www
- ./logs:/var/log/nginx
# nginx должен общаться с php контейнером
links:
- php
- memcached
memcached:
image: memcached
ports:
- "11211:11211"
php:
# у нас свой образ для PHP, указываем путь к нему и говорим что его надо собрать
build: ./images/php
# этот образ будет общаться с mysql
links:
- mysql
# монтируем директорию с проектами
volumes:
- ./www:/var/www
- ./tmp:/tmp/
mysql:
image: mariadb
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
- ./my.cnf:/etc/mysql/my.cnf
# задаем пароль для root пользователя
environment:
MYSQL_ROOT_PASSWORD: secret
pma:
# используем последний стабильный образ phpmyadmin
image: phpmyadmin/phpmyadmin
restart: always
links:
- mysql:mysql
ports:
- 8183:80
environment:
# прописываем название нашего MySQL хоста
PMA_HOST: mysql
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: secret
server {
index index.php;
server_name bitrix.dev;
listen 80;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www;
# Enable Gzip
gzip on;
gzip_http_version 1.0;
gzip_comp_level 5;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
ext/css
ext/javascript
ext/xml
ext/plain
ext/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
client_max_body_size 20M;
proxy_connect_timeout 60000s;
proxy_send_timeout 60000s;
proxy_read_timeout 60000s;
fastcgi_send_timeout 60000s;
fastcgi_read_timeout 60000s;
location / {
try_files $uri $uri/ @bitrix;
}
location ~* /upload/.*\.(php|php3|php4|php5|php6|phtml|pl|asp|aspx|cgi|dll|exe|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp|rb|var)$ {
types {
text/plain text/plain php php3 php4 php5 php6 phtml pl asp aspx cgi dll exe ico shtm shtml fcg fcgi fpl asmx pht py psp rb var;
}
}
location ~ \.php$ {
try_files $uri @bitrix;
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;
}
location @bitrix {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
}
location ~* /bitrix/admin.+\.php$ {
try_files $uri @bitrixadm;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @bitrixadm{
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* /\.ht { deny all; }
location ~* /\.(svn|hg|git) { deny all; }
location ~* ^/bitrix/(modules|local_cache|stack_cache|managed_cache|php_interface) {
deny all;
}
location ~* ^/upload/1c_[^/]+/ { deny all; }
location ~* /\.\./ { deny all; }
location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
location ~* ^/bitrix/html_pages/\.enabled { deny all; }
location ^~ /upload/support/not_image { internal; }
location ~* @.*\.html$ {
internal;
expires -1y;
add_header X-Bitrix-Composite "Nginx (file)";
}
location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
add_header Access-Control-Allow-Origin *;
}
location ~* ^/bitrix/cache/(css/.+\.css|js/.+\.js)$ {
expires 30d;
error_page 404 /404.html;
}
location ~* ^/bitrix/cache { deny all; }
location ^~ /upload/bx_cloud_upload/ {
location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:]+)\.(s3|s3-us-west-1|s3-eu-west-1|s3-ap-southeast-1|s3-ap-northeast-1)\.amazonaws\.com/(.+)$ {
internal;
resolver 8.8.8.8;
proxy_method GET;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Server $host;
proxy_max_temp_file_size 0;
proxy_pass $1://$2.$3.amazonaws.com/$4;
}
location ~* .*$ { deny all; }
}
location ~* ^/(upload|bitrix/images|bitrix/tmp) {
expires 30d;
}
location ~* \.(css|js|gif|png|jpg|jpeg|ico|ogg|ttf|woff|eot|otf)$ {
error_page 404 /404.html;
expires 30d;
}
location = /404.html {
access_log off ;
}
}
# Для начала указываем исходный образ, он будет использован как основа
FROM php:7.1-fpm
# Необязательная строка с указанием автора образа
MAINTAINER PHPtoday.ru <info@phptoday.ru>
# RUN выполняет идущую за ней команду в контексте нашего образа.
# В данном случае мы установим некоторые зависимости и модули PHP.
# Для установки модулей используем команду docker-php-ext-install.
# На каждый RUN создается новый слой в образе, поэтому рекомендуется объединять команды.
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \
curl \
wget \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
libmemcached-dev \
libzip-dev \
ssmtp \
&& echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf \
&& echo 'sendmail_path = "/usr/sbin/ssmtp -t"' > /usr/local/etc/php/conf.d/mail.ini \
&& docker-php-ext-install -j$(nproc) mbstring mysqli pdo_mysql zip opcache \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& git clone https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached \
&& cd /usr/src/php/ext/memcached && git checkout -b php7 origin/php7 \
&& docker-php-ext-configure memcached \
&& docker-php-ext-install memcached \
&& git clone https://github.com/websupport-sk/pecl-memcache /usr/src/php/ext/memcache \
&& cd /usr/src/php/ext/memcache && git checkout -b php7 origin/php7 \
&& docker-php-ext-configure memcache \
&& docker-php-ext-install memcache
# Куда же без 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
ADD php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf
# Указываем рабочую директорию для PHP
WORKDIR /var/www
RUN chown -R 33:33 /var/www /tmp
# Запускаем контейнер
# Из документации: The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable,
# or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.
CMD ["php-fpm"]
This diff is collapsed.
# MariaDB database server configuration file.
#
# You can copy this file to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
#user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
default-time-zone='+03:00'
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
max_connections = 100
connect_timeout = 5
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover_options = BACKUP
key_buffer_size = 128M
#open-files-limit = 2000
table_open_cache = 400
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 1M
#
# * Query Cache Configuration
#
# Cache only tiny result sets, so we can fit more in the query cache.
query_cache_limit = 128K
query_cache_size = 64M
# for more write intensive setups, set to DEMAND or OFF
#query_cache_type = DEMAND
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# we do want to know about network errors and such
#log_warnings = 2
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log[={0|1}]
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit = 1000
#log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#log_slow_admin_statements
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#report_host = master1
#auto_increment_increment = 2
#auto_increment_offset = 1
#log_bin = /var/log/mysql/mariadb-bin
#log_bin_index = /var/log/mysql/mariadb-bin.index
# not fab for performance, but safer
#sync_binlog = 1
expire_logs_days = 10
max_binlog_size = 100M
# slaves
#relay_log = /var/log/mysql/relay-bin
#relay_log_index = /var/log/mysql/relay-bin.index
#relay_log_info_file = /var/log/mysql/relay-bin.info
#log_slave_updates
#read_only
#
# If applications support it, this stricter sql_mode prevents some
# mistakes like inserting invalid dates etc.
sql_mode = ''
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB
# you can't just change log file size, requires special procedure
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 2
transaction-isolation = READ-COMMITTED
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completion
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!include /etc/mysql/mariadb.cnf
!includedir /etc/mysql/conf.d/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment