Last active
July 31, 2018 10:33
-
-
Save rutcreate/dd7bc524f9439d221d60c51435396f81 to your computer and use it in GitHub Desktop.
Docker WordPress with NGINX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
root /var/www/html; | |
index index.php index.html; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
fastcgi_pass wordpress:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param REMOTE_ADDR $http_x_real_ip; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
services: | |
nginx: | |
image: nginx:1.15-alpine | |
volumes: | |
- ./html:/var/www/html | |
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro | |
ports: | |
- 8888:80 | |
wordpress: | |
image: wordpress:4-php7.2-fpm | |
volumes: | |
- ./html:/var/www/html | |
environment: | |
WORDPRESS_DB_PASSWORD: example | |
mysql: | |
image: mysql:5.7 | |
volumes: | |
- db_data:/var/lib/mysql | |
environment: | |
MYSQL_ROOT_PASSWORD: example | |
elasticsearch: | |
image: elasticsearch:5.3-alpine | |
environment: | |
- cluster.name=docker-cluster | |
- bootstrap.memory_lock=true | |
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | |
ulimits: | |
memlock: | |
soft: -1 | |
hard: -1 | |
volumes: | |
- es_data:/usr/share/elasticsearch/data | |
deploy: | |
resources: | |
limits: | |
memory: 1g | |
reservations: | |
memory: 1000m | |
volumes: | |
db_data: | |
es_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 65; | |
#gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
cd <your-project-directory>
docker-compose.yml
to your project directory.$
mkdir html nginx
at the same level ofdocker-compose.yml
default.conf
andnginx.conf
to<your-project-directory>/nginx/
Your project structure should be look like this:
<your-project-directory>
--
docker-compose.yml
--
html
--
nginx
----
default.conf
----
nginx.conf
Run Docker
Docker
docker-compose up -d
(for daemon mode) ordocker-compose up
.docker stack deploy -c docker-compose.yml <project-name>