├── data ├── .keepme └── mysql │ └── .keepme ├── logs ├── .keepme └── nginx │ └── .keepme ├── databases ├── .keepme ├── export │ └── .keepme └── import │ └── .keepme ├── sources └── .keepme ├── .root_dir ├── conf ├── nginx │ ├── ssl │ │ └── .keepme │ ├── conf.d │ │ └── .keepme │ └── nginx.conf ├── mysql │ └── conf.d │ │ ├── docker.cnf │ │ └── mysql.cnf ├── php │ ├── php70 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php71 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php72 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php73 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php74 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php82 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ ├── php74-c2 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini │ └── php81-c2 │ │ ├── 10-opcache.ini │ │ ├── magento.conf │ │ └── php.ini └── varnish │ └── default.vcl ├── scripts ├── list-services ├── shell ├── mysql ├── fixowner ├── setup-composer ├── ssl ├── xdebug ├── varnish ├── database ├── init-magento └── create-vhost ├── images ├── cert.png ├── cert02.png ├── cert03.png └── xdebug-phpstorm-01.png ├── .env ├── env-example ├── .gitignore ├── docker-compose.yml └── README.md /data/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /logs/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/mysql/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /databases/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /logs/nginx/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sources/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.root_dir: -------------------------------------------------------------------------------- 1 | Keep this file -------------------------------------------------------------------------------- /conf/nginx/ssl/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conf/nginx/conf.d/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /databases/export/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /databases/import/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conf/mysql/conf.d/docker.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | skip-host-cache 3 | skip-name-resolve -------------------------------------------------------------------------------- /scripts/list-services: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker-compose ps --services --filter "status=running" -------------------------------------------------------------------------------- /images/cert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/picassio/docker-magento-multiple-php/HEAD/images/cert.png -------------------------------------------------------------------------------- /images/cert02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/picassio/docker-magento-multiple-php/HEAD/images/cert02.png -------------------------------------------------------------------------------- /images/cert03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/picassio/docker-magento-multiple-php/HEAD/images/cert03.png -------------------------------------------------------------------------------- /images/xdebug-phpstorm-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/picassio/docker-magento-multiple-php/HEAD/images/xdebug-phpstorm-01.png -------------------------------------------------------------------------------- /scripts/shell: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z "$1" ]; then 3 | echo "Please specify a PHP container to go into (ex. php74). 4 | EG: ./scripts/shell php72" 5 | exit 1 6 | fi 7 | docker-compose exec --user nginx "$@" bash -------------------------------------------------------------------------------- /conf/php/php70/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php71/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php72/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php73/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php74/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php82/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | MYSQL_DATABASE=magento 2 | MYSQL_USER=admin 3 | # MySQL ENV 4 | MYSQL_PASSWORD=admin 5 | MYSQL_ROOT_PASSWORD=root 6 | #MYSQL_VERSION=5.7 7 | MYSQL_VERSION=8.0 8 | 9 | # RabbitMQ ENV 10 | RABBITMQ_ERLANG_COOKIE=RABBITMQ_ERLANG_COOKIE 11 | RABBITMQ_DEFAULT_USER=admin 12 | RABBITMQ_DEFAULT_PASS=admin 13 | 14 | # Elasticsearch env 15 | ELASTICSEARCH_VERSION=7.14.1 16 | -------------------------------------------------------------------------------- /conf/php/php74-c2/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /conf/php/php81-c2/10-opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache 2 | opcache.enable=0 3 | opcache.enable_cli=0 4 | opcache.memory_consumption=512 5 | opcache.interned_strings_buffer=8 6 | opcache.max_accelerated_files=60000 7 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 8 | opcache.huge_code_pages=0 9 | opcache.validate_timestamps=0 10 | opcache.consistency_checks=0 -------------------------------------------------------------------------------- /env-example: -------------------------------------------------------------------------------- 1 | MYSQL_DATABASE=magento 2 | MYSQL_USER=admin 3 | # MySQL ENV 4 | MYSQL_PASSWORD=admin 5 | MYSQL_ROOT_PASSWORD=root 6 | #MYSQL_VERSION=5.7 7 | MYSQL_VERSION=8.0 8 | 9 | # RabbitMQ ENV 10 | RABBITMQ_ERLANG_COOKIE=RABBITMQ_ERLANG_COOKIE 11 | RABBITMQ_DEFAULT_USER=admin 12 | RABBITMQ_DEFAULT_PASS=admin 13 | 14 | # Elasticsearch env 15 | ELASTICSEARCH_VERSION=7.14.1 16 | -------------------------------------------------------------------------------- /scripts/mysql: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | containerNameDB=$(docker inspect -f '{{.Name}}' $(docker-compose ps -q mysql) | cut -c2-) 4 | 5 | mysqRootPass=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_ROOT_PASSWORD) 6 | rootPass="${mysqRootPass/MYSQL_ROOT_PASSWORD=/$replace}" 7 | 8 | docker-compose exec mysql mysql -uroot -p${rootPass} -------------------------------------------------------------------------------- /scripts/fixowner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Fixing all source code folder file ownerships..." 3 | 4 | if [[ -f "$(pwd)/.root_dir" ]]; then 5 | echo "you maybe need to enter your user password to use sudo command to change file owner" 6 | sudo chown -R 1000:1000 $(pwd)/sources/* 7 | echo "Files ownerships fixed." 8 | exit 0 9 | else 10 | echo "Please change your current folder to docker-compose root folder (root folder is the folder contain docker-compose.yml file)." 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /sources/* 2 | !/sources/.keepme 3 | /conf/nginx/conf.d/* 4 | !/conf/nginx/conf.d/.keepme 5 | /conf/nginx/ssl/* 6 | !/conf/nginx/ssl/.keepme 7 | /logs/nginx/* 8 | !/logs/.keepme 9 | !/logs/nginx/.keepme 10 | /data/* 11 | !/data/.keepme 12 | !/data/mysql/.keepme 13 | /data/mysql/* 14 | /databases/* 15 | !/databases/.keepme 16 | /databases/import/* 17 | /databases/export/* 18 | !/databases/import 19 | !/databases/export 20 | !/databases/import/.keepme 21 | !/databases/export/.keepme 22 | .DS_Store 23 | gitInfo.md -------------------------------------------------------------------------------- /conf/php/php70/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php71/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php72/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php73/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php74/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php82/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php74-c2/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/php/php81-c2/magento.conf: -------------------------------------------------------------------------------- 1 | [magento] 2 | user = nginx 3 | group = nginx 4 | listen = 9001 5 | listen.owner = nginx 6 | listen.group = nginx 7 | pm = ondemand 8 | pm.max_children = 50 9 | pm.process_idle_timeout = 10s 10 | pm.max_requests = 500 11 | slowlog = /var/log/php-fpm/www-slow.log 12 | php_admin_value[error_log] = /var/log/php-fpm/www-error.log 13 | php_admin_flag[log_errors] = on 14 | php_value[session.save_handler] = files 15 | php_value[session.save_path] = /var/lib/php/session 16 | php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache -------------------------------------------------------------------------------- /conf/mysql/conf.d/mysql.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, 2021, Oracle and/or its affiliates. 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License, version 2.0, 5 | # as published by the Free Software Foundation. 6 | # 7 | # This program is also distributed with certain software (including 8 | # but not limited to OpenSSL) that is licensed under separate terms, 9 | # as designated in a particular file or component or in included license 10 | # documentation. The authors of MySQL hereby grant you an additional 11 | # permission to link the program and your derivative works with the 12 | # separately licensed software that they have included with MySQL. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License, version 2.0, for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | 23 | # 24 | # The MySQL Client configuration file. 25 | # 26 | # For explanations see 27 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 28 | 29 | [mysql] -------------------------------------------------------------------------------- /conf/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | # For more information on configuration, see: 2 | # * Official English Documentation: http://nginx.org/en/docs/ 3 | # * Official Russian Documentation: http://nginx.org/ru/docs/ 4 | 5 | user nginx nginx; 6 | worker_processes auto; 7 | error_log /var/log/nginx/error.log; 8 | pid /run/nginx.pid; 9 | 10 | # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 11 | include /usr/share/nginx/modules/*.conf; 12 | 13 | events { 14 | worker_connections 1024; 15 | } 16 | 17 | http { 18 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 19 | '$status $body_bytes_sent "$http_referer" ' 20 | '"$http_user_agent" "$http_x_forwarded_for"'; 21 | 22 | access_log /var/log/nginx/access.log main; 23 | client_max_body_size 2M; 24 | sendfile on; 25 | tcp_nopush on; 26 | tcp_nodelay on; 27 | keepalive_timeout 65; 28 | types_hash_max_size 4096; 29 | 30 | include /etc/nginx/mime.types; 31 | default_type application/octet-stream; 32 | 33 | # Load modular configuration files from the /etc/nginx/conf.d directory. 34 | # See http://nginx.org/en/docs/ngx_core_module.html#include 35 | # for more information. 36 | include /etc/nginx/conf.d/*.conf; 37 | 38 | server { 39 | listen 80; 40 | listen [::]:80; 41 | server_name _; 42 | root /usr/share/nginx/html; 43 | 44 | # Load configuration files for the default server block. 45 | include /etc/nginx/default.d/*.conf; 46 | 47 | error_page 404 /404.html; 48 | location = /40x.html { 49 | } 50 | 51 | error_page 500 502 503 504 /50x.html; 52 | location = /50x.html { 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /conf/php/php81-c2/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [mcrypt] 159 | extension=mcrypt.so 160 | [xdebug] 161 | ;zend_extension=xdebug 162 | zend_extension=xdebug 163 | xdebug.mode=debug 164 | xdebug.client_host = host.docker.internal 165 | xdebug.client_port = 9003 166 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php82/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | ;[mcrypt] 159 | ;extension=mcrypt.so 160 | ;[xdebug] 161 | ;zend_extension=xdebug 162 | zend_extension=xdebug 163 | xdebug.mode=debug 164 | xdebug.client_host = host.docker.internal 165 | xdebug.client_port = 9003 166 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php70/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [xdebug] 159 | ;zend_extension=xdebug.so 160 | xdebug.remote_host = host.docker.internal 161 | xdebug.remote_enable = 1 162 | xdebug.remote_port = 9000 163 | xdebug.remote_handler = dbgp 164 | xdebug.remote_mode = req 165 | xdebug.profiler_enable=0 166 | xdebug.profiler_enable_trigger=1 167 | xdebug.remote_autostart=1 168 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php71/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [xdebug] 159 | ;zend_extension=xdebug.so 160 | xdebug.remote_host = host.docker.internal 161 | xdebug.remote_enable = 1 162 | xdebug.remote_port = 9000 163 | xdebug.remote_handler = dbgp 164 | xdebug.remote_mode = req 165 | xdebug.profiler_enable=0 166 | xdebug.profiler_enable_trigger=1 167 | xdebug.remote_autostart=1 168 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php73/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [mcrypt] 159 | extension=mcrypt.so 160 | [xdebug] 161 | ;zend_extension=xdebug.so 162 | xdebug.remote_host = host.docker.internal 163 | xdebug.remote_enable = 1 164 | xdebug.remote_port = 9000 165 | xdebug.remote_handler = dbgp 166 | xdebug.remote_mode = req 167 | xdebug.profiler_enable=0 168 | xdebug.profiler_enable_trigger=1 169 | xdebug.remote_autostart=1 170 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php72/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [mcrypt] 159 | extension=mcrypt.so 160 | [xdebug] 161 | ;zend_extension=xdebug.so 162 | xdebug.remote_host = host.docker.internal 163 | xdebug.remote_enable = 1 164 | xdebug.remote_port = 9000 165 | xdebug.remote_handler = dbgp 166 | xdebug.remote_mode = req 167 | xdebug.profiler_enable=0 168 | xdebug.profiler_enable_trigger=1 169 | xdebug.remote_autostart=1 170 | xdebug.idekey=PHPSTORM 171 | -------------------------------------------------------------------------------- /conf/php/php74-c2/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [mcrypt] 159 | extension=mcrypt.so 160 | [xdebug] 161 | ;zend_extension=xdebug 162 | zend_extension=xdebug 163 | xdebug.remote_host = host.docker.internal 164 | xdebug.remote_enable = 1 165 | xdebug.remote_port = 9000 166 | xdebug.remote_handler = dbgp 167 | xdebug.remote_mode = req 168 | xdebug.profiler_enable=0 169 | xdebug.profiler_enable_trigger=1 170 | xdebug.remote_autostart=1 171 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /conf/php/php74/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | date.timezone = UTC 3 | engine = On 4 | short_open_tag = Off 5 | precision = 14 6 | output_buffering = 4096 7 | zlib.output_compression = Off 8 | implicit_flush = Off 9 | unserialize_callback_func = 10 | serialize_precision = -1 11 | disable_functions = 12 | disable_classes = 13 | realpath_cache_size=10M 14 | realpath_cache_ttl=7200 15 | zend.enable_gc = On 16 | expose_php = Off 17 | max_execution_time = 300 18 | max_input_vars = 10000 19 | max_input_time = 600 20 | memory_limit = -1 21 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 22 | display_errors = On 23 | display_startup_errors = Off 24 | log_errors = On 25 | log_errors_max_len = 1024 26 | ignore_repeated_errors = Off 27 | ignore_repeated_source = Off 28 | report_memleaks = On 29 | html_errors = On 30 | variables_order = "GPCS" 31 | request_order = "GP" 32 | register_argc_argv = Off 33 | auto_globals_jit = On 34 | post_max_size = 200M 35 | auto_prepend_file = 36 | auto_append_file = 37 | default_mimetype = "text/html" 38 | default_charset = "UTF-8" 39 | doc_root = 40 | user_dir = 41 | enable_dl = Off 42 | file_uploads = On 43 | upload_max_filesize = 200M 44 | max_file_uploads = 200 45 | allow_url_fopen = On 46 | allow_url_include = Off 47 | default_socket_timeout = 60 48 | [CLI Server] 49 | cli_server.color = On 50 | [Date] 51 | [filter] 52 | [iconv] 53 | [imap] 54 | [intl] 55 | [sqlite3] 56 | [Pcre] 57 | [Pdo] 58 | [Pdo_mysql] 59 | pdo_mysql.cache_size = 2000 60 | pdo_mysql.default_socket= 61 | [Phar] 62 | [mail function] 63 | SMTP = localhost 64 | smtp_port = 25 65 | mail.add_x_header = Off 66 | sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' 67 | [ODBC] 68 | odbc.allow_persistent = On 69 | odbc.check_persistent = On 70 | odbc.max_persistent = -1 71 | odbc.max_links = -1 72 | odbc.defaultlrl = 4096 73 | odbc.defaultbinmode = 1 74 | [Interbase] 75 | ibase.allow_persistent = 1 76 | ibase.max_persistent = -1 77 | ibase.max_links = -1 78 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 79 | ibase.dateformat = "%Y-%m-%d" 80 | ibase.timeformat = "%H:%M:%S" 81 | [MySQLi] 82 | mysqli.max_persistent = -1 83 | mysqli.allow_persistent = On 84 | mysqli.max_links = -1 85 | mysqli.cache_size = 2000 86 | mysqli.default_port = 3306 87 | mysqli.default_socket = 88 | mysqli.default_host = 89 | mysqli.default_user = 90 | mysqli.default_pw = 91 | mysqli.reconnect = Off 92 | [mysqlnd] 93 | mysqlnd.collect_statistics = On 94 | mysqlnd.collect_memory_statistics = Off 95 | [OCI8] 96 | [PostgreSQL] 97 | pgsql.allow_persistent = On 98 | pgsql.auto_reset_persistent = Off 99 | pgsql.max_persistent = -1 100 | pgsql.max_links = -1 101 | pgsql.ignore_notice = 0 102 | pgsql.log_notice = 0 103 | [bcmath] 104 | bcmath.scale = 0 105 | [browscap] 106 | [Session] 107 | session.save_handler = files 108 | session.save_path = /tmp 109 | session.use_strict_mode = 0 110 | session.use_cookies = 1 111 | session.use_only_cookies = 1 112 | session.name = PHPSESSID 113 | session.auto_start = 0 114 | session.cookie_lifetime = 0 115 | session.cookie_path = / 116 | session.cookie_domain = 117 | session.cookie_httponly = 118 | session.serialize_handler = php 119 | session.gc_probability = 0 120 | session.gc_divisor = 1000 121 | session.gc_maxlifetime = 1440 122 | session.referer_check = 123 | session.cache_limiter = nocache 124 | session.cache_expire = 180 125 | session.use_trans_sid = 0 126 | session.sid_length = 26 127 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 128 | session.sid_bits_per_character = 5 129 | [Assertion] 130 | zend.assertions = -1 131 | [COM] 132 | [mbstring] 133 | [gd] 134 | [exif] 135 | [Tidy] 136 | tidy.clean_output = Off 137 | [soap] 138 | soap.wsdl_cache_enabled=1 139 | soap.wsdl_cache_dir="/tmp" 140 | soap.wsdl_cache_ttl=86400 141 | soap.wsdl_cache_limit = 5 142 | [sysvshm] 143 | [ldap] 144 | ldap.max_links = -1 145 | [dba] 146 | [curl] 147 | [openssl] 148 | [opcache] 149 | opcache.enable=0 150 | opcache.enable_cli=0 151 | opcache.memory_consumption=512MB 152 | opcache.interned_strings_buffer=8 153 | opcache.max_accelerated_files=60000 154 | opcache.blacklist_filename=/etc/php.d/opcache*.blacklist 155 | opcache.huge_code_pages=1 156 | opcache.validate_timestamps=0 157 | opcache.consistency_checks=0 158 | [mcrypt] 159 | extension=mcrypt.so 160 | [xdebug] 161 | ;zend_extension=xdebug 162 | zend_extension=xdebug 163 | xdebug.remote_host = host.docker.internal 164 | xdebug.remote_enable = 1 165 | xdebug.remote_port = 9000 166 | xdebug.remote_handler = dbgp 167 | xdebug.remote_mode = req 168 | xdebug.profiler_enable=0 169 | xdebug.profiler_enable_trigger=1 170 | xdebug.remote_autostart=1 171 | xdebug.idekey=PHPSTORM -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | nginx: 3 | build: 4 | context: ./build/nginx 5 | image: nginx-mage:v1.0 6 | hostname: nginx 7 | volumes: 8 | - ./conf/nginx/conf.d:/etc/nginx/conf.d 9 | - ./conf/nginx/ssl:/etc/nginx/ssl 10 | - ./logs/nginx:/var/log/nginx 11 | - ./sources:/home/public_html 12 | - ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf 13 | ports: 14 | - 80:80 15 | - 443:443 16 | 17 | php70: 18 | build: 19 | context: ./build/php70 20 | image: php7.0-mage:v1.0 21 | hostname: php70 22 | extra_hosts: 23 | - "host.docker.internal:host-gateway" 24 | volumes: 25 | - ./sources:/home/public_html 26 | - composer_cache:/home/nginx/.composer 27 | - ./conf/php/php70/magento.conf:/etc/php/7.0/fpm/pool.d/www.conf 28 | - ./conf/php/php70/php.ini:/etc/php/7.0/fpm/php.ini 29 | - ./conf/php/php70/php.ini:/etc/php/7.0/cli/php.ini 30 | 31 | 32 | php71: 33 | build: 34 | context: ./build/php71 35 | image: php7.1-mage:v1.0 36 | hostname: php71 37 | extra_hosts: 38 | - "host.docker.internal:host-gateway" 39 | volumes: 40 | - ./sources:/home/public_html 41 | - composer_cache:/home/nginx/.composer 42 | - ./conf/php/php71/magento.conf:/etc/php/7.1/fpm/pool.d/www.conf 43 | - ./conf/php/php71/php.ini:/etc/php/7.1/fpm/php.ini 44 | - ./conf/php/php71/php.ini:/etc/php/7.1/cli/php.ini 45 | 46 | 47 | php72: 48 | build: 49 | context: ./build/php72 50 | image: php7.2-mage:v1.0 51 | hostname: php72 52 | extra_hosts: 53 | - "host.docker.internal:host-gateway" 54 | volumes: 55 | - ./sources:/home/public_html 56 | - composer_cache:/home/nginx/.composer 57 | - ./conf/php/php72/magento.conf:/etc/php/7.2/fpm/pool.d/www.conf 58 | - ./conf/php/php72/php.ini:/etc/php/7.2/fpm/php.ini 59 | - ./conf/php/php72/php.ini:/etc/php/7.2/cli/php.ini 60 | 61 | php73: 62 | build: 63 | context: ./build/php73 64 | image: php7.3-mage:v1.0 65 | hostname: php73 66 | extra_hosts: 67 | - "host.docker.internal:host-gateway" 68 | volumes: 69 | - ./sources:/home/public_html 70 | - composer_cache:/home/nginx/.composer 71 | - ./conf/php/php73/magento.conf:/etc/php/7.3/fpm/pool.d/www.conf 72 | - ./conf/php/php73/php.ini:/etc/php/7.3/fpm/php.ini 73 | - ./conf/php/php73/php.ini:/etc/php/7.3/cli/php.ini 74 | 75 | php74: 76 | build: 77 | context: ./build/php74 78 | image: php7.4-mage:v1.0 79 | hostname: php74 80 | extra_hosts: 81 | - "host.docker.internal:host-gateway" 82 | volumes: 83 | - ./sources:/home/public_html 84 | - composer_cache:/home/nginx/.composer 85 | - ./conf/php/php74/magento.conf:/etc/php/7.4/fpm/pool.d/www.conf 86 | - ./conf/php/php74/php.ini:/etc/php/7.4/fpm/php.ini 87 | - ./conf/php/php74/php.ini:/etc/php/7.4/cli/php.ini 88 | 89 | php74-c2: 90 | build: 91 | context: ./build/php74-c2 92 | image: php7.4-c2-mage:v1.0 93 | hostname: php74-c2 94 | extra_hosts: 95 | - "host.docker.internal:host-gateway" 96 | volumes: 97 | - ./sources:/home/public_html 98 | - composer_cache:/home/nginx/.composer 99 | - ./conf/php/php74-c2/magento.conf:/etc/php/7.4/fpm/pool.d/www.conf 100 | - ./conf/php/php74-c2/php.ini:/etc/php/7.4/fpm/php.ini 101 | - ./conf/php/php74-c2/php.ini:/etc/php/7.4/cli/php.ini 102 | 103 | php81-c2: 104 | build: 105 | context: ./build/php81-c2 106 | image: php8.1-c2-mage:v1.0 107 | hostname: php81-c2 108 | extra_hosts: 109 | - "host.docker.internal:host-gateway" 110 | volumes: 111 | - ./sources:/home/public_html 112 | - composer_cache:/home/nginx/.composer 113 | - ./conf/php/php81-c2/magento.conf:/etc/php/8.1/fpm/pool.d/www.conf 114 | - ./conf/php/php81-c2/php.ini:/etc/php/8.1/fpm/php.ini 115 | - ./conf/php/php81-c2/php.ini:/etc/php/8.1/cli/php.ini 116 | php82: 117 | build: 118 | context: ./build/php82 119 | image: php8.2-mage:v1.0 120 | hostname: php82 121 | extra_hosts: 122 | - "host.docker.internal:host-gateway" 123 | volumes: 124 | - ./sources:/home/public_html 125 | - composer_cache:/home/nginx/.composer 126 | - ./conf/php/php82/magento.conf:/etc/php/8.2/fpm/pool.d/www.conf 127 | - ./conf/php/php82/php.ini:/etc/php/8.2/fpm/php.ini 128 | - ./conf/php/php82/php.ini:/etc/php/8.2/cli/php.ini 129 | 130 | mysql: 131 | hostname: mysql 132 | image: mysql:${MYSQL_VERSION} 133 | command: --default-authentication-plugin=mysql_native_password 134 | environment: 135 | - MYSQL_DATABASE=${MYSQL_DATABASE} 136 | - MYSQL_USER=${MYSQL_USER} 137 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 138 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 139 | volumes: 140 | - ./data/mysql:/var/lib/mysql 141 | - ./conf/mysql/conf.d:/etc/mysql/conf.d 142 | ports: 143 | - 3308:3306 144 | 145 | mailhog: 146 | image: mailhog/mailhog 147 | ports: 148 | - 1025:1025 149 | - 8025:8025 150 | 151 | redis: 152 | image: "redis:6.0-alpine" 153 | ports: 154 | - "127.0.0.1:6379:6379" 155 | sysctls: 156 | - "net.core.somaxconn=65535" 157 | volumes: 158 | - "redis_data:/data" 159 | 160 | elasticsearch: 161 | build: 162 | context: ./build/elasticsearch 163 | args: 164 | ELASTICSEARCH_VERSION: ${ELASTICSEARCH_VERSION} 165 | image: elasticsearch-manual:${ELASTICSEARCH_VERSION} 166 | environment: 167 | - discovery.type=single-node 168 | - node.name=elasticseach 169 | - cluster.name=es-docker-cluster 170 | - bootstrap.memory_lock=true 171 | - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" 172 | ulimits: 173 | memlock: 174 | soft: -1 175 | hard: -1 176 | volumes: 177 | - elasticsearch-data:/usr/share/elasticsearch/data 178 | ports: 179 | - 9200:9200 180 | 181 | kibana: 182 | image: kibana:${ELASTICSEARCH_VERSION} 183 | environment: 184 | SERVER_NAME: kibana 185 | ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]' 186 | depends_on: 187 | - elasticsearch 188 | ports: 189 | - 5601:5601 190 | 191 | rabbitmq: 192 | image: rabbitmq:3-management-alpine 193 | volumes: 194 | - rabbitmq-data:/var/lib/rabbitmq/ 195 | environment: 196 | RABBITMQ_ERLANG_COOKIE: ${RABBITMQ_ERLANG_COOKIE} 197 | RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER} 198 | RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS} 199 | ports: 200 | - 5672:5672 201 | - 15672:15672 202 | phpmyadmin: 203 | image: phpmyadmin 204 | restart: always 205 | ports: 206 | - 8080:80 207 | environment: 208 | - PMA_ARBITRARY=1 209 | 210 | phpredmin: 211 | image: sasanrose/phpredmin 212 | environment: 213 | - PHPREDMIN_DATABASE_REDIS_0_HOST=redis 214 | ports: 215 | - "8081:80" 216 | depends_on: 217 | - redis 218 | 219 | varnish: 220 | build: 221 | context: ./build/varnish 222 | image: varnish-6.0:v1 223 | hostname: varnish 224 | ports: 225 | - 6081:6081 226 | depends_on: 227 | - nginx 228 | volumes: 229 | - ./conf/varnish/default.vcl:/etc/varnish/default.vcl 230 | 231 | volumes: 232 | composer_cache: 233 | composer_cache_file: 234 | elasticsearch-data: 235 | redis_data: 236 | rabbitmq-data: 237 | -------------------------------------------------------------------------------- /scripts/setup-composer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Script to create virtual host for Nginx server 5 | # 6 | 7 | # UnComment it if bash is lower than 4.x version 8 | shopt -s extglob 9 | 10 | ################################################################################ 11 | # CORE FUNCTIONS - Do not edit 12 | ################################################################################ 13 | 14 | ## Uncomment it for debugging purpose 15 | ###set -o errexit 16 | #set -o pipefail 17 | #set -o nounset 18 | #set -o xtrace 19 | 20 | # 21 | # VARIABLES 22 | # 23 | _bold=$(tput bold) 24 | _underline=$(tput sgr 0 1) 25 | _reset=$(tput sgr0) 26 | 27 | _purple=$(tput setaf 171) 28 | _red=$(tput setaf 1) 29 | _green=$(tput setaf 76) 30 | _tan=$(tput setaf 3) 31 | _blue=$(tput setaf 38) 32 | 33 | # 34 | # HEADERS & LOGGING 35 | # 36 | function _debug() 37 | { 38 | if [[ "$DEBUG" = 1 ]]; then 39 | "$@" 40 | fi 41 | } 42 | 43 | function _header() 44 | { 45 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 46 | } 47 | 48 | function _arrow() 49 | { 50 | printf '➜ %s\n' "$@" 51 | } 52 | 53 | function _success() 54 | { 55 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 56 | } 57 | 58 | function _error() { 59 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 60 | } 61 | 62 | function _warning() 63 | { 64 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 65 | } 66 | 67 | function _underline() 68 | { 69 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 70 | } 71 | 72 | function _bold() 73 | { 74 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 75 | } 76 | 77 | function _note() 78 | { 79 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 80 | } 81 | 82 | function _die() 83 | { 84 | _error "$@" 85 | exit 1 86 | } 87 | 88 | function _safeExit() 89 | { 90 | exit 0 91 | } 92 | 93 | # 94 | # UTILITY HELPER 95 | # 96 | function _seekConfirmation() 97 | { 98 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 99 | read -p " (y/n) " -n 1 100 | printf '\n' 101 | } 102 | 103 | # Test whether the result of an 'ask' is a confirmation 104 | function _isConfirmed() 105 | { 106 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 107 | return 0 108 | fi 109 | return 1 110 | } 111 | 112 | 113 | function _typeExists() 114 | { 115 | if type "$1" >/dev/null; then 116 | return 0 117 | fi 118 | return 1 119 | } 120 | 121 | function _isOs() 122 | { 123 | if [[ "${OSTYPE}" == $1* ]]; then 124 | return 0 125 | fi 126 | return 1 127 | } 128 | 129 | function _isOsDebian() 130 | { 131 | if [[ -f /etc/debian_version ]]; then 132 | return 0 133 | else 134 | return 1 135 | fi 136 | } 137 | 138 | function _isOsRedHat() 139 | { 140 | if [[ -f /etc/redhat-release ]]; then 141 | return 0 142 | else 143 | return 1 144 | fi 145 | } 146 | 147 | function _isOsMac() 148 | { 149 | if [[ "$(uname -s)" = "Darwin" ]]; then 150 | return 0 151 | else 152 | return 1 153 | fi 154 | } 155 | 156 | function _checkRootUser() 157 | { 158 | #if [ "$(id -u)" != "0" ]; then 159 | if [ "$(whoami)" != 'root' ]; then 160 | _die "You cannot run $0 as non-root user. Please use sudo $0" 161 | fi 162 | } 163 | 164 | function _printPoweredBy() 165 | { 166 | local mp_ascii 167 | mp_ascii=' 168 | ____ __ __ _ ____ _____ ___ ____ ____ 169 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 170 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 171 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 172 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 173 | 174 | ' 175 | cat </dev/null || _die "'${cmd}' command not found." 229 | done; 230 | } 231 | 232 | function processArgs() 233 | { 234 | for arg in "$@" 235 | do 236 | case $arg in 237 | --php-version=*) 238 | APP_PHP="${arg#*=}" 239 | ;; 240 | --debug) 241 | DEBUG=1 242 | set -o xtrace 243 | ;; 244 | -h|--help) 245 | _printUsage 246 | ;; 247 | *) 248 | _printUsage 249 | ;; 250 | esac 251 | done 252 | 253 | validateArgs 254 | } 255 | 256 | function validateArgs() 257 | { 258 | ERROR_COUNT=0 259 | if [[ -z "$APP_PHP" ]]; then 260 | _error "--php-version=... parameter is missing." 261 | ERROR_COUNT=$((ERROR_COUNT + 1)) 262 | fi 263 | if [[ ! -z "$APP_PHP" && "$APP_PHP" != @(php70|php71|php72|php73|php74|php74-c2) ]]; then 264 | _error "Please enter valid application php --php-version=... parameter(php70|php71|php72|php73|php74|php74-c2)." 265 | ERROR_COUNT=$((ERROR_COUNT + 1)) 266 | fi 267 | 268 | [[ "$ERROR_COUNT" -gt 0 ]] && exit 1 269 | } 270 | 271 | function validateBaseServices() 272 | { 273 | if [[ ! $($SCRIPTS_DIR/list-services | grep $APP_PHP) ]]; then 274 | _error "$APP_PHP service should be started, please start $APP_PHP" 275 | exit 1 276 | fi 277 | } 278 | 279 | function checkComposerAuth() 280 | { 281 | MAGENTO_USERNAME_PROP="http-basic.repo.magento.com.username" 282 | MAGENTO_PASSWORD_PROP="http-basic.repo.magento.com.password" 283 | 284 | PUBLIC_KEY="$(docker-compose exec -T --user nginx ${APP_PHP} composer config --global $MAGENTO_USERNAME_PROP 2>/dev/null)" 285 | PRIVATE_KEY="$(docker-compose exec -T --user nginx ${APP_PHP} composer config --global $MAGENTO_PASSWORD_PROP 2>/dev/null)" 286 | 287 | if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then 288 | exec < /dev/tty 289 | echo 290 | echo "Composer authentication required (repo.magento.com public and private keys):" 291 | read -r -p " Username: " PUBLIC_KEY 292 | read -r -p " Password: " PRIVATE_KEY 293 | echo 294 | exec <&- 295 | if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then 296 | _error "Please setup Composer auth for repo.magento.com to continue." 297 | fi 298 | _arrow "Configure magento repo auth" 299 | $(docker-compose exec -T --user nginx ${APP_PHP} composer config --global http-basic.repo.magento.com ${PUBLIC_KEY} ${PRIVATE_KEY}) || _die "Cannot configure magento auth" 300 | _success "Configure magento repo auth done" 301 | else 302 | _warning "Composer auth for Magento has already setup. No need to do anything" 303 | fi 304 | 305 | } 306 | 307 | ################################################################################ 308 | # Main 309 | ################################################################################ 310 | export LC_CTYPE=C 311 | export LANG=C 312 | 313 | DEBUG=0 314 | _debug set -x 315 | VERSION="1.2.0" 316 | 317 | function main() 318 | { 319 | checkCmdDependencies 320 | 321 | [[ $# -lt 1 ]] && _printUsage 322 | 323 | processArgs "$@" 324 | checkComposerAuth 325 | exit 0 326 | } 327 | 328 | main "$@" 329 | 330 | _debug set +x 331 | -------------------------------------------------------------------------------- /conf/varnish/default.vcl: -------------------------------------------------------------------------------- 1 | # VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6 2 | vcl 4.0; 3 | 4 | import std; 5 | # The minimal Varnish version is 6.0 6 | # For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https' 7 | 8 | backend default { 9 | .host = "nginx"; 10 | .port = "80"; 11 | .first_byte_timeout = 600s; 12 | # .probe = { 13 | # .url = "/pub/health_check.php"; 14 | # .timeout = 2s; 15 | # .interval = 5s; 16 | # .window = 10; 17 | # .threshold = 5; 18 | # } 19 | } 20 | 21 | acl purge { 22 | "0.0.0.0/0"; 23 | } 24 | 25 | sub vcl_recv { 26 | if (req.restarts > 0) { 27 | set req.hash_always_miss = true; 28 | } 29 | 30 | if (req.method == "PURGE") { 31 | if (client.ip !~ purge) { 32 | return (synth(405, "Method not allowed")); 33 | } 34 | # To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header 35 | # has been added to the response in your backend server config. This is used, for example, by the 36 | # capistrano-magento2 gem for purging old content from varnish during it's deploy routine. 37 | if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) { 38 | return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required")); 39 | } 40 | if (req.http.X-Magento-Tags-Pattern) { 41 | ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern); 42 | } 43 | if (req.http.X-Pool) { 44 | ban("obj.http.X-Pool ~ " + req.http.X-Pool); 45 | } 46 | return (synth(200, "Purged")); 47 | } 48 | 49 | if (req.method != "GET" && 50 | req.method != "HEAD" && 51 | req.method != "PUT" && 52 | req.method != "POST" && 53 | req.method != "TRACE" && 54 | req.method != "OPTIONS" && 55 | req.method != "DELETE") { 56 | /* Non-RFC2616 or CONNECT which is weird. */ 57 | return (pipe); 58 | } 59 | 60 | # We only deal with GET and HEAD by default 61 | if (req.method != "GET" && req.method != "HEAD") { 62 | return (pass); 63 | } 64 | 65 | # Bypass customer, shopping cart, checkout 66 | if (req.url ~ "/customer" || req.url ~ "/checkout") { 67 | return (pass); 68 | } 69 | 70 | # Bypass health check requests 71 | if (req.url ~ "^/(pub/)?(health_check.php)$") { 72 | return (pass); 73 | } 74 | 75 | # Set initial grace period usage status 76 | set req.http.grace = "none"; 77 | 78 | # normalize url in case of leading HTTP scheme and domain 79 | set req.url = regsub(req.url, "^http[s]?://", ""); 80 | 81 | # collect all cookies 82 | std.collect(req.http.Cookie); 83 | 84 | # Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression 85 | if (req.http.Accept-Encoding) { 86 | if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { 87 | # No point in compressing these 88 | unset req.http.Accept-Encoding; 89 | } elsif (req.http.Accept-Encoding ~ "gzip") { 90 | set req.http.Accept-Encoding = "gzip"; 91 | } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") { 92 | set req.http.Accept-Encoding = "deflate"; 93 | } else { 94 | # unknown algorithm 95 | unset req.http.Accept-Encoding; 96 | } 97 | } 98 | 99 | # Remove all marketing get parameters to minimize the cache objects 100 | if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") { 101 | set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", ""); 102 | set req.url = regsub(req.url, "[?|&]+$", ""); 103 | } 104 | 105 | # Static files caching 106 | if (req.url ~ "^/(pub/)?(media|static)/") { 107 | # Static files should not be cached by default 108 | return (pass); 109 | 110 | # But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines 111 | #unset req.http.Https; 112 | #unset req.http.X-Forwarded-Proto; 113 | #unset req.http.Cookie; 114 | } 115 | 116 | # Authenticated GraphQL requests should not be cached by default 117 | if (req.url ~ "/graphql" && req.http.Authorization ~ "^Bearer") { 118 | return (pass); 119 | } 120 | 121 | return (hash); 122 | } 123 | 124 | sub vcl_hash { 125 | if (req.http.cookie ~ "X-Magento-Vary=") { 126 | hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1")); 127 | } 128 | 129 | # To make sure http users don't see ssl warning 130 | if (req.http.X-Forwarded-Proto) { 131 | hash_data(req.http.X-Forwarded-Proto); 132 | } 133 | 134 | 135 | if (req.url ~ "/graphql") { 136 | call process_graphql_headers; 137 | } 138 | } 139 | 140 | sub process_graphql_headers { 141 | if (req.http.Store) { 142 | hash_data(req.http.Store); 143 | } 144 | if (req.http.Content-Currency) { 145 | hash_data(req.http.Content-Currency); 146 | } 147 | } 148 | 149 | sub vcl_backend_response { 150 | 151 | set beresp.grace = 3d; 152 | 153 | if (beresp.http.content-type ~ "text") { 154 | set beresp.do_esi = true; 155 | } 156 | 157 | if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") { 158 | set beresp.do_gzip = true; 159 | } 160 | 161 | if (beresp.http.X-Magento-Debug) { 162 | set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control; 163 | } 164 | 165 | # cache only successfully responses and 404s 166 | if (beresp.status != 200 && beresp.status != 404) { 167 | set beresp.ttl = 0s; 168 | set beresp.uncacheable = true; 169 | return (deliver); 170 | } elsif (beresp.http.Cache-Control ~ "private") { 171 | set beresp.uncacheable = true; 172 | set beresp.ttl = 86400s; 173 | return (deliver); 174 | } 175 | 176 | # validate if we need to cache it and prevent from setting cookie 177 | if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) { 178 | unset beresp.http.set-cookie; 179 | } 180 | 181 | # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass 182 | if (beresp.ttl <= 0s || 183 | beresp.http.Surrogate-control ~ "no-store" || 184 | (!beresp.http.Surrogate-Control && 185 | beresp.http.Cache-Control ~ "no-cache|no-store") || 186 | beresp.http.Vary == "*") { 187 | # Mark as Hit-For-Pass for the next 2 minutes 188 | set beresp.ttl = 120s; 189 | set beresp.uncacheable = true; 190 | } 191 | 192 | return (deliver); 193 | } 194 | 195 | sub vcl_deliver { 196 | if (obj.hits > 0) { 197 | set resp.http.X-Cache = "HIT"; 198 | set resp.http.X-Cache-Hits = obj.hits; 199 | } 200 | else { 201 | set resp.http.X-Cache = "MISS"; 202 | } 203 | 204 | 205 | if (resp.http.X-Magento-Debug) { 206 | if (resp.http.x-varnish ~ " ") { 207 | set resp.http.X-Magento-Cache-Debug = "HIT"; 208 | set resp.http.Grace = req.http.grace; 209 | } else { 210 | set resp.http.X-Magento-Cache-Debug = "MISS"; 211 | } 212 | } else { 213 | unset resp.http.Age; 214 | } 215 | 216 | # Not letting browser to cache non-static files. 217 | if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") { 218 | set resp.http.Pragma = "no-cache"; 219 | set resp.http.Expires = "-1"; 220 | set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; 221 | } 222 | 223 | unset resp.http.X-Magento-Debug; 224 | unset resp.http.X-Magento-Tags; 225 | unset resp.http.X-Powered-By; 226 | unset resp.http.Server; 227 | unset resp.http.X-Varnish; 228 | unset resp.http.Via; 229 | unset resp.http.Link; 230 | } 231 | 232 | sub vcl_hit { 233 | if (obj.ttl >= 0s) { 234 | # Hit within TTL period 235 | return (deliver); 236 | } 237 | if (std.healthy(req.backend_hint)) { 238 | if (obj.ttl + 300s > 0s) { 239 | # Hit after TTL expiration, but within grace period 240 | set req.http.grace = "normal (healthy server)"; 241 | return (deliver); 242 | } else { 243 | # Hit after TTL and grace expiration 244 | return (restart); 245 | } 246 | } else { 247 | # server is not healthy, retrieve from cache 248 | set req.http.grace = "unlimited (unhealthy server)"; 249 | return (deliver); 250 | } 251 | } -------------------------------------------------------------------------------- /scripts/ssl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Script to create virtual host for Nginx server 4 | # 5 | 6 | # UnComment it if bash is lower than 4.x version 7 | shopt -s extglob 8 | 9 | ################################################################################ 10 | # CORE FUNCTIONS - Do not edit 11 | ################################################################################ 12 | 13 | ## Uncomment it for debugging purpose 14 | ###set -o errexit 15 | #set -o pipefail 16 | #set -o nounset 17 | #set -o xtrace 18 | 19 | # 20 | # VARIABLES 21 | # 22 | _bold=$(tput bold) 23 | _underline=$(tput sgr 0 1) 24 | _reset=$(tput sgr0) 25 | 26 | _purple=$(tput setaf 171) 27 | _red=$(tput setaf 1) 28 | _green=$(tput setaf 76) 29 | _tan=$(tput setaf 3) 30 | _blue=$(tput setaf 38) 31 | 32 | # 33 | # HEADERS & LOGGING 34 | # 35 | function _debug() 36 | { 37 | if [[ "$DEBUG" = 1 ]]; then 38 | "$@" 39 | fi 40 | } 41 | 42 | function _header() 43 | { 44 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 45 | } 46 | 47 | function _arrow() 48 | { 49 | printf '➜ %s\n' "$@" 50 | } 51 | 52 | function _success() 53 | { 54 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 55 | } 56 | 57 | function _error() { 58 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 59 | } 60 | 61 | function _warning() 62 | { 63 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 64 | } 65 | 66 | function _underline() 67 | { 68 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 69 | } 70 | 71 | function _bold() 72 | { 73 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 74 | } 75 | 76 | function _note() 77 | { 78 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 79 | } 80 | 81 | function _die() 82 | { 83 | _error "$@" 84 | exit 1 85 | } 86 | 87 | function _safeExit() 88 | { 89 | exit 0 90 | } 91 | 92 | # 93 | # UTILITY HELPER 94 | # 95 | function _seekConfirmation() 96 | { 97 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 98 | read -p " (y/n) " -n 1 99 | printf '\n' 100 | } 101 | 102 | # Test whether the result of an 'ask' is a confirmation 103 | function _isConfirmed() 104 | { 105 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 106 | return 0 107 | fi 108 | return 1 109 | } 110 | 111 | 112 | function _typeExists() 113 | { 114 | if type "$1" >/dev/null; then 115 | return 0 116 | fi 117 | return 1 118 | } 119 | 120 | function _isOs() 121 | { 122 | if [[ "${OSTYPE}" == $1* ]]; then 123 | return 0 124 | fi 125 | return 1 126 | } 127 | 128 | function _isOsDebian() 129 | { 130 | if [[ -f /etc/debian_version ]]; then 131 | return 0 132 | else 133 | return 1 134 | fi 135 | } 136 | 137 | function _isOsRedHat() 138 | { 139 | if [[ -f /etc/redhat-release ]]; then 140 | return 0 141 | else 142 | return 1 143 | fi 144 | } 145 | 146 | function _isOsMac() 147 | { 148 | if [[ "$(uname -s)" = "Darwin" ]]; then 149 | return 0 150 | else 151 | return 1 152 | fi 153 | } 154 | 155 | function _checkRootUser() 156 | { 157 | #if [ "$(id -u)" != "0" ]; then 158 | if [ "$(whoami)" != 'root' ]; then 159 | _die "You cannot run $0 as non-root user. Please use sudo $0" 160 | fi 161 | } 162 | 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | 178 | function _printPoweredBy() 179 | { 180 | local mp_ascii 181 | mp_ascii=' 182 | ____ __ __ _ ____ _____ ___ ____ ____ 183 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 184 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 185 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 186 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 187 | 188 | ' 189 | cat </dev/null || _die "'${cmd}' command not found." 242 | done; 243 | } 244 | 245 | function processArgs() 246 | { 247 | for arg in "$@" 248 | do 249 | case $arg in 250 | --domain=*) 251 | VHOST_DOMAIN="${arg#*=}" 252 | ;; 253 | --debug) 254 | DEBUG=1 255 | set -o xtrace 256 | ;; 257 | -h|--help) 258 | _printUsage 259 | ;; 260 | *) 261 | _printUsage 262 | ;; 263 | esac 264 | done 265 | 266 | validateArgs 267 | sanitizeArgs 268 | } 269 | 270 | function validateArgs() 271 | { 272 | ERROR_COUNT=0 273 | if [[ -z "$VHOST_DOMAIN" ]]; then 274 | _error "--domain=... parameter is missing." 275 | ERROR_COUNT=$((ERROR_COUNT + 1)) 276 | fi 277 | 278 | [[ "$ERROR_COUNT" -gt 0 ]] && exit 1 279 | } 280 | 281 | function sanitizeArgs() 282 | { 283 | if [[ ! -z "$VHOST_DOMAIN" ]] && [[ "$VHOST_DOMAIN" == http* ]]; then 284 | VHOST_DOMAIN=$(getPureDomain) 285 | fi 286 | } 287 | 288 | function initDefaultArgs() 289 | { 290 | SSL_DIR="$(pwd)/conf/nginx/ssl" 291 | 292 | YES_STRING=$"y" 293 | NO_STRING=$"n" 294 | YES_NO_PROMPT=$"[y/n]: " 295 | YES_CAPS=$(echo ${YES_STRING}|tr [:lower:] [:upper:]) 296 | NO_CAPS=$(echo ${NO_STRING}|tr [:lower:] [:upper:]) 297 | DATABASE_NAME="magento"_"$(date +%s)" 298 | 299 | NGINX_SITES_CONF_D="$(pwd)/conf/nginx/conf.d" 300 | NGINX_SITES_CONF_D_SSL_FILE="${NGINX_SITES_CONF_D}/${VHOST_DOMAIN}-ssl.conf" 301 | } 302 | 303 | function command_exists () 304 | { 305 | type "$1" &> /dev/null 306 | } 307 | 308 | function checkSslCommand() 309 | { 310 | if ! command_exists mkcert; then 311 | _error "Missing mkcert command" 312 | _warning "You need to install mkcert with this command below if you are using Ubuntu:" 313 | echo -n " sudo apt-get install libnss3-tools -y 314 | sudo wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 -O /usr/local/bin/mkcert 315 | sudo chmod +x /usr/local/bin/mkcert 316 | mkcert -install 317 | " 318 | exit 1 319 | fi 320 | } 321 | 322 | function createCertificate() 323 | { 324 | _arrow "Create $VHOST_DOMAIN certificate" 325 | mkcert -key-file $VHOST_DOMAIN.key -cert-file $VHOST_DOMAIN.crt $VHOST_DOMAIN || _die "Cannot create certificate" 326 | _arrow "Moving certificate to the right folder" 327 | mv $VHOST_DOMAIN.key $VHOST_DOMAIN.crt ${SSL_DIR}/ 328 | _success "$VHOST_DOMAIN certificate created" 329 | } 330 | 331 | function checkDomainExist () 332 | { 333 | if [[ -f ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN.conf ]]; then 334 | _success "Domain exists" 335 | else 336 | _error "Domain not exist, Did you set it up on docker-compose system?" 337 | exit 1 338 | fi 339 | } 340 | 341 | function prepareSslVhostContent() 342 | { 343 | echo "server { 344 | server_name ${VHOST_DOMAIN}; 345 | 346 | listen 443 ssl; 347 | 348 | ssl_certificate /etc/nginx/ssl/$VHOST_DOMAIN.crt; 349 | ssl_certificate_key /etc/nginx/ssl/$VHOST_DOMAIN.key; 350 | 351 | client_max_body_size 100M; 352 | location / { 353 | proxy_pass http://127.0.0.1:80; 354 | proxy_set_header Host \$http_host; 355 | proxy_set_header X-Forwarded-Host \$http_host; 356 | proxy_set_header X-Real-IP \$remote_addr; 357 | proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; 358 | proxy_set_header Ssl-Offloaded "1"; 359 | proxy_set_header X-Forwarded-Proto https; 360 | proxy_set_header X-Forwarded-Port 443; 361 | 362 | proxy_buffer_size 128k; 363 | proxy_buffers 4 256k; 364 | proxy_busy_buffers_size 256k; 365 | 366 | proxy_read_timeout 600; 367 | proxy_connect_timeout 600; 368 | proxy_send_timeout 600; 369 | } 370 | 371 | error_page 404 /404.html; 372 | location = /40x.html { 373 | } 374 | 375 | error_page 500 502 503 504 /50x.html; 376 | location = /50x.html { 377 | } 378 | }" > "$NGINX_SITES_CONF_D_SSL_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_SSL_FILE}" 379 | 380 | _arrow "${NGINX_SITES_CONF_D_SSL_FILE} file has been created." 381 | } 382 | 383 | 384 | function reloadNginx() 385 | { 386 | local _nginxTest=$(docker-compose exec nginx nginx -t) 387 | if [[ $? -eq 0 ]]; then 388 | docker-compose exec nginx nginx -s reload || _die "Nginx couldn't be reloaded." 389 | else 390 | echo "$_nginxTest" 391 | fi 392 | } 393 | 394 | function printSuccessMessage() 395 | { 396 | _success "Virtual host for Nginx has been successfully created!" 397 | 398 | echo "################################################################" 399 | echo "" 400 | echo " >> Domain : ${VHOST_DOMAIN}" 401 | echo " >> Nginx Config File : ${NGINX_SITES_CONF_D_SSL_FILE}" 402 | echo "" 403 | echo "################################################################" 404 | 405 | } 406 | 407 | ################################################################################ 408 | # Main 409 | ################################################################################ 410 | export LC_CTYPE=C 411 | export LANG=C 412 | 413 | DEBUG=0 414 | _debug set -x 415 | VERSION="1.2.0" 416 | 417 | function main() 418 | { 419 | # _checkRootUser 420 | checkCmdDependencies 421 | checkSslCommand 422 | 423 | [[ $# -lt 1 ]] && _printUsage 424 | 425 | processArgs "$@" 426 | initDefaultArgs 427 | 428 | checkDomainExist 429 | createCertificate 430 | prepareSslVhostContent 431 | reloadNginx 432 | 433 | printSuccessMessage 434 | exit 0 435 | } 436 | 437 | main "$@" 438 | 439 | _debug set +x -------------------------------------------------------------------------------- /scripts/xdebug: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Script to create virtual host for Nginx server 4 | # 5 | 6 | # UnComment it if bash is lower than 4.x version 7 | shopt -s extglob 8 | 9 | ################################################################################ 10 | # CORE FUNCTIONS - Do not edit 11 | ################################################################################ 12 | 13 | ## Uncomment it for debugging purpose 14 | ###set -o errexit 15 | #set -o pipefail 16 | #set -o nounset 17 | #set -o xtrace 18 | 19 | # 20 | # VARIABLES 21 | # 22 | _bold=$(tput bold) 23 | _underline=$(tput sgr 0 1) 24 | _reset=$(tput sgr0) 25 | 26 | _purple=$(tput setaf 171) 27 | _red=$(tput setaf 1) 28 | _green=$(tput setaf 76) 29 | _tan=$(tput setaf 3) 30 | _blue=$(tput setaf 38) 31 | 32 | # 33 | # HEADERS & LOGGING 34 | # 35 | function _debug() 36 | { 37 | if [[ "$DEBUG" = 1 ]]; then 38 | "$@" 39 | fi 40 | } 41 | 42 | function _header() 43 | { 44 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 45 | } 46 | 47 | function _arrow() 48 | { 49 | printf '➜ %s\n' "$@" 50 | } 51 | 52 | function _success() 53 | { 54 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 55 | } 56 | 57 | function _error() { 58 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 59 | } 60 | 61 | function _warning() 62 | { 63 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 64 | } 65 | 66 | function _underline() 67 | { 68 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 69 | } 70 | 71 | function _bold() 72 | { 73 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 74 | } 75 | 76 | function _note() 77 | { 78 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 79 | } 80 | 81 | function _die() 82 | { 83 | _error "$@" 84 | exit 1 85 | } 86 | 87 | function _safeExit() 88 | { 89 | exit 0 90 | } 91 | 92 | # 93 | # UTILITY HELPER 94 | # 95 | function _seekConfirmation() 96 | { 97 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 98 | read -p " (y/n) " -n 1 99 | printf '\n' 100 | } 101 | 102 | # Test whether the result of an 'ask' is a confirmation 103 | function _isConfirmed() 104 | { 105 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 106 | return 0 107 | fi 108 | return 1 109 | } 110 | 111 | 112 | function _typeExists() 113 | { 114 | if type "$1" >/dev/null; then 115 | return 0 116 | fi 117 | return 1 118 | } 119 | 120 | function _isOs() 121 | { 122 | if [[ "${OSTYPE}" == $1* ]]; then 123 | return 0 124 | fi 125 | return 1 126 | } 127 | 128 | function _isOsDebian() 129 | { 130 | if [[ -f /etc/debian_version ]]; then 131 | return 0 132 | else 133 | return 1 134 | fi 135 | } 136 | 137 | function _isOsRedHat() 138 | { 139 | if [[ -f /etc/redhat-release ]]; then 140 | return 0 141 | else 142 | return 1 143 | fi 144 | } 145 | 146 | function _isOsMac() 147 | { 148 | if [[ "$(uname -s)" = "Darwin" ]]; then 149 | return 0 150 | else 151 | return 1 152 | fi 153 | } 154 | 155 | function _checkRootUser() 156 | { 157 | #if [ "$(id -u)" != "0" ]; then 158 | if [ "$(whoami)" != 'root' ]; then 159 | _die "You cannot run $0 as non-root user. Please use sudo $0" 160 | fi 161 | } 162 | 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | 178 | function _printPoweredBy() 179 | { 180 | local mp_ascii 181 | mp_ascii=' 182 | ____ __ __ _ ____ _____ ___ ____ ____ 183 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 184 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 185 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 186 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 187 | 188 | ' 189 | cat </dev/null || _die "'${cmd}' command not found." 248 | done; 249 | } 250 | 251 | function processArgs() 252 | { 253 | # Parse Arguments 254 | 255 | case $1 in 256 | enable) 257 | COMMAND="$1" 258 | for arg in "${@:2}" 259 | do 260 | case $arg in 261 | --php-version=*) 262 | APP_PHP="${arg#*=}" 263 | ;; 264 | -h|--help) 265 | _printUsage 266 | ;; 267 | *) 268 | _printUsage 269 | ;; 270 | esac 271 | done 272 | ;; 273 | disable) 274 | COMMAND="$1" 275 | for arg in "${@:2}" 276 | do 277 | case $arg in 278 | --php-version=*) 279 | APP_PHP="${arg#*=}" 280 | ;; 281 | -h|--help) 282 | _printUsage 283 | ;; 284 | *) 285 | _printUsage 286 | ;; 287 | esac 288 | done 289 | ;; 290 | status) 291 | COMMAND="$1" 292 | for arg in "${@:2}" 293 | do 294 | case $arg in 295 | --php-version=*) 296 | APP_PHP="${arg#*=}" 297 | ;; 298 | -h|--help) 299 | _printUsage 300 | ;; 301 | *) 302 | _printUsage 303 | ;; 304 | esac 305 | done 306 | ;; 307 | -h|--help) 308 | _printUsage 309 | ;; 310 | *) 311 | _printUsage 312 | ;; 313 | esac 314 | 315 | validateArgs 316 | } 317 | 318 | function initDefaultArgs() 319 | { 320 | YES_STRING=$"y" 321 | NO_STRING=$"n" 322 | YES_NO_PROMPT=$"[y/n]: " 323 | YES_CAPS=$(echo ${YES_STRING}|tr [:lower:] [:upper:]) 324 | NO_CAPS=$(echo ${NO_STRING}|tr [:lower:] [:upper:]) 325 | 326 | PHP_INI_LOCATION="$(pwd)/conf/php/${APP_PHP}/php.ini" 327 | 328 | XDEBUG_STATUS= 329 | } 330 | 331 | function validateArgs() 332 | { 333 | ERROR_COUNT=0 334 | if [[ -z "$APP_PHP" ]]; then 335 | _error "--php-version=... parameter is missing." 336 | ERROR_COUNT=$((ERROR_COUNT + 1)) 337 | fi 338 | if [[ ! -z "$APP_PHP" && "$APP_PHP" != @(php70|php71|php72|php73|php74|php74-c2|php81-c2) ]]; then 339 | _error "Please enter valid application php --php-version=... parameter(php70|php71|php72|php73|php74|php74-c2|php81-c2)." 340 | ERROR_COUNT=$((ERROR_COUNT + 1)) 341 | fi 342 | 343 | [[ "$ERROR_COUNT" -gt 0 ]] && exit 1 344 | } 345 | 346 | function restartPhpContainer() 347 | { 348 | _arrow "Reload container ${APP_PHP}" 349 | docker-compose restart ${APP_PHP} || _die "${APP_PHP} cannot reload." 350 | _success "Container ${APP_PHP} reloaded." 351 | } 352 | 353 | function enableXdebug() 354 | { 355 | statusXdebug 356 | if [[ $XDEBUG_STATUS == 1 ]]; then 357 | _warning "Xdebug enabled, no need to do anything" && exit 1 358 | fi 359 | _arrow "Enable Xdebug for ${APP_PHP}" 360 | 361 | sed -i 's/;zend_extension=xdebug/zend_extension=xdebug/g' $PHP_INI_LOCATION || _die "Cannot change Xdebug setting" 362 | 363 | _success "Xdebug enabled" 364 | restartPhpContainer 365 | } 366 | 367 | function disableXdebug() 368 | { 369 | statusXdebug 370 | if [[ $XDEBUG_STATUS == 0 ]]; then 371 | _warning "Xdebug disabled, no need to do anything" && exit 1 372 | fi 373 | _arrow "Disable Xdebug for ${APP_PHP}" 374 | 375 | sed -i 's/zend_extension=xdebug/;zend_extension=xdebug/g' $PHP_INI_LOCATION || _die "Cannot change Xdebug setting" 376 | 377 | _success "Xdebug disabled" 378 | restartPhpContainer 379 | } 380 | 381 | function checkPhpContainerRunning() 382 | { 383 | _arrow "Check ${APP_PHP} is running?" 384 | if [[ $($(pwd)/scripts/list-services | grep ${APP_PHP}) ]]; then 385 | _success "${APP_PHP} is running" 386 | else 387 | _error "${APP_PHP} is not running" && exit 1 388 | fi 389 | } 390 | 391 | function statusXdebug() 392 | { 393 | _arrow "Check Xdebug status for ${APP_PHP}" 394 | if [[ $(docker-compose exec ${APP_PHP} php -i | grep xdebug) ]]; then 395 | _success "${APP_PHP}: Xdebug enabled" 396 | XDEBUG_STATUS=1 397 | else 398 | _warning "${APP_PHP}: Xdebug disabled" 399 | XDEBUG_STATUS=0 400 | fi 401 | } 402 | 403 | function doAction() 404 | { 405 | case $COMMAND in 406 | enable) 407 | enableXdebug 408 | ;; 409 | disable) 410 | disableXdebug 411 | ;; 412 | status) 413 | statusXdebug 414 | ;; 415 | esac 416 | } 417 | 418 | function printSuccessMessage() 419 | { 420 | _success "Your Action has done!" 421 | } 422 | 423 | ################################################################################ 424 | # Main 425 | ################################################################################ 426 | export LC_CTYPE=C 427 | export LANG=C 428 | 429 | DEBUG=0 430 | _debug set -x 431 | VERSION="1" 432 | 433 | function main() 434 | { 435 | # _checkRootUser 436 | checkCmdDependencies 437 | 438 | 439 | [[ $# -lt 1 ]] && _printUsage 440 | 441 | processArgs "$@" 442 | 443 | initDefaultArgs 444 | checkPhpContainerRunning 445 | 446 | doAction 447 | printSuccessMessage 448 | exit 0 449 | } 450 | 451 | main "$@" 452 | 453 | _debug set +x -------------------------------------------------------------------------------- /scripts/varnish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Script to create virtual host for Nginx server 4 | # 5 | 6 | # UnComment it if bash is lower than 4.x version 7 | shopt -s extglob 8 | 9 | ################################################################################ 10 | # CORE FUNCTIONS - Do not edit 11 | ################################################################################ 12 | 13 | ## Uncomment it for debugging purpose 14 | ###set -o errexit 15 | #set -o pipefail 16 | #set -o nounset 17 | #set -o xtrace 18 | 19 | # 20 | # VARIABLES 21 | # 22 | _bold=$(tput bold) 23 | _underline=$(tput sgr 0 1) 24 | _reset=$(tput sgr0) 25 | 26 | _purple=$(tput setaf 171) 27 | _red=$(tput setaf 1) 28 | _green=$(tput setaf 76) 29 | _tan=$(tput setaf 3) 30 | _blue=$(tput setaf 38) 31 | 32 | # 33 | # HEADERS & LOGGING 34 | # 35 | function _debug() 36 | { 37 | if [[ "$DEBUG" = 1 ]]; then 38 | "$@" 39 | fi 40 | } 41 | 42 | function _header() 43 | { 44 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 45 | } 46 | 47 | function _arrow() 48 | { 49 | printf '➜ %s\n' "$@" 50 | } 51 | 52 | function _success() 53 | { 54 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 55 | } 56 | 57 | function _error() { 58 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 59 | } 60 | 61 | function _warning() 62 | { 63 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 64 | } 65 | 66 | function _underline() 67 | { 68 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 69 | } 70 | 71 | function _bold() 72 | { 73 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 74 | } 75 | 76 | function _note() 77 | { 78 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 79 | } 80 | 81 | function _die() 82 | { 83 | _error "$@" 84 | exit 1 85 | } 86 | 87 | function _safeExit() 88 | { 89 | exit 0 90 | } 91 | 92 | # 93 | # UTILITY HELPER 94 | # 95 | function _seekConfirmation() 96 | { 97 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 98 | read -p " (y/n) " -n 1 99 | printf '\n' 100 | } 101 | 102 | # Test whether the result of an 'ask' is a confirmation 103 | function _isConfirmed() 104 | { 105 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 106 | return 0 107 | fi 108 | return 1 109 | } 110 | 111 | 112 | function _typeExists() 113 | { 114 | if type "$1" >/dev/null; then 115 | return 0 116 | fi 117 | return 1 118 | } 119 | 120 | function _isOs() 121 | { 122 | if [[ "${OSTYPE}" == $1* ]]; then 123 | return 0 124 | fi 125 | return 1 126 | } 127 | 128 | function _isOsDebian() 129 | { 130 | if [[ -f /etc/debian_version ]]; then 131 | return 0 132 | else 133 | return 1 134 | fi 135 | } 136 | 137 | function _isOsRedHat() 138 | { 139 | if [[ -f /etc/redhat-release ]]; then 140 | return 0 141 | else 142 | return 1 143 | fi 144 | } 145 | 146 | function _isOsMac() 147 | { 148 | if [[ "$(uname -s)" = "Darwin" ]]; then 149 | return 0 150 | else 151 | return 1 152 | fi 153 | } 154 | 155 | function _checkRootUser() 156 | { 157 | #if [ "$(id -u)" != "0" ]; then 158 | if [ "$(whoami)" != 'root' ]; then 159 | _die "You cannot run $0 as non-root user. Please use sudo $0" 160 | fi 161 | } 162 | 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | 178 | function _printPoweredBy() 179 | { 180 | local mp_ascii 181 | mp_ascii=' 182 | ____ __ __ _ ____ _____ ___ ____ ____ 183 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 184 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 185 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 186 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 187 | 188 | ' 189 | cat </dev/null || _die "'${cmd}' command not found." 250 | done; 251 | } 252 | 253 | function processArgs() 254 | { 255 | # Parse Arguments 256 | 257 | case $1 in 258 | enable) 259 | COMMAND="$1" 260 | for arg in "${@:2}" 261 | do 262 | case $arg in 263 | --domain=*) 264 | VHOST_DOMAIN="${arg#*=}" 265 | ;; 266 | -h|--help) 267 | _printUsage 268 | ;; 269 | *) 270 | _printUsage 271 | ;; 272 | esac 273 | done 274 | ;; 275 | disable) 276 | COMMAND="$1" 277 | for arg in "${@:2}" 278 | do 279 | case $arg in 280 | --domain=*) 281 | VHOST_DOMAIN="${arg#*=}" 282 | ;; 283 | -h|--help) 284 | _printUsage 285 | ;; 286 | *) 287 | _printUsage 288 | ;; 289 | esac 290 | done 291 | ;; 292 | status) 293 | COMMAND="$1" 294 | for arg in "${@:2}" 295 | do 296 | case $arg in 297 | --domain=*) 298 | VHOST_DOMAIN="${arg#*=}" 299 | ;; 300 | -h|--help) 301 | _printUsage 302 | ;; 303 | *) 304 | _printUsage 305 | ;; 306 | esac 307 | done 308 | ;; 309 | -h|--help) 310 | _printUsage 311 | ;; 312 | *) 313 | _printUsage 314 | ;; 315 | esac 316 | 317 | validateArgs 318 | } 319 | 320 | function initDefaultArgs() 321 | { 322 | YES_STRING=$"y" 323 | NO_STRING=$"n" 324 | YES_NO_PROMPT=$"[y/n]: " 325 | YES_CAPS=$(echo ${YES_STRING}|tr [:lower:] [:upper:]) 326 | NO_CAPS=$(echo ${NO_STRING}|tr [:lower:] [:upper:]) 327 | 328 | PHP_INI_LOCATION="$(pwd)/conf/php/${APP_PHP}/php.ini" 329 | 330 | NGINX_SITES_CONF_D="$(pwd)/conf/nginx/conf.d" 331 | FPC_STATUS= 332 | NGINX_VARNISH_STATUS= 333 | } 334 | 335 | function validateArgs() 336 | { 337 | ERROR_COUNT=0 338 | if [[ -z "$VHOST_DOMAIN" ]]; then 339 | _error "--domain=... parameter is missing." 340 | ERROR_COUNT=$((ERROR_COUNT + 1)) 341 | fi 342 | 343 | [[ "$ERROR_COUNT" -gt 0 ]] && exit 1 344 | } 345 | 346 | 347 | function checkDomainExist () 348 | { 349 | if [[ -f ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN.conf ]]; then 350 | _success "Domain exists" 351 | else 352 | _error "Domain not exist, Did you set it up on docker-compose system?" 353 | exit 1 354 | fi 355 | } 356 | 357 | function checkDomainSslExist () 358 | { 359 | if [[ -f ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN-ssl.conf ]]; then 360 | _success "Domain SSL exists" 361 | else 362 | _error "Domain SSL not exist, Did you enable SSL for this domain?" 363 | exit 1 364 | fi 365 | } 366 | 367 | function checkNginxContainerRunning() 368 | { 369 | _arrow "Check Nginx container is running?" 370 | if [[ $($(pwd)/scripts/list-services | grep nginx) ]]; then 371 | _success "Nginx container is running" 372 | else 373 | _error "Nginx container is not running, please start it!" && exit 1 374 | fi 375 | } 376 | 377 | function checkMysqlContainerRunning() 378 | { 379 | _arrow "Check Mysql container is running?" 380 | if [[ $($(pwd)/scripts/list-services | grep mysql) ]]; then 381 | _success "Mysql container is running" 382 | else 383 | _error "Mysql container is not running, please start it!" && exit 1 384 | fi 385 | } 386 | 387 | function checkPhpContainerRunning() 388 | { 389 | _arrow "Check Nginx container is running?" 390 | if [[ $($(pwd)/scripts/list-services | grep $DOMAIN_PHP_VERSION) ]]; then 391 | _success "PHP $DOMAIN_PHP_VERSION container is running" 392 | else 393 | _error "PHP $DOMAIN_PHP_VERSION container is not running, please start it!" && exit 1 394 | fi 395 | } 396 | 397 | function getDomainDocroot() 398 | { 399 | _arrow "Get Vhost $VHOST_DOMAIN docroot" 400 | DOC_ROOT=$(cat ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN.conf | grep "/home/public_html/" | grep -v "fastcgi_param" | awk '{print $3}' | awk -F/ '{print $4}' | awk -F\; '{print $1}') || _die "Cannot get Vhost $VHOST_DOMAIN docroot" 401 | _success "Get Vhost $VHOST_DOMAIN successfuly" 402 | } 403 | 404 | function getDomainPhpVersion() 405 | { 406 | _arrow "Get $VHOST_DOMAIN php version" 407 | DOMAIN_PHP_VERSION=$(cat ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN.conf | grep 9001 | awk 'NR==1{print $2}' | awk -F\: '{print $1}') 408 | _success "Get $VHOST_DOMAIN successfuly" 409 | } 410 | 411 | function checkDomainMagentoFullPageCacheStatus() 412 | { 413 | FPC_STATUS=$(docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento config:show system/full_page_cache/caching_application 2>&1) 414 | # Remove /r 415 | FPC_STATUS=${FPC_STATUS%$'\r'} 416 | if [[ "$FPC_STATUS" == "2" ]]; then 417 | _success "Your $VHOST_DOMAIN Magento is configured Varnish as default Full page cache" 418 | else 419 | _error "Domain $VHOST_DOMAIN do not use Varnish as default Full page cache" 420 | fi 421 | } 422 | 423 | function checkNginxSSLVhostVarnishProxyPass() 424 | { 425 | if [[ -n $(cat ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN-ssl.conf | grep 'proxy_pass http://varnish:6081') ]]; then 426 | _success "Your Nginx SSL $VHOST_DOMAIN is configured proxy pass to Varnish backend" 427 | NGINX_VARNISH_STATUS=1 428 | else 429 | _error "Your Nginx SSL $VHOST_DOMAIN is not configured proxy pass to Varnish backend" 430 | NGINX_VARNISH_STATUS=0 431 | fi 432 | } 433 | 434 | function enableVarnish() 435 | { 436 | 437 | checkDomainMagentoFullPageCacheStatus 438 | if [[ "$FPC_STATUS" != "2" ]]; then 439 | _arrow "Configuring Varnish as default full page cache for $VHOST_DOMAIN" 440 | docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento config:set system/full_page_cache/caching_application 2 || _die "Configure Varnish as default full page cache for $VHOST_DOMAIN failed" 441 | _arrow "Configure $VHOST_DOMAIN Magento env.php with varnish config" 442 | docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento setup:config:set --http-cache-hosts=varnish:6081 || _die "Cannot configure $VHOST_DOMAIN Magento env.php with varnish config" 443 | _success "Configure Varnish as default full page cache for $VHOST_DOMAIN successful" 444 | _arrow "Flush $VHOST_DOMAIN Magento cache" 445 | docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento cache:flush || _die "Cannot flush $VHOST_DOMAIN Magento cache" 446 | _success "Flush $VHOST_DOMAIN Magento cache successful" 447 | fi 448 | 449 | checkNginxSSLVhostVarnishProxyPass 450 | if [[ $NGINX_VARNISH_STATUS -eq 0 ]]; then 451 | _arrow "Enable varnish for domain $VHOST_DOMAIN" 452 | sed -i 's/proxy_pass http:\/\/127.0.0.1:80;/proxy_pass http:\/\/varnish:6081;/g' ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN-ssl.conf || _die "Cannot enable Varnish on Nginx configure file" 453 | reloadNginx 454 | fi 455 | 456 | _success "Enable varnish for domain $VHOST_DOMAIN successfuly, you need to change your Magento base_url to use https if you did not change yet" 457 | } 458 | 459 | function disableVarnish() 460 | { 461 | checkDomainMagentoFullPageCacheStatus 462 | if [[ "$FPC_STATUS" == "2" ]]; then 463 | _arrow "Disable Varnish as default full page cache, Enable Build-in cache for $VHOST_DOMAIN" 464 | docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento config:set system/full_page_cache/caching_application 1 || _die "Cannot disable Varnish as default full page cache, Enable Build-in cache for $VHOST_DOMAIN" 465 | _arrow "Disable Varnish as default full page cache, Enable Build-in cache for $VHOST_DOMAIN successful" 466 | _arrow "You need to manual remove varnish config line on your $VHOST_DOMAIN Magento env.php" 467 | _arrow "Flush $VHOST_DOMAIN Magento cache" 468 | docker-compose exec --user nginx $DOMAIN_PHP_VERSION php /home/public_html/$DOC_ROOT/bin/magento cache:flush || _die "Cannot flush $VHOST_DOMAIN Magento cache" 469 | _success "Flush $VHOST_DOMAIN Magento cache successful" 470 | fi 471 | 472 | checkNginxSSLVhostVarnishProxyPass 473 | if [[ $NGINX_VARNISH_STATUS -eq 1 ]]; then 474 | _arrow "Disable varnish for domain $VHOST_DOMAIN" 475 | sed -i 's/proxy_pass http:\/\/varnish:6081;/proxy_pass http:\/\/127.0.0.1:80;/g' ${NGINX_SITES_CONF_D}/$VHOST_DOMAIN-ssl.conf || _die "Cannot disable Varnish on Nginx configure file" 476 | reloadNginx 477 | fi 478 | 479 | _success "Disable varnish for domain $VHOST_DOMAIN successfuly" 480 | } 481 | 482 | function statusVarnish() 483 | { 484 | _arrow "Get Varnish status for domain $VHOST_DOMAIN" 485 | checkDomainMagentoFullPageCacheStatus 486 | checkNginxSSLVhostVarnishProxyPass 487 | } 488 | 489 | function reloadNginx() 490 | { 491 | local _nginxTest=$(docker-compose exec nginx nginx -t) 492 | _arrow "Reload nginx" 493 | if [[ $? -eq 0 ]]; then 494 | docker-compose exec nginx nginx -s reload || _die "Nginx couldn't be reloaded." 495 | _success "Nginx reloaded" 496 | else 497 | echo "$_nginxTest" 498 | fi 499 | } 500 | 501 | function doAction() 502 | { 503 | case $COMMAND in 504 | enable) 505 | enableVarnish 506 | ;; 507 | disable) 508 | disableVarnish 509 | ;; 510 | status) 511 | statusVarnish 512 | ;; 513 | esac 514 | } 515 | 516 | function printSuccessMessage() 517 | { 518 | _success "Your Action has done!" 519 | } 520 | 521 | ################################################################################ 522 | # Main 523 | ################################################################################ 524 | export LC_CTYPE=C 525 | export LANG=C 526 | 527 | DEBUG=0 528 | _debug set -x 529 | VERSION="1" 530 | 531 | function main() 532 | { 533 | # _checkRootUser 534 | checkCmdDependencies 535 | 536 | 537 | [[ $# -lt 1 ]] && _printUsage 538 | 539 | processArgs "$@" 540 | 541 | initDefaultArgs 542 | checkNginxContainerRunning 543 | checkDomainExist 544 | checkDomainSslExist 545 | getDomainDocroot 546 | getDomainPhpVersion 547 | checkPhpContainerRunning 548 | checkMysqlContainerRunning 549 | 550 | doAction 551 | printSuccessMessage 552 | exit 0 553 | } 554 | 555 | main "$@" 556 | 557 | _debug set +x -------------------------------------------------------------------------------- /scripts/database: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Script to create virtual host for Nginx server 4 | # 5 | 6 | # UnComment it if bash is lower than 4.x version 7 | shopt -s extglob 8 | 9 | ################################################################################ 10 | # CORE FUNCTIONS - Do not edit 11 | ################################################################################ 12 | 13 | ## Uncomment it for debugging purpose 14 | ###set -o errexit 15 | #set -o pipefail 16 | #set -o nounset 17 | #set -o xtrace 18 | 19 | # 20 | # VARIABLES 21 | # 22 | _bold=$(tput bold) 23 | _underline=$(tput sgr 0 1) 24 | _reset=$(tput sgr0) 25 | 26 | _purple=$(tput setaf 171) 27 | _red=$(tput setaf 1) 28 | _green=$(tput setaf 76) 29 | _tan=$(tput setaf 3) 30 | _blue=$(tput setaf 38) 31 | 32 | # 33 | # HEADERS & LOGGING 34 | # 35 | function _debug() 36 | { 37 | if [[ "$DEBUG" = 1 ]]; then 38 | "$@" 39 | fi 40 | } 41 | 42 | function _header() 43 | { 44 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 45 | } 46 | 47 | function _arrow() 48 | { 49 | printf '➜ %s\n' "$@" 50 | } 51 | 52 | function _success() 53 | { 54 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 55 | } 56 | 57 | function _error() { 58 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 59 | } 60 | 61 | function _warning() 62 | { 63 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 64 | } 65 | 66 | function _underline() 67 | { 68 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 69 | } 70 | 71 | function _bold() 72 | { 73 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 74 | } 75 | 76 | function _note() 77 | { 78 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 79 | } 80 | 81 | function _die() 82 | { 83 | _error "$@" 84 | exit 1 85 | } 86 | 87 | function _safeExit() 88 | { 89 | exit 0 90 | } 91 | 92 | # 93 | # UTILITY HELPER 94 | # 95 | function _seekConfirmation() 96 | { 97 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 98 | read -p " (y/n) " -n 1 99 | printf '\n' 100 | } 101 | 102 | # Test whether the result of an 'ask' is a confirmation 103 | function _isConfirmed() 104 | { 105 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 106 | return 0 107 | fi 108 | return 1 109 | } 110 | 111 | 112 | function _typeExists() 113 | { 114 | if type "$1" >/dev/null; then 115 | return 0 116 | fi 117 | return 1 118 | } 119 | 120 | function _isOs() 121 | { 122 | if [[ "${OSTYPE}" == $1* ]]; then 123 | return 0 124 | fi 125 | return 1 126 | } 127 | 128 | function _isOsDebian() 129 | { 130 | if [[ -f /etc/debian_version ]]; then 131 | return 0 132 | else 133 | return 1 134 | fi 135 | } 136 | 137 | function _isOsRedHat() 138 | { 139 | if [[ -f /etc/redhat-release ]]; then 140 | return 0 141 | else 142 | return 1 143 | fi 144 | } 145 | 146 | function _isOsMac() 147 | { 148 | if [[ "$(uname -s)" = "Darwin" ]]; then 149 | return 0 150 | else 151 | return 1 152 | fi 153 | } 154 | 155 | function _checkRootUser() 156 | { 157 | #if [ "$(id -u)" != "0" ]; then 158 | if [ "$(whoami)" != 'root' ]; then 159 | _die "You cannot run $0 as non-root user. Please use sudo $0" 160 | fi 161 | } 162 | 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | 178 | function _printPoweredBy() 179 | { 180 | local mp_ascii 181 | mp_ascii=' 182 | ____ __ __ _ ____ _____ ___ ____ ____ 183 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 184 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 185 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 186 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 187 | 188 | ' 189 | cat </dev/null || _die "'${cmd}' command not found." 420 | done; 421 | } 422 | 423 | function getMysqlInformation() 424 | { 425 | containerNameDB=$(docker inspect -f '{{.Name}}' $(docker-compose ps -q mysql) | cut -c2-) 426 | 427 | mysqlUser=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_USER) 428 | user="${mysqlUser/MYSQL_USER=/$replace}" 429 | 430 | mysqlPass=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_PASSWORD) 431 | pass="${mysqlPass/MYSQL_PASSWORD=/$replace}" 432 | 433 | mysqRootPass=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_ROOT_PASSWORD) 434 | rootPass="${mysqRootPass/MYSQL_ROOT_PASSWORD=/$replace}" 435 | } 436 | 437 | function checkDatabaseFileName() 438 | { 439 | if [[ $(echo ${DATABASE_IMPORT_SOURCE_NAME} | awk -F\. '{print $NF}') != "sql" ]]; then 440 | _error "Database source file name extension invalid, must be end .sql. EG: abc.sql" 441 | exit 1 442 | elif [[ -f ${IMPORT_DIR}/${DATABASE_IMPORT_SOURCE_NAME} ]]; then 443 | _success "Database source file exists" 444 | else 445 | _error "Database source file not exists" 446 | exit 1 447 | fi 448 | } 449 | 450 | 451 | function checkMysqlContainerRunning() 452 | { 453 | 454 | _arrow "Check Mysql container is running?" 455 | if [[ $($(pwd)/scripts/list-services | grep mysql) ]]; then 456 | _success "Mysql container is running" 457 | else 458 | _error "Mysql container is not running, please start it!" && exit 1 459 | fi 460 | } 461 | 462 | function checkDatabaseName() 463 | { 464 | if [[ ${DATABASE_NAME} =~ $DATABASE_PATTERN ]]; then 465 | _success "Good database name" 466 | else 467 | _error "Invalid Database name, please choose other name!!" 468 | exit 1 469 | fi 470 | } 471 | 472 | function listMysqlDatabase() 473 | { 474 | docker-compose exec mysql mysql -u root --password=${rootPass} -e "show databases" 2>&1 | grep -v "Using a password" 475 | } 476 | 477 | function exportMysqlDatabase() 478 | { 479 | _arrow "Check database exist" 480 | if [[ $(docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "show databases like '${DATABASE_NAME}'" 2>&1 | grep -v "Using a password" | grep -o "${DATABASE_NAME}") == ${DATABASE_NAME} ]]; then 481 | _success "Database existed" 482 | _arrow "Export database" 483 | docker-compose exec -T mysql /usr/bin/mysqldump -u root --password=${rootPass} 2>&1 | grep -v "Using a password" > ${DES_DIR}/${DATABASE_NAME}-${BACKDATE}.sql 484 | _success "Your database exported" 485 | echo " >> Export file location: ${DES_DIR}/${DATABASE_NAME}-${BACKDATE}.sql" 486 | else 487 | _error "Database ${DATABASE_NAME} not exists. Please check!!" 488 | exit 1 489 | fi 490 | 491 | } 492 | 493 | function importMysqlDatabase() 494 | { 495 | _arrow "Check database source" 496 | checkDatabaseFileName 497 | _arrow "Check database ${DATABASE_IMPORT_TARGET_NAME} exist?" 498 | if [[ $(docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "show databases like '${DATABASE_NAME}'" 2>&1 | grep -v "Using a password" | grep -o "${DATABASE_NAME}") == ${DATABASE_NAME} ]] 499 | then 500 | _success "Database existed" 501 | _arrow "Import database" 502 | docker-compose exec -T mysql mysql -u root -p${rootPass} ${DATABASE_IMPORT_TARGET_NAME} < ${IMPORT_DIR}/${DATABASE_IMPORT_SOURCE_NAME} 2>&1 | grep -v "Using a password" 503 | _success "Database name ${DATABASE_IMPORT_TARGET_NAME} imported" 504 | else 505 | _error "Database ${DATABASE_IMPORT_TARGET_NAME} not exists. Please create it!!" 506 | exit 1 507 | fi 508 | 509 | } 510 | 511 | function createMysqlDatabase() 512 | { 513 | _arrow "Check database name" 514 | checkDatabaseName 515 | _arrow "Check database ${DATABASE_NAME} exist?" 516 | if [[ $(docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "show databases like '${DATABASE_NAME}'" 2>&1 | grep -v "Using a password" | grep -o "${DATABASE_NAME}") == ${DATABASE_NAME} ]] 517 | then 518 | _error "Database existed, please choose other name!" 519 | exit 1 520 | else 521 | _arrow "Database name avaiable, create database ${DATABASE_NAME}" 522 | docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "create database ${DATABASE_NAME}" 2>&1 | grep -v "Using a password" 523 | _success "Database name ${DATABASE_NAME} created" 524 | listMysqlDatabase 525 | fi 526 | } 527 | 528 | function dropMysqlDatabase() 529 | { 530 | _arrow "Check database name" 531 | checkDatabaseName 532 | _arrow "Check database ${DATABASE_NAME} exist?" 533 | if [[ $(docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "show databases like '${DATABASE_NAME}'" 2>&1 | grep -v "Using a password" | grep -o "${DATABASE_NAME}") == ${DATABASE_NAME} ]] 534 | then 535 | _success "Database existed" 536 | else 537 | _error "Database name not exists!" 538 | exit 1 539 | fi 540 | if askYesOrNo $"Are you sure, bro?" 541 | then 542 | _arrow "drop database!" 543 | docker-compose exec mysql mysql -u root -p${rootPass} --skip-column-names -e "drop database ${DATABASE_NAME}" 2>&1 | grep -v "Using a password" 544 | _success "Database name ${DATABASE_NAME} dropped" 545 | listMysqlDatabase 546 | else 547 | exit 1 548 | fi 549 | } 550 | 551 | function printSuccessMessage() 552 | { 553 | _success "Your Action has done!" 554 | } 555 | 556 | function doAction() 557 | { 558 | case $COMMAND in 559 | create) 560 | createMysqlDatabase 561 | ;; 562 | import) 563 | importMysqlDatabase 564 | ;; 565 | export) 566 | exportMysqlDatabase 567 | ;; 568 | drop) 569 | dropMysqlDatabase 570 | ;; 571 | list) 572 | listMysqlDatabase 573 | ;; 574 | esac 575 | } 576 | 577 | ################################################################################ 578 | # Main 579 | ################################################################################ 580 | export LC_CTYPE=C 581 | export LANG=C 582 | 583 | DEBUG=0 584 | _debug set -x 585 | VERSION="1" 586 | 587 | function main() 588 | { 589 | # _checkRootUser 590 | checkCmdDependencies 591 | 592 | 593 | [[ $# -lt 1 ]] && _printUsage 594 | initDefaultArgs 595 | processArgs "$@" 596 | 597 | checkMysqlContainerRunning 598 | 599 | getMysqlInformation 600 | 601 | doAction 602 | printSuccessMessage 603 | exit 0 604 | } 605 | 606 | main "$@" 607 | 608 | _debug set +x -------------------------------------------------------------------------------- /scripts/init-magento: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Script to create virtual host for Nginx server 4 | # 5 | 6 | # UnComment it if bash is lower than 4.x version 7 | shopt -s extglob 8 | 9 | ################################################################################ 10 | # CORE FUNCTIONS - Do not edit 11 | ################################################################################ 12 | 13 | ## Uncomment it for debugging purpose 14 | ###set -o errexit 15 | #set -o pipefail 16 | #set -o nounset 17 | #set -o xtrace 18 | 19 | # 20 | # VARIABLES 21 | # 22 | _bold=$(tput bold) 23 | _underline=$(tput sgr 0 1) 24 | _reset=$(tput sgr0) 25 | 26 | _purple=$(tput setaf 171) 27 | _red=$(tput setaf 1) 28 | _green=$(tput setaf 76) 29 | _tan=$(tput setaf 3) 30 | _blue=$(tput setaf 38) 31 | 32 | # 33 | # HEADERS & LOGGING 34 | # 35 | function _debug() 36 | { 37 | if [[ "$DEBUG" = 1 ]]; then 38 | "$@" 39 | fi 40 | } 41 | 42 | function _header() 43 | { 44 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 45 | } 46 | 47 | function _arrow() 48 | { 49 | printf '➜ %s\n' "$@" 50 | } 51 | 52 | function _success() 53 | { 54 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 55 | } 56 | 57 | function _error() { 58 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 59 | } 60 | 61 | function _warning() 62 | { 63 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 64 | } 65 | 66 | function _underline() 67 | { 68 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 69 | } 70 | 71 | function _bold() 72 | { 73 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 74 | } 75 | 76 | function _note() 77 | { 78 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 79 | } 80 | 81 | function _die() 82 | { 83 | _error "$@" 84 | exit 1 85 | } 86 | 87 | function _safeExit() 88 | { 89 | exit 0 90 | } 91 | 92 | # 93 | # UTILITY HELPER 94 | # 95 | function _seekConfirmation() 96 | { 97 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 98 | read -p " (y/n) " -n 1 99 | printf '\n' 100 | } 101 | 102 | # Test whether the result of an 'ask' is a confirmation 103 | function _isConfirmed() 104 | { 105 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 106 | return 0 107 | fi 108 | return 1 109 | } 110 | 111 | 112 | function _typeExists() 113 | { 114 | if type "$1" >/dev/null; then 115 | return 0 116 | fi 117 | return 1 118 | } 119 | 120 | function _isOs() 121 | { 122 | if [[ "${OSTYPE}" == $1* ]]; then 123 | return 0 124 | fi 125 | return 1 126 | } 127 | 128 | function _isOsDebian() 129 | { 130 | if [[ -f /etc/debian_version ]]; then 131 | return 0 132 | else 133 | return 1 134 | fi 135 | } 136 | 137 | function _isOsRedHat() 138 | { 139 | if [[ -f /etc/redhat-release ]]; then 140 | return 0 141 | else 142 | return 1 143 | fi 144 | } 145 | 146 | function _isOsMac() 147 | { 148 | if [[ "$(uname -s)" = "Darwin" ]]; then 149 | return 0 150 | else 151 | return 1 152 | fi 153 | } 154 | 155 | function _checkRootUser() 156 | { 157 | #if [ "$(id -u)" != "0" ]; then 158 | if [ "$(whoami)" != 'root' ]; then 159 | _die "You cannot run $0 as non-root user. Please use sudo $0" 160 | fi 161 | } 162 | 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | 178 | function _printPoweredBy() 179 | { 180 | local mp_ascii 181 | mp_ascii=' 182 | ____ __ __ _ ____ _____ ___ ____ ____ 183 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 184 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 185 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 186 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 187 | 188 | ' 189 | cat </dev/null || _die "'${cmd}' command not found." 245 | done; 246 | } 247 | 248 | function processArgs() 249 | { 250 | for arg in "$@" 251 | do 252 | case $arg in 253 | --domain=*) 254 | VHOST_DOMAIN="${arg#*=}" 255 | ;; 256 | --magento-version=*) 257 | MAGENTO_VERSION="${arg#*=}" 258 | ;; 259 | --magento-edition=*) 260 | MAGENTO_EDITION="${arg#*=}" 261 | ;; 262 | --php-version=*) 263 | APP_PHP="${arg#*=}" 264 | ;; 265 | --debug) 266 | DEBUG=1 267 | set -o xtrace 268 | ;; 269 | -h|--help) 270 | _printUsage 271 | ;; 272 | *) 273 | _printUsage 274 | ;; 275 | esac 276 | done 277 | 278 | validateArgs 279 | sanitizeArgs 280 | } 281 | 282 | function initDefaultArgs() 283 | { 284 | IMPORT_DIR="$(pwd)/databases/import" 285 | SCRIPTS_DIR="$(pwd)/scripts" 286 | DES_DIR="$(pwd)/databases/export" 287 | TODAY="$(date +"%Y-%m-%d")" 288 | BACKDATE="$(date +"%Y-%m-%d")" 289 | DATABASE_PATTERN="^([[:alnum:]]([[:alnum:]_]{0,61}[[:alnum:]]))$" 290 | SOURCE_DIR="$(pwd)/sources" 291 | 292 | YES_STRING=$"y" 293 | NO_STRING=$"n" 294 | YES_NO_PROMPT=$"[y/n]: " 295 | YES_CAPS=$(echo ${YES_STRING}|tr [:lower:] [:upper:]) 296 | NO_CAPS=$(echo ${NO_STRING}|tr [:lower:] [:upper:]) 297 | DATABASE_NAME="magento"_"$(date +%s)" 298 | 299 | NGINX_SITES_CONF_D="$(pwd)/conf/nginx/conf.d" 300 | NGINX_SITES_CONF_D_FILE="${NGINX_SITES_CONF_D}/${VHOST_DOMAIN}.conf" 301 | 302 | ADMIN_USER="admin" 303 | ADMIN_PASSWORD="Admin123" 304 | 305 | MYSQL_HOST="mysql" 306 | } 307 | 308 | 309 | function validateArgs() 310 | { 311 | ERROR_COUNT=0 312 | if [[ -z "$VHOST_DOMAIN" ]]; then 313 | _error "--domain=... parameter is missing." 314 | ERROR_COUNT=$((ERROR_COUNT + 1)) 315 | fi 316 | if [[ ! -z "$APP_PHP" && "$APP_PHP" != @(php70|php71|php72|php73|php74|php74-c2|php81-c2|php82) ]]; then 317 | _error "Please enter valid application php --php-version=... parameter(php70|php71|php72|php73|php74|php74-c2|php81-c2|php82)." 318 | ERROR_COUNT=$((ERROR_COUNT + 1)) 319 | fi 320 | if [[ -z "$MAGENTO_VERSION" ]]; then 321 | _error "--mangeto-version=... parameter is missing." 322 | ERROR_COUNT=$((ERROR_COUNT + 1)) 323 | fi 324 | if [[ -z "$APP_PHP" ]]; then 325 | _error "--php-version=... parameter is missing." 326 | ERROR_COUNT=$((ERROR_COUNT + 1)) 327 | fi 328 | if [[ -z "$MAGENTO_EDITION" ]]; then 329 | _error "--magento-edition=... parameter is missing." 330 | ERROR_COUNT=$((ERROR_COUNT + 1)) 331 | fi 332 | if [[ ! -z "$MAGENTO_EDITION" && "$MAGENTO_EDITION" != @(community|enterprise) ]]; then 333 | _error "Please enter valid application magento edition --magento-edition=... parameter(community|enterprise)." 334 | ERROR_COUNT=$((ERROR_COUNT + 1)) 335 | fi 336 | 337 | [[ "$ERROR_COUNT" -gt 0 ]] && exit 1 338 | } 339 | 340 | function sanitizeArgs() 341 | { 342 | if [[ ! -z "$VHOST_DOMAIN" ]] && [[ "$VHOST_DOMAIN" == http* ]]; then 343 | VHOST_DOMAIN=$(getPureDomain) 344 | fi 345 | } 346 | 347 | function verifyCurrentDirIsDockercomposeDir() 348 | { 349 | if [[ ! -f $($(pwd)/.root_dir) ]]; then 350 | _error "Please change your current folder to docker-compose root folder (root folder is the folder contain docker-compose.yml file)." 351 | exit 1 352 | fi 353 | } 354 | 355 | function getMysqlInformation() 356 | { 357 | containerNameDB=$(docker inspect -f '{{.Name}}' $(docker-compose ps -q mysql) | cut -c2-) 358 | 359 | mysqlUser=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_USER) 360 | user="${mysqlUser/MYSQL_USER=/$replace}" 361 | 362 | mysqlPass=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_PASSWORD) 363 | pass="${mysqlPass/MYSQL_PASSWORD=/$replace}" 364 | 365 | mysqRootPass=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $containerNameDB | grep MYSQL_ROOT_PASSWORD) 366 | rootPass="${mysqRootPass/MYSQL_ROOT_PASSWORD=/$replace}" 367 | } 368 | 369 | function validateMagentoVersion() 370 | { 371 | if [[ $MAGENTO_VERSION = @(2.4.0*|2.4.1*|2.4.2*|2.4.3*) ]]; then 372 | if [[ $APP_PHP != "php74" ]]; then 373 | _error "PHP should run with PHP version 7.4 composer1, --php-version=php74" 374 | exit 1 375 | elif [[ ! $($SCRIPTS_DIR/list-services | grep elasticsearch) ]]; then 376 | _error "Elasticsearch service should be started, please start elasticsearch" 377 | exit 1 378 | fi 379 | elif [[ $MAGENTO_VERSION == 2.4* ]] && [[ $MAGENTO_VERSION != @(2.4.0*|2.4.1*|2.4.2*|2.4.3*) ]]; then 380 | if [[ $APP_PHP != @(php81-c2*|php82*) ]]; then 381 | _error "PHP should run with PHP version 8.1 composer2 or PHP version 8.2, --php-version=php81-c2 or --php-version=php82 " 382 | exit 1 383 | elif [[ ! $($SCRIPTS_DIR/list-services | grep elasticsearch) ]]; then 384 | _error "Elasticsearch service should be started, please start elasticsearch" 385 | exit 1 386 | fi 387 | fi 388 | } 389 | 390 | function validateBaseServices() 391 | { 392 | if [[ ! $($SCRIPTS_DIR/list-services | grep nginx) ]]; then 393 | _error "nginx service should be started, please start Nginx" 394 | exit 1 395 | fi 396 | if [[ ! $($SCRIPTS_DIR/list-services | grep mysql) ]]; then 397 | _error "Mysql service should be started, please start Mysql" 398 | exit 1 399 | fi 400 | if [[ ! $($SCRIPTS_DIR/list-services | grep $APP_PHP) ]]; then 401 | _error "$APP_PHP service should be started, please start $APP_PHP" 402 | exit 1 403 | fi 404 | } 405 | 406 | function createSourceCodeFolder() 407 | { 408 | if [[ -d ${SOURCE_DIR}/$VHOST_DOMAIN ]] && [[ "$(ls -A ${SOURCE_DIR}/$VHOST_DOMAIN)" ]]; then 409 | _error "${SOURCE_DIR}/$VHOST_DOMAIN folder is not empty" 410 | exit 1 411 | else 412 | _arrow "Create source code folder" 413 | mkdir -p ${SOURCE_DIR}/$VHOST_DOMAIN || _die "Error" 414 | _success "Source code folder created" 415 | fi 416 | } 417 | 418 | function createMagentoDomain() 419 | { 420 | ${SCRIPTS_DIR}/create-vhost --domain=${VHOST_DOMAIN} --app=magento2 --root-dir=${VHOST_DOMAIN} --php-version=${APP_PHP} 421 | } 422 | 423 | function createDomainDatabase() 424 | { 425 | ${SCRIPTS_DIR}/database create --database-name=${DATABASE_NAME} 426 | } 427 | 428 | function checkComposerAuth() 429 | { 430 | MAGENTO_USERNAME_PROP="http-basic.repo.magento.com.username" 431 | MAGENTO_PASSWORD_PROP="http-basic.repo.magento.com.password" 432 | 433 | PUBLIC_KEY="$(docker-compose exec -T --user nginx ${APP_PHP} composer config --global $MAGENTO_USERNAME_PROP 2>/dev/null)" 434 | PRIVATE_KEY="$(docker-compose exec -T --user nginx ${APP_PHP} composer config --global $MAGENTO_PASSWORD_PROP 2>/dev/null)" 435 | 436 | if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then 437 | echo 438 | echo "Composer authentication required (repo.magento.com public and private keys):" 439 | read -r -p " Username: " PUBLIC_KEY 440 | read -r -p " Password: " PRIVATE_KEY 441 | echo 442 | if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then 443 | _error "Please setup Composer auth for repo.magento.com to continue." 444 | fi 445 | _arrow "Configure magento repo auth" 446 | $(docker-compose exec -T --user nginx ${APP_PHP} composer config --global http-basic.repo.magento.com ${PUBLIC_KEY} ${PRIVATE_KEY}) || _die "Cannot configure magento auth" 447 | _success "Configure magento repo auth done" 448 | fi 449 | 450 | } 451 | 452 | function downloadMagentoVersion() 453 | { 454 | VERSION=${MAGENTO_VERSION} 455 | EDITION=${MAGENTO_EDITION} 456 | _arrow "Download Magento ${EDITION} version ${VERSION}" 457 | docker-compose exec --user nginx ${APP_PHP} php -d memory_limit=-1 /usr/bin/composer create-project --repository=https://repo.magento.com/ magento/project-"${EDITION}"-edition="${VERSION}" /home/public_html/${VHOST_DOMAIN}/ || _die "Cannot download source code" 458 | _success "Download Magento ${EDITION} version ${VERSION} done" 459 | } 460 | 461 | function installMagentoVersion() 462 | { 463 | _arrow "Install Magento ${EDITION} version ${VERSION} for $VHOST_DOMAIN" 464 | 465 | if [[ $MAGENTO_VERSION == 2.4* ]]; then 466 | docker-compose exec --user nginx ${APP_PHP} php -d memory_limit=-1 /home/public_html/${VHOST_DOMAIN}/bin/magento setup:install \ 467 | --db-host="$MYSQL_HOST" \ 468 | --db-name="${DATABASE_NAME}" \ 469 | --db-user="root" \ 470 | --db-password="$rootPass" \ 471 | --base-url=http://"$VHOST_DOMAIN"/ \ 472 | --admin-firstname="admin" \ 473 | --admin-lastname="admin" \ 474 | --admin-email="admin@localhost.com" \ 475 | --admin-user="$ADMIN_USER" \ 476 | --admin-password="$ADMIN_PASSWORD" \ 477 | --backend-frontname="admin" \ 478 | --language="en_US" \ 479 | --search-engine=elasticsearch7 \ 480 | --elasticsearch-host="elasticsearch" \ 481 | --elasticsearch-port="9200" \ 482 | --elasticsearch-index-prefix="${VHOST_DOMAIN}" \ 483 | --currency="USD" \ 484 | --timezone="America/Chicago" \ 485 | --use-rewrites=1 || _die "Cannot Install Magento" 486 | _success "Install Magento ${EDITION} version ${VERSION} for $VHOST_DOMAIN successful!" 487 | else 488 | docker-compose exec --user nginx ${APP_PHP} php -d memory_limit=-1 /home/public_html/${VHOST_DOMAIN}/bin/magento setup:install \ 489 | --db-host="$MYSQL_HOST" \ 490 | --db-name="${DATABASE_NAME}" \ 491 | --db-user="root" \ 492 | --db-password="$rootPass" \ 493 | --base-url=http://"$VHOST_DOMAIN"/ \ 494 | --admin-firstname="admin" \ 495 | --admin-lastname="admin" \ 496 | --admin-email="admin@localhost.com" \ 497 | --admin-user="$ADMIN_USER" \ 498 | --admin-password="$ADMIN_PASSWORD" \ 499 | --backend-frontname="admin" \ 500 | --language="en_US" \ 501 | --currency="USD" \ 502 | --timezone="America/Chicago" \ 503 | --use-rewrites=1 || _die "Cannot Install Magento" 504 | _success "Install Magento ${EDITION} version ${VERSION} for $VHOST_DOMAIN successful!" 505 | fi 506 | } 507 | 508 | function printSuccessMessage() 509 | { 510 | echo "################################################################" 511 | echo "" 512 | echo " >> Domain : ${VHOST_DOMAIN}" 513 | echo " >> PHP version : ${APP_PHP}" 514 | echo " >> Document Root : /home/public_html/${VHOST_DOMAIN}/" 515 | echo " >> Nginx Config File : ${NGINX_SITES_CONF_D_FILE}" 516 | echo " >> Database name : ${DATABASE_NAME}" 517 | echo " >> Database User : root" 518 | echo " >> Database Password : $rootPass" 519 | echo " >> Admin URL : http://${VHOST_DOMAIN}/admin" 520 | echo " >> Admin User : $ADMIN_USER" 521 | echo " >> Admin Password : $ADMIN_PASSWORD" 522 | echo "" 523 | echo "################################################################" 524 | } 525 | 526 | ################################################################################ 527 | # Main 528 | ################################################################################ 529 | export LC_CTYPE=C 530 | export LANG=C 531 | 532 | DEBUG=0 533 | _debug set -x 534 | VERSION="1" 535 | 536 | function main() 537 | { 538 | # _checkRootUser 539 | # verifyCurrentDirIsDockercomposeDir 540 | checkCmdDependencies 541 | 542 | [[ $# -lt 1 ]] && _printUsage 543 | 544 | processArgs "$@" 545 | initDefaultArgs 546 | 547 | validateMagentoVersion 548 | validateBaseServices 549 | 550 | createSourceCodeFolder 551 | createMagentoDomain 552 | createDomainDatabase 553 | 554 | checkComposerAuth 555 | downloadMagentoVersion 556 | 557 | getMysqlInformation 558 | installMagentoVersion 559 | 560 | printSuccessMessage 561 | exit 0 562 | } 563 | 564 | main "$@" 565 | 566 | _debug set +x -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MỤC LỤC 2 | - [MỤC LỤC](#mục-lục) 3 | - [GIỚI THIỆU](#giới-thiệu) 4 | - [Yêu cầu hệ thống](#yêu-cầu-hệ-thống) 5 | - [Giới thiệu hệ thống](#giới-thiệu-hệ-thống) 6 | - [Cấu trúc thư mục hệ thống](#cấu-trúc-thư-mục-hệ-thống) 7 | - [Các services được cấu hình sẵn trong hệ thống](#các-services-được-cấu-hình-sẵn-trong-hệ-thống) 8 | - [Các command của hệ thống](#các-command-của-hệ-thống) 9 | - [Hệ thống email catch all](#hệ-thống-email-catch-all) 10 | - [HƯỚNG DẪN SỬ DỤNG](#hướng-dẫn-sử-dụng) 11 | - [Các lệnh docker/docker-compose cơ bản](#các-lệnh-dockerdocker-compose-cơ-bản) 12 | - [Hướng dẫn sử dụng hệ thống](#hướng-dẫn-sử-dụng-hệ-thống) 13 | - [Bắt đầu sử dụng](#bắt-đầu-sử-dụng) 14 | - [Xoá dữ liệu](#xoá-dữ-liệu) 15 | - [Một số ví dụ](#một-số-ví-dụ) 16 | - [Khởi tạo và chạy nginx, php72, mysql](#khởi-tạo-và-chạy-nginx-php72-mysql) 17 | - [Khởi tạo thêm php72](#khởi-tạo-thêm-php72) 18 | - [Bật Xdebug cho php72](#bật-xdebug-cho-php72) 19 | - [Tạo database với tên yoyoyo](#tạo-database-với-tên-yoyoyo) 20 | - [Import file backup vào database yoyoyo](#import-file-backup-vào-database-yoyoyo) 21 | - [Export (backup) database tên yoyoyo](#export-backup-database-tên-yoyoyo) 22 | - [Drop database với tên yoyoyo](#drop-database-với-tên-yoyoyo) 23 | - [Tự động tải và cài đặt Magento](#tự-động-tải-và-cài-đặt-magento) 24 | - [Bật SSL cho domain](#bật-ssl-cho-domain) 25 | - [Sử dụng varnish cho domain](#sử-dụng-varnish-cho-domain) 26 | - [Các bước chạy 1 site magento dự án clone từ git02 về](#các-bước-chạy-1-site-magento-dự-án-clone-từ-git02-về) 27 | # GIỚI THIỆU 28 | Combo docker-compose cho Magento với các tính năng như: 29 | 30 | * Chạy được đồng thời nhiều phiên bản PHP, bạn không cần phải tạo tạo nhiều stack docker-compose khác nhau cho nhiều project, mà chỉ cần dùng 1 stack docker-compose duy nhất. 31 | * Tự động tạo Virtual host cho nginx, hỗ trợ Magento 1, Magento 2, Laravel, Wordpress. 32 | * Hỗ trợ SSL 33 | * Tự động tải, cài đặt Magento fresh các phiên bản theo yêu cầu. 34 | * Tạo/Drop/Import/Export database từ command. 35 | * Bật tắt Xdebug ứng với từng phiên bản PHP. 36 | * Tự động add các domain sử dụng vào /etc/hosts. 37 | * Email catch all local, tránh tình trạng gửi email ra ngoài internet (tất nhiên thì vẫn phải nhớ check xem config SMTP đừng có để configure của prod =))) 38 | * Hỗ trợ nvm, grunt. 39 | * Log nginx được lưu riêng trong thư mục logs/nginx 40 | 41 | Hiện tại mới test trên Ubuntu, các hệ điều hành khác mọi người vui lòng tự mò =). 42 | 43 | ## Yêu cầu hệ thống 44 | * Hệ thống cần có cài đặt docker và docker-compose (docker-compose cần cài bản mới nhất thông qua hướng dẫn sau, lưu ý không cài đặt docker-compose thông qua python pip - đây là phiên bản cũ ). Hướng dẫn cài đặt có thể tham khảo Google hoặc: 45 | 46 | [Hướng dẫn cài đặt docker trên Ubuntu](https://docs.docker.com/engine/install/ubuntu/) 47 | 48 | ```bash 49 | # Hướng dẫn cài đặt docker-compose trên Ubuntu 50 | sudo curl -L https://github.com/docker/compose/releases/download/1.28.5/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose 51 | chmod +x /usr/local/bin/docker-compose 52 | ``` 53 | 54 | * Cài xong docker thì nhơ chạy lệnh này để add user máy mình đang chạy được quyền chạy docker mà không cần gõ sudo, gõ xong thì nhớ logout rồi login lại: 55 | ```bash 56 | sudo usermod -aG docker $USER 57 | ``` 58 | ### Giới thiệu hệ thống 59 | ```bash 60 | ❯ tree 61 | . 62 | ├── README.md 63 | ├── build 64 | │   ├── elasticsearch 65 | │   │   └── Dockerfile 66 | │   ├── nginx 67 | │   │   ├── Dockerfile 68 | │   │   └── conf 69 | │   │   └── nginx.conf 70 | │   ├── php70 71 | │   │   └── Dockerfile 72 | │   ├── php71 73 | │   │   └── Dockerfile 74 | │   ├── php72 75 | │   │   └── Dockerfile 76 | │   ├── php73 77 | │   │   └── Dockerfile 78 | │   ├── php74 79 | │   │   └── Dockerfile 80 | │   ├── php74-c2 81 | │   │   └── Dockerfile 82 | │   ├── php81-c2 83 | │   │   └── Dockerfile 84 | │   └── varnish 85 | │   └── Dockerfile 86 | ├── conf 87 | │   ├── nginx 88 | │   │   ├── conf.d 89 | │   │   ├── nginx.conf 90 | │   │   └── ssl 91 | │   ├── php 92 | │   │   ├── php70 93 | │   │   │   ├── 10-opcache.ini 94 | │   │   │   ├── magento.conf 95 | │   │   │   └── php.ini 96 | │   │   ├── php71 97 | │   │   │   ├── 10-opcache.ini 98 | │   │   │   ├── magento.conf 99 | │   │   │   └── php.ini 100 | │   │   ├── php72 101 | │   │   │   ├── 10-opcache.ini 102 | │   │   │   ├── magento.conf 103 | │   │   │   └── php.ini 104 | │   │   ├── php73 105 | │   │   │   ├── 10-opcache.ini 106 | │   │   │   ├── magento.conf 107 | │   │   │   └── php.ini 108 | │   │   ├── php74 109 | │   │   │   ├── 10-opcache.ini 110 | │   │   │   ├── magento.conf 111 | │   │   │   └── php.ini 112 | │   │   ├── php74-c2 113 | │   │   │   ├── 10-opcache.ini 114 | │   │   │   ├── magento.conf 115 | │   │   │   └── php.ini 116 | │   │   ├─ php81-c2 117 | │   │   │   ├── 10-opcache.ini 118 | │   │   │   ├── magento.conf 119 | │   │   │   └── php.ini 120 | │   │   └── php82 121 | │   │   ├── 10-opcache.ini 122 | │   │   ├── magento.conf 123 | │   │   └── php.ini 124 | | | 125 | │   └── varnish 126 | │   └── default.vcl 127 | ├── data 128 | ├── databases 129 | │   ├── export 130 | │   └── import 131 | ├── docker-compose.yml 132 | ├── env-example 133 | ├── images 134 | │   ├── cert.png 135 | │   ├── cert02.png 136 | │   ├── cert03.png 137 | │   └── xdebug-phpstorm-01.png 138 | ├── logs 139 | │   └── nginx 140 | ├── scripts 141 | │   ├── create-vhost 142 | │   ├── database 143 | │   ├── fixowner 144 | │   ├── init-magento 145 | │   ├── list-services 146 | │   ├── mysql 147 | │   ├── setup-composer 148 | │   ├── shell 149 | │   ├── ssl 150 | │   ├── varnish 151 | │   └── xdebug 152 | └── sources 153 | 154 | 32 directories, 48 files 155 | ``` 156 | #### Cấu trúc thư mục hệ thống 157 | 158 | | Thư mục | Chức năng | 159 | |---------|-----------| 160 | | build | Chứa các file sử dụng trong quá trình build container sử dụng cho hệ thống | 161 | | conf | Chứa các file config cho container sử dụng trong quá trình người dùng sử dụng | 162 | | data | Chứa các dữ liệu cho các container như mysql, rabbitMQ | 163 | | database | Folder sử dụng cho các chức năng import/export database | 164 | | images | Folder ảnh của cái README.md này, LOL | 165 | | logs | Folder chứa log nginx cho tiện theo dõi ngoài hệ thống | 166 | | scripts | Folder chứa các command chức năng sử dụng cho hệ thống | 167 | | sources | Folder chứa các thư mục sources của các website dự án | 168 | 169 | #### Các services được cấu hình sẵn trong hệ thống 170 | 171 | * Hệ thống đã được cấu hình sẵn các services sau: 172 | 173 | | Tên services | Giải thích | 174 | |--------------|------------| 175 | | nginx | service webserver nginx | 176 | | php70 | service php version php 7.0 | 177 | | php71 | service php version php 7.1 | 178 | | php72 | service php version php 7.2 | 179 | | php73 | service php version php 7.3 | 180 | | php74-c2 | service php version php 7.4 sử dụng composer2| 181 | | php81-c2 | service php version php 8.1 sử dụng composer2| 182 | | php82 | service php version php 8.2 sử dụng composer2| 183 | | php74 | service php version php 7.4 | 184 | | mysql | service mysql, default sử dụng version 8.0 | 185 | | mailhog | service email catch all | 186 | | elasticsearch | service Elastiscsearch | 187 | | kibana | service Kibana | 188 | | redis | service Redis | 189 | | rabbitmq | service RabbitMQ | 190 | | phpmyadmin | service phpmyadmin | 191 | | phpredmin | service phpredmin | 192 | | varnish | service varnish | 193 | 194 | 195 | #### Các command của hệ thống 196 | | Command | Tác dụng | 197 | |---------|----------| 198 | | create-vhost | Tự động tạo virtual host cho services nginx ứng với từng loại magento và version php | 199 | | database | create/drop/import/export/list databases | 200 | | fixowner | Command sử dụng để change lại owner của thư mục source code đúng với default mà hệ thống sử dụng | 201 | | init-magento | Command sử dụng để tự động tải về và cài đặt Magento lên hệ thống | 202 | | list-services | Command sử dụng để list các services mà docker-compose đã khởi tạo và đang chạy | 203 | | mysql | Command sử dụng để tương tác với mysql shell trong mysql container | 204 | | setup-composer | Composer sử dụng để setup auth.json default cho repo của Magento trong trường hợp cần thiết | 205 | | shell | Command sử dụng để truy cập vào các container php với user dùng để chạy website, không dùng user root | 206 | | ssl | Command sử dụng để tạo Virtual host SSL cho các domain được lựa chọn | 207 | | xdebug | Command sử dụng để bật/tắt xdebug của 1 service php được lựa chọn | 208 | | varnish | Command sử dụng để bật/tắt varnish của 1 domain được lựa chọn | 209 | 210 | #### Hệ thống email catch all 211 | 212 | * Hệ thống có được cấu hình thêm sử dụng email catch all dùng Mailhog để có thể test mail trên local mà không cần cấu hình SMTP với các thông tin public. 213 | * Mặc định hệ thống nếu không cấu hình SMTP, các service PHP đều sẽ gửi email thông qua Mailhog, do đó khi start hệ thống cần start thêm service Mailhog 214 | * Trường hợp Mailhog đã được start, có thể kiểm tra email đã được gửi thông qua Mailhog bằng cách truy cập đường dẫn sau trên trình duyệt: [http://localhost:8025](http://localhost:8025) 215 | * Trường hợp muốn cấu hình SMTP sử dụng Mailhog cho Magento, có thể sử dụng thông tin kết nối sau: 216 | 217 | | | | 218 | |---|---| 219 | | SMTP Server | mailhog | 220 | | SMTP Port | 1025 | 221 | # HƯỚNG DẪN SỬ DỤNG 222 | ## Các lệnh docker/docker-compose cơ bản 223 | * Xài docker thì cũng nên biết 1 số lệnh cơ bản sau: 224 | ```bash 225 | # Xem thông tin các docker container đang chạy sử dụng docker-compose.yml tại thư mục hiện hành 226 | docker-compose ps 227 | 228 | # Xem thông tin tài nguyên mà các container đang sử dụng 229 | docker stats 230 | 231 | # List tất cả các serices được khai báo trong file docker-compose.yml 232 | docker-compose ps --services 233 | 234 | # List tất cả các server được khai báo trong file docker-compose.yml đang ở trạng thái running 235 | docker-compose ps --services --filter "status=running" 236 | 237 | # Khởi tạo toàn bộ các services (containers) được khai báo trong file docker-compose.yml 238 | docker-compose up -d 239 | 240 | # Check log của 1 container nào đó (ngoài php, nginx), ví dụ logs của elasticsearch 241 | docker-compose log elasticsearch 242 | 243 | # Khởi tạo và chạy một số services (container) được lựa chọn, chứ không khởi động toàn bộ services (container) được khai báo trong docker-compose.yml - Ví dụ chỉ khởi tạo và chạy nginx, php72, mysql 244 | docker-compose up -d nginx php72 mysql 245 | 246 | # Stop và xoá toàn bộ các services (containers) tạo và đang chạy được khai vào trong file docker-compose.yml, bao gồm cả volumes (không bao gồm file trong thư mục ./data/) 247 | docker-compose down --remove-orphans 248 | 249 | # Tắt các services (container) đang chạy được khai báo trong file docker-compose.yml - Kiểu tắt 1 xíu cho đỡ nặng máy rồi tí khởi động lại. 250 | docker-compose stop 251 | 252 | # Khởi động các services (container) đã khởi tạo được khai báo trong file docker-compose.yml - services (container) nào mà không khởi tạo trước đó thì sẽ vẫn không được khởi tạo và không được start. 253 | docker-compose start 254 | 255 | # Restart lại các services (container) đang chạy 256 | docker-compose restart 257 | 258 | # Chui vô 1 services để chạy command - Ví dụ tính chui vô container service php72 để chạy composer 259 | docker-compose exec php72 bash 260 | 261 | # Restart lại container php sau khi thay đổi giá trị nào đó trong php.ini, ví dụ cần restart container php72 262 | docker-compose restart php72 263 | ``` 264 | * Các services nội bộ có thể kết nối với nhau thông qua tên của services. Ví dụ có thể điền Mysql host thay vì localhost là mysql. Hoặc kết nối tới các services elasticsearch, redis thay vì localhost thì để là elasticsearch và redis, các port kết nối vẫn là port mặc định v.v. 265 | 266 | ## Hướng dẫn sử dụng hệ thống 267 | 268 | * Clone repo này vào một thư mục trên máy 269 | * Copy file env-example thành .env 270 | * Đổi thông tin cần thiết nếu có trong file .env trước khi chạy. 271 | * MySQL được mount port ra ngoài thông qua port 3308, trong trường hợp bạn muốn kết nối tới container mysql từ máy vật lý thông qua phần mêm như MySQL Workbench, bạn có thể connect với thông tin host: 127.0.0.1, port: 3308 272 | * phpmyadmin được mount port ra ngoài máy vật lý thông qua port 8080 273 | * phpredmin được mount port ra ngoài máy vật lý thông qua port 8081, và với thông tin User: admin, Password: admin 274 | * Trường hợp sau một thời gian sử dụng, bạn có build lại image mà bị lỗi, bạn có thể sử dụng câu lệnh build sau để bỏ qua docker cache được lưu trước đó, ví dụ bạn cần build image php81-c2 275 | ```bash 276 | docker-compose build --no-cache php81-c2 277 | ``` 278 | 279 | **Lưu ý:** 280 | * Mọi command khi chạy trên hệ thống cần chạy trong thư mục chứa file docker-compose.yml 281 | * Source code website cần được để trong 1 thư mục riêng trong thư mục sources. Nên để tạo thư mục dạng sources/domain.com và clone sources code vào thư mục này. Source code nên để trực tiếp trong thư mục sources/domain.com/ chứ không để trong sources/domain.com/src, trong trường hợp để trong sources/domain.com/src cần lưu ý trong bước tạo virtual host của nginx. 282 | * Các command sử dụng cần được gọi theo dạng ./scripts/ten_command. Ví dụ: ./scripts/xdebug enable --php-version=php72 283 | * Các command đều có hướng dẫn sử dụng riêng, có thể xem hướng dẫn bằng cách gõ command trong shell, ví dụ: 284 | ```bash 285 | user@local:~/docker-magento$./scripts/xdebug 286 | Docker Xdebug tools 287 | Version 1 288 | 289 | ./scripts/xdebug [OPT] [ARG]... 290 | 291 | Options: 292 | enable Enable Xdebug. 293 | disable Disable Xdebug. 294 | status List all Xdebug status. 295 | Args: 296 | --php-version PHP version used for Xdebug (php70|php71|php72|php73|php74). 297 | -h, --help Display this help and exit. 298 | 299 | Examples: 300 | Disable Xdebug for PHP 7.2 301 | ./scripts/xdebug disable --php-version=php72 302 | Enable Xdebug for PHP 7.3 303 | ./scripts/xdebug enable --php-version=php73 304 | 305 | 306 | ____ __ __ _ ____ _____ ___ ____ ____ 307 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 308 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 309 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 310 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 311 | 312 | 313 | 314 | ################################################################################ 315 | ``` 316 | ## Bắt đầu sử dụng 317 | ```bash 318 | # Clone về 1 thư mục 319 | git clone https://github.com/picassio/docker-magento-multiple-php.git ~/docker-mangento 320 | # Chuyển đến thư mục 321 | cd ~/docker-mangento 322 | # Tạo file .env 323 | cp env-example .env 324 | # Chỉnh sửa thông tin file .env nếu cần thiết 325 | # Khởi tạo hệ thống theo như cầu, ví dụ cần chạy nginx, php72, mysql, mailhog 326 | docker-compose up -d nginx php72 mysql mailhog 327 | # Khởi tạo thêm service nếu cần thêm, ví dụ hệ thống cần chạy thêm elasticsearch, redis 328 | docker-compose up -d redis elasticsearch 329 | # List các services đang chạy 330 | ./scripts/list-services 331 | 332 | ``` 333 | ## Xoá dữ liệu 334 | 335 | Trong trường hợp bạn muốn xoá toàn bộ dữ liệu (do rảnh quá, thích tạo cái mới trắng tinh chơi, lol), bạn cần xoá các thư mục sau: 336 | 337 | - Các thư mục chứa source code trong: ./data/ 338 | - Các file nginx config trong: ./conf/nginx/conf.d/ 339 | - Stop và xoá các container cũng như các docker volume cũ, để stop container và xoá container/volume có thể chạy lệnh: 340 | ```bash 341 | docker-compose down -v --remove-orphans 342 | ``` 343 | 344 | ## Một số ví dụ 345 | 346 | ### Khởi tạo và chạy nginx, php72, mysql, mailhog 347 | Default hệ thống sẽ gửi mail thông qua mailhog, do đó khi tạo bất cứ 1 stack mới nào cần start thêm mailhog. 348 | ```bash 349 | docker-compose up -d nginx php72 mysql mailhog 350 | ``` 351 | ### Khởi tạo thêm php72 352 | ```bash 353 | docker-compose up -d nginx php73 mysql 354 | ``` 355 | ### Bật Xdebug cho php72 356 | ```bash 357 | ./scripts/xdebug enable --php-version=php72 358 | ``` 359 | 360 | * Lưu ý: Để sử dụng Xdebug với PHP Storm, cần cấu hình thêm Map path trong PHP Storm setting. Mục Absolute path onn the server là path của website trong docker container: 361 | ![PHPSTORM XDEBUG](./images/xdebug-phpstorm-01.png "PHP Storm path map for Xdebug") 362 | 363 | ### Tạo database với tên yoyoyo 364 | ```bash 365 | ./scripts/database create --database-name=yoyoyo 366 | ``` 367 | ### Import file backup vào database yoyoyo 368 | * File backup cần import vào cần có tên dạng .sql. Ví dụ: backup-test.sql 369 | * File backup cần import vào cần để trong thư mục ./databases/import 370 | ```bash 371 | ./scripts/database import --source=backup-test.sql --target=yoyoyo 372 | ``` 373 | ### Export (backup) database tên yoyoyo 374 | ```bash 375 | ./scripts/database export --database-name=yoyoyo 376 | ``` 377 | ### Drop database với tên yoyoyo 378 | ```bash 379 | ./scripts/database drop --database-name=yoyoyo 380 | ``` 381 | ### Tự động tải và cài đặt Magento 382 | * Tự động tải và cài đặt Magento bản community version 2.3.4, sử dụng domain test.com, chạy với php7.2 383 | ```bash 384 | ./scripts/init-magento --php-version=php72 --domain=test.com --mangeto-version=2.3.4 --magento-edition=community 385 | ``` 386 | ### Bật SSL cho domain 387 | * Bật SSL cho domain test.com 388 | * Sau khi bật cần chỉnh lại databse của mangeto, phần URL sang dùng https 389 | ```bash 390 | ./scripts/ssl --domain=test-magento.com 391 | ``` 392 | ### Sử dụng varnish cho domain 393 | ```bash 394 | # Bật varnish 395 | ./scripts/varnish-test enable --domain=test.com 396 | 397 | # Tắt varnish 398 | ./scripts/varnish-test disable --domain=test.com 399 | 400 | # Check varnish status 401 | ./scripts/varnish-test status --domain=test.com 402 | 403 | ``` 404 | ### Các bước chạy 1 site magento dự án clone từ git02 về 405 | * Mọi command thực hiện cần đứng ở thư mục chứa file docker-compose.yml 406 | * Chọn domain cần sử dụng cho dự án, ví dụ magento-test.com, tạo thư mục chứa source code 407 | ```bash 408 | mkdir -p ./sources/magento-test.com 409 | * Clone source code từ git về thư mục vừa tạo 410 | ```bash 411 | git clone http://gitrepo.com ./sources/magento-test.com 412 | ``` 413 | * Tạo database cho website, ví dụ: magento_db 414 | ```bash 415 | ./scripts/database create --database-name=magento_db 416 | ``` 417 | * Copy file backup DB của website vào thư mục ./databases/import 418 | * Chạy command import DB, ví dụ 419 | ```bash 420 | ./scripts/database import --source=backup-test.sql --target=magento_db 421 | ``` 422 | * Chọn phiên bản php cần chạy. Trong trường hợp chưa khởi tạo, khởi tạo trên hệ thống ví dụ php version cần sử dụng là php7.3 423 | ```bash 424 | docker-compose up -d php73 425 | ``` 426 | * Tạo Vhost cho nginx container service 427 | * Lúc này root dir thay vì ./sources/magento-test.com sẽ chỉ cần để tên thư mục source code trong thư mục ./sources/ là magento-test.com. Trong trường hợp source code của Magento ở trong ./sources/magento-test.com/src thì --root-dir=magento-test.com/src 428 | ```bash 429 | ./scripts/create-vhost --domain=magento-test.com --app=magento2 --root-dir=magento-test.com --php-version=php73 430 | ``` 431 | * Copy file env.php, config.php vào đúng thư mục, chỉnh sửa lại thông tin kết nối db. Password root mysql có được khai báo trong file .env 432 | ```bash 433 | 'host' => 'mysql', 434 | 'dbname' => 'magento_db', 435 | 'username' => 'root', 436 | 'password' => 'root', 437 | ``` 438 | * Truy cập vào container php73 để chạy các command build 439 | ```bash 440 | ./scripts/shell php73 441 | cd magento-test.com 442 | # Chạy command build j đó của bạn, lưu ý ko chạy sudo 443 | ``` -------------------------------------------------------------------------------- /scripts/create-vhost: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Script to create virtual host for Nginx server 5 | # 6 | 7 | # UnComment it if bash is lower than 4.x version 8 | shopt -s extglob 9 | 10 | ################################################################################ 11 | # CORE FUNCTIONS - Do not edit 12 | ################################################################################ 13 | 14 | ## Uncomment it for debugging purpose 15 | ###set -o errexit 16 | #set -o pipefail 17 | #set -o nounset 18 | #set -o xtrace 19 | 20 | # 21 | # VARIABLES 22 | # 23 | _bold=$(tput bold) 24 | _underline=$(tput sgr 0 1) 25 | _reset=$(tput sgr0) 26 | 27 | _purple=$(tput setaf 171) 28 | _red=$(tput setaf 1) 29 | _green=$(tput setaf 76) 30 | _tan=$(tput setaf 3) 31 | _blue=$(tput setaf 38) 32 | 33 | # 34 | # HEADERS & LOGGING 35 | # 36 | function _debug() 37 | { 38 | if [[ "$DEBUG" = 1 ]]; then 39 | "$@" 40 | fi 41 | } 42 | 43 | function _header() 44 | { 45 | printf '\n%s%s========== %s ==========%s\n' "$_bold" "$_purple" "$@" "$_reset" 46 | } 47 | 48 | function _arrow() 49 | { 50 | printf '➜ %s\n' "$@" 51 | } 52 | 53 | function _success() 54 | { 55 | printf '%s✔ %s%s\n' "$_green" "$@" "$_reset" 56 | } 57 | 58 | function _error() { 59 | printf '%s✖ %s%s\n' "$_red" "$@" "$_reset" 60 | } 61 | 62 | function _warning() 63 | { 64 | printf '%s➜ %s%s\n' "$_tan" "$@" "$_reset" 65 | } 66 | 67 | function _underline() 68 | { 69 | printf '%s%s%s%s\n' "$_underline" "$_bold" "$@" "$_reset" 70 | } 71 | 72 | function _bold() 73 | { 74 | printf '%s%s%s\n' "$_bold" "$@" "$_reset" 75 | } 76 | 77 | function _note() 78 | { 79 | printf '%s%s%sNote:%s %s%s%s\n' "$_underline" "$_bold" "$_blue" "$_reset" "$_blue" "$@" "$_reset" 80 | } 81 | 82 | function _die() 83 | { 84 | _error "$@" 85 | exit 1 86 | } 87 | 88 | function _safeExit() 89 | { 90 | exit 0 91 | } 92 | 93 | # 94 | # UTILITY HELPER 95 | # 96 | function _seekConfirmation() 97 | { 98 | printf '\n%s%s%s' "$_bold" "$@" "$_reset" 99 | read -p " (y/n) " -n 1 100 | printf '\n' 101 | } 102 | 103 | # Test whether the result of an 'ask' is a confirmation 104 | function _isConfirmed() 105 | { 106 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then 107 | return 0 108 | fi 109 | return 1 110 | } 111 | 112 | 113 | function _typeExists() 114 | { 115 | if type "$1" >/dev/null; then 116 | return 0 117 | fi 118 | return 1 119 | } 120 | 121 | function _isOs() 122 | { 123 | if [[ "${OSTYPE}" == $1* ]]; then 124 | return 0 125 | fi 126 | return 1 127 | } 128 | 129 | function _isOsDebian() 130 | { 131 | if [[ -f /etc/debian_version ]]; then 132 | return 0 133 | else 134 | return 1 135 | fi 136 | } 137 | 138 | function _isOsRedHat() 139 | { 140 | if [[ -f /etc/redhat-release ]]; then 141 | return 0 142 | else 143 | return 1 144 | fi 145 | } 146 | 147 | function _isOsMac() 148 | { 149 | if [[ "$(uname -s)" = "Darwin" ]]; then 150 | return 0 151 | else 152 | return 1 153 | fi 154 | } 155 | 156 | function _checkRootUser() 157 | { 158 | #if [ "$(id -u)" != "0" ]; then 159 | if [ "$(whoami)" != 'root' ]; then 160 | _die "You cannot run $0 as non-root user. Please use sudo $0" 161 | fi 162 | } 163 | 164 | function askYesOrNo { 165 | REPLY="" 166 | while [ -z "$REPLY" ] ; do 167 | read -ep "$1 $YES_NO_PROMPT" -n1 REPLY 168 | REPLY=$(echo ${REPLY}|tr [:lower:] [:upper:]) 169 | case $REPLY in 170 | $YES_CAPS ) return 0 ;; 171 | $NO_CAPS ) return 1 ;; 172 | * ) REPLY="" 173 | esac 174 | done 175 | } 176 | 177 | function _printPoweredBy() 178 | { 179 | local mp_ascii 180 | mp_ascii=' 181 | ____ __ __ _ ____ _____ ___ ____ ____ 182 | / ___|| \/ | / \ | _ \_ _/ _ \/ ___| / ___| 183 | \___ \| |\/| | / _ \ | |_) || || | | \___ \| | 184 | ___) | | | |/ ___ \| _ < | || |_| |___) | |___ 185 | |____/|_| |_/_/ \_\_| \_\|_| \___/|____/ \____| 186 | 187 | ' 188 | cat </dev/null || _die "'${cmd}' command not found." 387 | done; 388 | } 389 | 390 | function createVirtualHost() 391 | { 392 | # @todo magento | default 393 | 394 | _arrow "Virtual host creation for Nginx started..." 395 | 396 | # Prepare virtual host content as per application 397 | # @todo move it to template based 398 | # @todo add option for https 399 | _arrow "Creating Nginx Vhost File..." 400 | prepareVhostFilePaths 401 | prepareAppVhostContent 402 | _success "Done" 403 | 404 | # @todo change-ownership 405 | 406 | _arrow "Creating an entry to /etc/hosts file..." 407 | createEtcHostEntry 408 | _success "Done" 409 | 410 | _arrow "Reloading the Nginx container configuration..." 411 | reloadNginx 412 | _success "Done" 413 | } 414 | 415 | function createDefaultVhost() 416 | { 417 | #@todo implementation 418 | _die "Vhost for default application not supported yet. Please specify correct --app=... parameter." 419 | } 420 | 421 | function prepareVhostFilePaths() 422 | { 423 | NGINX_SITES_CONF_D_FILE="${NGINX_SITES_CONF_D}/${VHOST_DOMAIN}.conf" 424 | } 425 | 426 | function prepareAppVhostContent() 427 | { 428 | if [[ "$APP_TYPE" = 'magento2' ]]; then 429 | prepareM2VhostContent 430 | elif [[ "$APP_TYPE" = 'magento1' ]]; then 431 | prepareM1VhostContent 432 | elif [[ "$APP_TYPE" = 'wordpress' ]]; then 433 | prepareWpVhostContent 434 | elif [[ "$APP_TYPE" = 'laravel' ]]; then 435 | prepareLaravelVhostContent 436 | elif [[ "$APP_TYPE" = 'default' ]]; then 437 | prepareDefaultVhostContent 438 | fi 439 | } 440 | 441 | function prepareM1VhostContent() 442 | { 443 | echo "server { 444 | listen 80; 445 | server_name ${VHOST_DOMAIN}; 446 | root /home/public_html/${VHOST_ROOT_DIR}; 447 | 448 | location / { 449 | index index.html index.php; ## Allow a static html file to be shown first 450 | try_files \$uri \$uri/ @handler; ## If missing pass the URI to Magento's front handler 451 | expires 30d; ## Assume all files are cachable 452 | } 453 | 454 | # add this for yii else css js will not be picked up 455 | location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 456 | try_files \$uri =404; 457 | } 458 | 459 | ## These locations would be hidden by .htaccess normally 460 | location /app/ { deny all; } 461 | location /includes/ { deny all; } 462 | location /lib/ { deny all; } 463 | location /media/downloadable/ { deny all; } 464 | location /pkginfo/ { deny all; } 465 | location /report/config.xml { deny all; } 466 | location /var/ { deny all; } 467 | 468 | ## Disable .htaccess and other hidden files 469 | location ~ /\. { 470 | deny all; 471 | access_log off; 472 | log_not_found off; 473 | } 474 | 475 | location @handler { ## Magento uses a common front handler 476 | rewrite / /index.php; 477 | } 478 | 479 | location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler 480 | rewrite ^(.*\.php)/ \$1 last; 481 | } 482 | 483 | location ~ \.php$ { ## Execute PHP scripts 484 | if (!-e \$request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss 485 | 486 | # expires off; ## Do not cache dynamic content 487 | fastcgi_pass ${APP_PHP}:9001; 488 | # fastcgi_param HTTPS \$fastcgi_https; 489 | fastcgi_index index.php; 490 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 491 | 492 | fastcgi_param PHP_VALUE \"display_startup_errors=on\"; 493 | fastcgi_param PHP_VALUE \"display_errors=on\"; 494 | fastcgi_param PHP_VALUE \"html_errors=on\"; 495 | fastcgi_param PHP_VALUE \"log_errors=on\"; 496 | fastcgi_param PHP_VALUE \"error_log=/home/public_html/${VHOST_ROOT_DIR}/var/log/system.log\"; 497 | fastcgi_param PHP_VALUE \"xdebug.show_exception_trace=0\"; 498 | 499 | #fastcgi_param MAGE_RUN_CODE default; 500 | #fastcgi_param MAGE_RUN_TYPE store; 501 | fastcgi_param MAGE_IS_DEVELOPER_MODE true; 502 | 503 | include fastcgi_params; 504 | fastcgi_read_timeout 300; 505 | } 506 | } 507 | " > "$NGINX_SITES_CONF_D_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_FILE}" 508 | _arrow "${NGINX_SITES_CONF_D_FILE} file has been created." 509 | } 510 | 511 | function prepareM2VhostContent() 512 | { 513 | echo "server { 514 | 515 | server_name ${VHOST_DOMAIN}; 516 | set \$MAGE_ROOT /home/public_html/${VHOST_ROOT_DIR}; 517 | 518 | access_log /var/log/nginx/${VHOST_DOMAIN}.access.log; 519 | error_log /var/log/nginx/${VHOST_DOMAIN}.error.log; 520 | 521 | ## set \$MAGE_MODE default; # or production or developer 522 | ## 523 | ## If you set MAGE_MODE in server config, you must pass the variable into the 524 | ## PHP entry point blocks, which are indicated below. You can pass 525 | ## it in using: 526 | ## 527 | ## fastcgi_param MAGE_MODE \$MAGE_MODE; 528 | ## 529 | ## In production mode, you should uncomment the 'expires' directive in the /static/ location block 530 | 531 | root \$MAGE_ROOT/pub; 532 | 533 | index index.php; 534 | autoindex off; 535 | charset UTF-8; 536 | error_page 404 403 = /errors/404.php; 537 | #add_header "X-UA-Compatible" "IE=Edge"; 538 | 539 | 540 | # Deny access to sensitive files 541 | location /.user.ini { 542 | deny all; 543 | } 544 | 545 | # PHP entry point for setup application 546 | location ~* ^/setup($|/) { 547 | root \$MAGE_ROOT; 548 | location ~ ^/setup/index.php { 549 | fastcgi_pass ${APP_PHP}:9001; 550 | 551 | fastcgi_param PHP_FLAG \"session.auto_start=off \\n suhosin.session.cryptua=off\"; 552 | fastcgi_param PHP_VALUE \"memory_limit=756M \\n max_execution_time=600\"; 553 | fastcgi_param PHP_VALUE \"error_log=/home/public_html/${VHOST_ROOT_DIR}/var/log/php-error.log\"; 554 | fastcgi_read_timeout 600s; 555 | fastcgi_connect_timeout 600s; 556 | 557 | fastcgi_index index.php; 558 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 559 | include fastcgi_params; 560 | } 561 | 562 | location ~ ^/setup/(?!pub/). { 563 | deny all; 564 | } 565 | 566 | location ~ ^/setup/pub/ { 567 | add_header X-Frame-Options \"SAMEORIGIN\"; 568 | } 569 | } 570 | 571 | # PHP entry point for update application 572 | location ~* ^/update($|/) { 573 | root \$MAGE_ROOT; 574 | 575 | location ~ ^/update/index.php { 576 | fastcgi_split_path_info ^(/update/index.php)(/.+)$; 577 | fastcgi_pass ${APP_PHP}:9001; 578 | fastcgi_param PHP_VALUE \"error_log=/home/public_html/${VHOST_ROOT_DIR}/var/log/php-error.log\"; 579 | fastcgi_index index.php; 580 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 581 | fastcgi_param PATH_INFO \$fastcgi_path_info; 582 | include fastcgi_params; 583 | } 584 | 585 | # Deny everything but index.php 586 | location ~ ^/update/(?!pub/). { 587 | deny all; 588 | } 589 | 590 | location ~ ^/update/pub/ { 591 | add_header X-Frame-Options \"SAMEORIGIN\"; 592 | } 593 | } 594 | 595 | location / { 596 | try_files \$uri \$uri/ /index.php\$is_args\$args; 597 | } 598 | 599 | location /pub/ { 600 | location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) { 601 | deny all; 602 | } 603 | alias \$MAGE_ROOT/pub/; 604 | add_header X-Frame-Options \"SAMEORIGIN\"; 605 | } 606 | 607 | location /static/ { 608 | # Uncomment the following line in production mode 609 | # expires max; 610 | 611 | # Remove signature of the static files that is used to overcome the browser cache 612 | location ~ ^/static/version { 613 | rewrite ^/static/(version\d*/)?(.*)$ /static/\$2 last; 614 | } 615 | 616 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ { 617 | add_header Cache-Control \"public\"; 618 | add_header X-Frame-Options \"SAMEORIGIN\"; 619 | expires +1y; 620 | 621 | if (!-f \$request_filename) { 622 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last; 623 | } 624 | } 625 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 626 | add_header Cache-Control \"no-store\"; 627 | add_header X-Frame-Options \"SAMEORIGIN\"; 628 | expires off; 629 | 630 | if (!-f \$request_filename) { 631 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last; 632 | } 633 | } 634 | if (!-f \$request_filename) { 635 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last; 636 | } 637 | add_header X-Frame-Options \"SAMEORIGIN\"; 638 | } 639 | 640 | location /media/ { 641 | try_files \$uri \$uri/ /get.php\$is_args\$args; 642 | 643 | location ~ ^/media/theme_customization/.*\.xml { 644 | deny all; 645 | } 646 | 647 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 648 | add_header Cache-Control \"public\"; 649 | add_header X-Frame-Options \"SAMEORIGIN\"; 650 | expires +1y; 651 | try_files \$uri \$uri/ /get.php\$is_args\$args; 652 | } 653 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 654 | add_header Cache-Control \"no-store\"; 655 | add_header X-Frame-Options \"SAMEORIGIN\"; 656 | expires off; 657 | try_files \$uri \$uri/ /get.php\$is_args\$args; 658 | } 659 | add_header X-Frame-Options \"SAMEORIGIN\"; 660 | } 661 | 662 | location /media/customer/ { 663 | deny all; 664 | } 665 | 666 | location /media/downloadable/ { 667 | deny all; 668 | } 669 | 670 | location /media/import/ { 671 | deny all; 672 | } 673 | 674 | location /media/custom_options/ { 675 | deny all; 676 | } 677 | 678 | location /errors/ { 679 | location ~* \.xml$ { 680 | deny all; 681 | } 682 | } 683 | 684 | # PHP entry point for main application 685 | location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { 686 | try_files \$uri =404; 687 | fastcgi_pass ${APP_PHP}:9001; 688 | fastcgi_param PHP_VALUE \"error_log=/home/public_html/${VHOST_ROOT_DIR}/var/log/php-error.log\"; 689 | fastcgi_buffers 16 16k; 690 | fastcgi_buffer_size 32k; 691 | 692 | fastcgi_param PHP_FLAG \"session.auto_start=off \\n suhosin.session.cryptua=off\"; 693 | fastcgi_param PHP_VALUE \"memory_limit=756M \\n max_execution_time=18000\"; 694 | fastcgi_read_timeout 600s; 695 | fastcgi_connect_timeout 600s; 696 | 697 | fastcgi_index index.php; 698 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 699 | include fastcgi_params; 700 | } 701 | 702 | gzip on; 703 | gzip_disable \"msie6\"; 704 | 705 | gzip_comp_level 6; 706 | gzip_min_length 1100; 707 | gzip_buffers 16 8k; 708 | gzip_proxied any; 709 | gzip_types 710 | text/plain 711 | text/css 712 | text/js 713 | text/xml 714 | text/javascript 715 | application/javascript 716 | application/x-javascript 717 | application/json 718 | application/xml 719 | application/xml+rss 720 | image/svg+xml; 721 | gzip_vary on; 722 | 723 | # Banned locations (only reached if the earlier PHP entry point regexes don't match) 724 | location ~* (\.php$|\.phtml$|\.htaccess$|\.git) { 725 | deny all; 726 | } 727 | } 728 | " > "$NGINX_SITES_CONF_D_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_FILE}" 729 | _arrow "${NGINX_SITES_CONF_D_FILE} file has been created." 730 | } 731 | 732 | function prepareWpVhostContent() 733 | { 734 | echo "server { 735 | listen 80; 736 | 737 | access_log /var/log/nginx/${VHOST_DOMAIN}.access.log; 738 | error_log /var/log/nginx/${VHOST_DOMAIN}.error.log; 739 | 740 | server_name ${VHOST_DOMAIN}; 741 | root /home/public_html/${VHOST_ROOT_DIR}; 742 | 743 | location / { 744 | index index.html index.php; 745 | try_files \$uri \$uri/ /index.php?\$args; 746 | } 747 | 748 | location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 749 | expires max; 750 | log_not_found off; 751 | } 752 | 753 | ## Disable .htaccess and other hidden files 754 | location ~ /\. { 755 | deny all; 756 | access_log off; 757 | log_not_found off; 758 | } 759 | 760 | location ~ \.php$ { 761 | if (!-e \$request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss 762 | 763 | # expires off; ## Do not cache dynamic content 764 | fastcgi_pass ${APP_PHP}:9001; 765 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 766 | include fastcgi_params; 767 | fastcgi_read_timeout 300; 768 | } 769 | }" > "$NGINX_SITES_CONF_D_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_FILE}" 770 | 771 | _arrow "${NGINX_SITES_CONF_D_FILE} file has been created." 772 | } 773 | 774 | function prepareLaravelVhostContent() 775 | { 776 | echo "server { 777 | listen 80; 778 | 779 | # Log files for Debugging 780 | access_log /var/log/nginx/${VHOST_DOMAIN}.access.log; 781 | error_log /var/log/nginx/${VHOST_DOMAIN}.error.log; 782 | 783 | # Web root Directory for Laravel project 784 | root /home/public_html/${VHOST_ROOT_DIR}; 785 | index index.php index.html index.htm; 786 | server_name ${VHOST_DOMAIN}; 787 | 788 | location / { 789 | try_files \$uri \$uri/ /index.php?\$query_string; 790 | } 791 | 792 | # PHP-FPM Configuration Nginx 793 | location ~ \.php$ { 794 | try_files \$uri =404; 795 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 796 | fastcgi_pass ${APP_PHP}:9001; 797 | fastcgi_index index.php; 798 | fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; 799 | include fastcgi_params; 800 | } 801 | }" > "$NGINX_SITES_CONF_D_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_FILE}" 802 | 803 | _arrow "${NGINX_SITES_CONF_D_FILE} file has been created." 804 | } 805 | 806 | function prepareDefaultVhostContent() 807 | { 808 | echo "server { 809 | listen 80; 810 | 811 | # Log files for Debugging 812 | access_log /var/log/nginx/${VHOST_DOMAIN}.access.log; 813 | error_log /var/log/nginx/${VHOST_DOMAIN}.error.log; 814 | 815 | # Web root Directory for Laravel project 816 | root /home/public_html/${VHOST_ROOT_DIR}; 817 | index index.html index.htm; 818 | server_name ${VHOST_DOMAIN}; 819 | 820 | location / { 821 | try_files \$uri \$uri/ =404; 822 | } 823 | }" > "$NGINX_SITES_CONF_D_FILE" || _die "Couldn't write to file: ${NGINX_SITES_CONF_D_FILE}" 824 | 825 | _arrow "${NGINX_SITES_CONF_D_FILE} file has been created." 826 | } 827 | 828 | function createEtcHostEntry() 829 | { 830 | local _etcHostLine="127.0.0.1 ${VHOST_DOMAIN}" 831 | if grep -Eq "127.0.0.1[[:space:]]+${VHOST_DOMAIN}" /etc/hosts; then 832 | _warning "Entry ${_etcHostLine} already exists in host file" 833 | else 834 | echo "Your system password has been requested to add an entry to /etc/hosts..." 835 | echo "127.0.0.1 ${VHOST_DOMAIN}" | sudo tee -a /etc/hosts || _die "Unable to write host to /etc/hosts" 836 | fi 837 | } 838 | 839 | function reloadNginx() 840 | { 841 | local _nginxTest=$(docker-compose exec nginx nginx -t) 842 | if [[ $? -eq 0 ]]; then 843 | docker-compose exec nginx nginx -s reload || _die "Nginx couldn't be reloaded." 844 | else 845 | echo "$_nginxTest" 846 | fi 847 | } 848 | 849 | function printSuccessMessage() 850 | { 851 | _success "Virtual host for Nginx has been successfully created!" 852 | 853 | echo "################################################################" 854 | echo "" 855 | echo " >> Domain : ${VHOST_DOMAIN}" 856 | echo " >> Application : ${APP_TYPE}" 857 | echo " >> PHP version : ${APP_PHP}" 858 | echo " >> Document Root : $(pwd)/sources/$VHOST_ROOT_DIR" 859 | echo " >> Nginx Config File : ${NGINX_SITES_CONF_D_FILE}" 860 | echo "" 861 | echo "################################################################" 862 | 863 | } 864 | 865 | ################################################################################ 866 | # Main 867 | ################################################################################ 868 | export LC_CTYPE=C 869 | export LANG=C 870 | 871 | DEBUG=0 872 | _debug set -x 873 | VERSION="1.2.0" 874 | 875 | function main() 876 | { 877 | # _checkRootUser 878 | checkCmdDependencies 879 | 880 | [[ $# -lt 1 ]] && _printUsage 881 | 882 | initDefaultArgs 883 | processArgs "$@" 884 | 885 | checkAppStackContainerRunning 886 | 887 | checkRootDir 888 | createVirtualHost 889 | 890 | printSuccessMessage 891 | exit 0 892 | } 893 | 894 | main "$@" 895 | 896 | _debug set +x 897 | --------------------------------------------------------------------------------