diff --git a/devops/Dockerfile b/devops/Dockerfile new file mode 100644 index 0000000..5f70b64 --- /dev/null +++ b/devops/Dockerfile @@ -0,0 +1,30 @@ +FROM wordpress:4.9-fpm + +ENV TMP /tmp/nginx-php/ + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng-dev \ + libfreetype6-dev \ + && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr/include \ + && docker-php-ext-install gd + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- \ + --filename=composer \ + --install-dir=/usr/local/bin && \ + echo "alias composer='composer'" >> /root/.bashrc && \ + composer + +# php configs +COPY www.conf /usr/local/etc/php-fpm.d/www.conf +COPY docker-php.ini /usr/local/etc/php/conf.d/docker-php.ini + +RUN apt-get install -y nginx + +# nginx configs +COPY nginx /etc/nginx + +WORKDIR /var/www + +EXPOSE 80 diff --git a/devops/docker-compose.yml b/devops/docker-compose.yml deleted file mode 100644 index 9c5c8b3..0000000 --- a/devops/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - mysql: - image: mysql:5.7 - volumes: - - "./storage/mysql:/var/lib/mysql" - - "./storage/logs/mysql:/var/log/mysql" - environment: - - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-pass4dev} - - MYSQL_DATABASE=${MYSQL_DATABASE:-db4dev} - - MYSQL_USER=${MYSQL_USER:-user4dev} - - MYSQL_PASSWORD=${MYSQL_PASSWORD:-pass4dev} - restart: always - - php_fpm: - build: - context: ./php_fpm - depends_on: - - mysql - volumes: - - "../htdocs/wp-content:/var/www/html/wp-content" - - "../htdocs/wp-config.php:/var/www/html/wp-config.php" - - "htdocs:/var/www/html" - environment: - - DB_NAME=${DB_NAME:-db4dev} - - DB_USER=${DB_USER:-user4dev} - - DB_PASSWORD=${DB_PASSWORD:-pass4dev} - - DB_HOST=${DB_HOST:-mysql} - restart: always - - nginx: - image: nginx:1.15-alpine - depends_on: - - php_fpm - volumes: - - "./nginx/nginx.conf:/etc/nginx/nginx.conf:ro" - - "./storage/logs/nginx:/var/log/nginx" - - "../htdocs/wp-content:/var/www/html/wp-content" - - "../htdocs/wp-config.php:/var/www/html/wp-config.php:ro" - - "htdocs:/var/www/html" - restart: always - -volumes: - htdocs: \ No newline at end of file diff --git a/devops/docker-php.ini b/devops/docker-php.ini new file mode 100644 index 0000000..66b8f68 --- /dev/null +++ b/devops/docker-php.ini @@ -0,0 +1 @@ +memory_limit = 512M \ No newline at end of file diff --git a/devops/nginx/conf.d/default.conf b/devops/nginx/conf.d/default.conf new file mode 100644 index 0000000..69beec5 --- /dev/null +++ b/devops/nginx/conf.d/default.conf @@ -0,0 +1,3 @@ +upstream php-upstream { + server 127.0.0.1:9000; +} \ No newline at end of file diff --git a/devops/nginx/env/dev/lawcarta_wordpress.conf b/devops/nginx/env/dev/lawcarta_wordpress.conf deleted file mode 100644 index 33b9ed2..0000000 --- a/devops/nginx/env/dev/lawcarta_wordpress.conf +++ /dev/null @@ -1,70 +0,0 @@ -server { - - server_name dev1.lawcarta.com dev1.livecarta.com; - - root /var/www/WordPress/htdocs/; - index index.html index.php; - - error_log /var/log/nginx/wordpress-error.log; - - if (!-e $request_filename) { - rewrite /wp-admin$ $scheme://$host$uri/ permanent; - rewrite ^(/[^/]+)?(/wp-.*) $2 last; - rewrite ^(/[^/]+)?(/.*\.php) $2 last; - } - - location / { - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - include fastcgi.conf; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_pass unix:/run/php/php7.1-fpm.sock; - fastcgi_read_timeout 300; - } - - location ~ /\.ht { - deny all; - } - - listen 443 ssl; # managed by Certbot - ssl_certificate /etc/letsencrypt/live/dev1.lawcarta.com/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/dev1.lawcarta.com/privkey.pem; # managed by Certbot - include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot - - - if ($scheme != "https") { - return 301 https://$host$request_uri; - } # managed by Certbot - - - - - -} - -server { - if ($host = dev1.livecarta.com) { - return 301 https://$host$request_uri; - } # managed by Certbot - - - if ($host = dev1.lawcarta.com) { - return 301 https://$host$request_uri; - } # managed by Certbot - - - listen 80; - listen [::]:80; - - server_name dev1.lawcarta.com dev1.livecarta.com; - return 404; # managed by Certbot - - - - -} diff --git a/devops/nginx/nginx.conf b/devops/nginx/nginx.conf index b766974..5a4d29e 100644 --- a/devops/nginx/nginx.conf +++ b/devops/nginx/nginx.conf @@ -1,5 +1,5 @@ -user nginx; +user www-data; worker_processes 1; error_log /var/log/nginx/error.log warn; @@ -10,7 +10,6 @@ events { worker_connections 1024; } - http { include /etc/nginx/mime.types; default_type application/octet-stream; @@ -30,34 +29,6 @@ http { client_max_body_size 10m; - server { - listen 80; - server_name lawcarta.loc livecarta.loc; - - root /var/www/html; - index index.php; - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - if (!-e $request_filename) { - rewrite /wp-admin$ $scheme://$host$uri/ permanent; - rewrite ^(/[^/]+)?(/wp-.*) $2 last; - rewrite ^(/[^/]+)?(/.*\.php) $2 last; - } - - location / { - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - #fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_pass php_fpm:9000; - } - } -} + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-available/*.conf; +} \ No newline at end of file diff --git a/devops/nginx/sites-available/default.conf b/devops/nginx/sites-available/default.conf new file mode 100644 index 0000000..b7f871c --- /dev/null +++ b/devops/nginx/sites-available/default.conf @@ -0,0 +1,30 @@ +server { + listen 80; + server_name lawcarta.loc livecarta.loc localhost; + + root /var/www; + index index.php; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + if (!-e $request_filename) { + rewrite /wp-admin$ $scheme://$host$uri/ permanent; + rewrite ^(/[^/]+)?(/wp-.*) $2 last; + rewrite ^(/[^/]+)?(/.*\.php) $2 last; + } + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + #fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_pass localhost:9000; + } +} \ No newline at end of file diff --git a/devops/php_fpm/Dockerfile b/devops/php_fpm/Dockerfile deleted file mode 100644 index 88cd438..0000000 --- a/devops/php_fpm/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM wordpress:4.9-fpm - -RUN apt-get update && apt-get install -y --no-install-recommends \ - libjpeg-dev \ - libpng-dev \ - libfreetype6-dev \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr/include \ - && docker-php-ext-install gd diff --git a/devops/www.conf b/devops/www.conf new file mode 100644 index 0000000..8d11bb6 --- /dev/null +++ b/devops/www.conf @@ -0,0 +1,10 @@ +[www] + +user = www-data +group = www-data + +pm = dynamic +pm.max_children = 50 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 \ No newline at end of file diff --git a/environments/dev_amazon/domain_db_fix.sql b/environments/dev_amazon/domain_db_fix.sql new file mode 100644 index 0000000..7b18167 --- /dev/null +++ b/environments/dev_amazon/domain_db_fix.sql @@ -0,0 +1,14 @@ +######FOR TEST DEV ENV + +update wp_options set option_value = "https://doc-dev.lawcarta.com" where option_id = 1 limit 1; +update wp_options set option_value = "https://doc-dev.lawcarta.com" where option_id = 2 limit 1; + +update wp_2_options set option_value = "https://doc-dev.livecarta.com" where option_id = 1 limit 1; +update wp_2_options set option_value = "https://doc-dev.lawcarta.com/livecarta" where option_id = 2 limit 1; + +update wp_blogs set domain = "doc-dev.lawcarta.com" where blog_id = 1 limit 1; +update wp_blogs set domain = "doc-dev.lawcarta.com" where blog_id = 2 limit 1; + +update wp_domain_mapping set domain = "doc-dev.livecarta.com" where blog_id = 2 limit 1; + +update wp_site set domain = "doc-dev.lawcarta.com" where id =1 limit 1; diff --git a/environments/dev_amazon/robots.txt b/environments/dev_amazon/robots.txt new file mode 100644 index 0000000..77470cb --- /dev/null +++ b/environments/dev_amazon/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file diff --git a/environments/dev_amazon/wp-config-local.php b/environments/dev_amazon/wp-config-local.php new file mode 100644 index 0000000..6b8ce6f --- /dev/null +++ b/environments/dev_amazon/wp-config-local.php @@ -0,0 +1,21 @@ +