1. Create a data folder mkdir / the Data , all files are in this configuration.
2, installation docker, see: HTTPS: // www.cnblogs.com/yanglei-xyz/p/install_docker.html
3, configure mysql:
3-1, create a container
mkdir /data/mysql
cd /data/mysql
docker run -p 3306:3306 --name mysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=yourpassword -m 512m --memory-swap -1 --oom-kill-disable -d mysql:5.7
Description:
- -p 3306: 3306 Port Mapping
- --name mysql custom container name
- -e MYSQL_ROOT_PASSWORD = yourpassword configuration mysql default password
- the swap-512M --memory -m - . 1 configuration allows maximum memory and swap space of -1 indicates unlimited
- --oom- the kill-kill automatically disable to prevent insufficient system memory process
3-2, is provided to allow external network access mysql
Exec Docker - IT MySQL bash # to enter the interior of the container MySQL -u root - the p-# to enter mysql, password is the password you just set Grant All privileges ON * * to. ' root ' @ ' % ' ; # allow remote login flush privileges; # permission to refresh exit # exit mysql exit # exit container # restart mysql container docker restart mysql
4. Configure WordPress:
mkdir /data/wordpress cd /data/wordpress docker run --name wordpress -p 8002:80 -e WORDPRESS_DB_HOST=172.17.0.1:3306 -v /data/wordpress/www/html/:/var/www/html/ -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=yourpassword -m 512m --memory-swap -1 --oom-kill-disable -d wordpress
Description:
-
-p 8002: 80 map the host port 8002 to port 80 of the container
-
WORDPRESS_DB_HOST = -e 172.17. 0.1: 3306 using external mysql
-
-e WORDPRESS_DB_USER = root -e WORDPRESS_DB_PASSWORD = yourpassword external mysql user name and password
-
-v / data / wordpress / www / html /: / var / www / html / folder mapping program WordPress
- the swap-512M --memory -m - . 1 configuration allows maximum memory and swap space of -1 indicates unlimited
- --oom- the kill-kill automatically disable to prevent insufficient system memory process
5, configure nginx:
docker run -p 80:80 -p 443:443 --name nginx -v /data/nginx/www:/www -v /data/nginx/conf.d:/etc/nginx/conf.d -v /data/nginx/cert:/etc/nginx/cert -v /data/nginx/logs:/wwwlogs -m 64m --memory-swap -1 --oom-kill-disable -d nginx
Description:
-
-v /data/nginx/conf.d:/etc/nginx/conf.d mapping configuration file
-
-v / data / nginx / cert: / etc / nginx / cert certificate mapping file
Certificates can select the certificate to use Ali cloud-free year, due to apply for one on the line.
Download nginx certificate and upload it to / data / nginx / cert directory
Configure a reverse proxy:
cd / data / nginx / conf.d saw home.conf
server { listen 80; server_name www.yoursite.com; return 301 https://www.yoursite.com$request_uri; #自动跳转http到https } server { listen 443; server_name www.yoursite.com; ssl on; ssl_certificate /etc/nginx/cert/3666270_yanglei.xyz.pem; ssl_certificate_key /etc/nginx/cert/3666270_yanglei.xyz.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; #获取真实ip proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://172.17.0.1:8002; client_max_body_size 10240m; } }
Save the restart nginx: Docker restart nginx
6, modify WordPress:
Once you've configured found it impossible to load the js and css, the solution is as follows:
Entering program directory WordPress CD / Data / WordPress / WWW / HTML , configuration changes VI WP-the config.php
Behind the increase in the first paragraph of the comment the following code:
$_SERVER['HTTPS'] = 'on'; define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);
Finished modifying Figure:
After the visit WordPress and install it, and have the whole station https, do not need to do any additional configuration. If you install good before modifying WordPress, so I do not know and then not diverted.