Difference between revisions of "Wordpress"

From ElectroDragon
Jump to navigation Jump to search
Line 111: Line 111:
* https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose
* https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose
* https://buddy.works/guides/wordpress-docker-kubernetes-part-1
* https://buddy.works/guides/wordpress-docker-kubernetes-part-1
[[category: Website]]
[[category: Web]]

Latest revision as of 10:49, 1 December 2019

  • tar -czvf blog.tar.gz /srv/www/idehe.com
  • tar -xzvf blog.tar.gz
  • mysqldump -u root -p blogdb> blogdb.sql
  • wget idehe.com/blogdb.sql
  • wget idehe.com/blog.tar.gz


Docker run by step


  • docker run --name wp-mysql -e MYSQL_ROOT_PASSWORD=test -d -p 3306:3306 mysql:5.7
  • docker run --name wp-mysql -e MYSQL_ROOT_PASSWORD=test -d -p 3306:3306 -v /root/docker-wp/web3:/test mysql:5.7
  • docker exec -it wp-mysql bin/bash
  • mysql -u root -p
  • create database blogdb;
  • use blogdb;
  • source /test/blogdb.sql

wordpress link to mysql

  • docker run -d --name wp --link wp-mysql:mysql -p 80:80 wordpress
  • docker run -d --name wp --link wp-mysql:mysql -p 80:80 -v /root/docker-wp/web3/wp/wp:/var/www/html wordpress
  • change wp-config.php later, change db name to blogdb

maybe update url in wp-config,php


For cerbot

Add config is docker-compose.yml

  • add port:
     - "80:80"
     - "443:443"
  • Add volumes:
     - /web/wp:/var/www/html
     - ./nginx-conf:/etc/nginx/conf.d
     - /web/ssl:/etc/letsencrypt
  • Add service certbot
     - webserver
   image: certbot/certbot
   container_name: ssl
     - /web/ssl:/etc/letsencrypt
     - /web/wp:/var/www/html
   #command: certonly --webroot --webroot-path=/var/www/html --email hechaogm@gmail.com --agree-tos --no-eff-email --staging -d idehe.com -d www.idehe.com
   command: certonly --webroot --webroot-path=/var/www/html --email hechaogm@gmail.com --agree-tos --no-eff-email --force-renewal -d idehe.com -d www.idehe.com
  • In the two command line, if the certbot already got, use second line, setup email address and domain
  • after <docker-compose up -d --force-recreate>, try<docker-compose ps>, you should get following, certbot service state should be exit 0, if not then should check logs
  • After first trial, the certbot will be obtained, and change docker-compose.yml config file command --staging to --force-renewal
  Name                 Command               State           Ports       
certbot     certbot certonly --webroot ...   Exit 0                      
db          docker-entrypoint.sh --def ...   Up       3306/tcp, 33060/tcp
webserver   nginx -g daemon off;             Up>80/tcp 
wordpress   docker-entrypoint.sh php-fpm     Up       9000/tcp
  • use new nginx config file
  • correct output of cerbot service, use CMD <docker-compose logs cerbot> to check
Recreating certbot ... done
Attaching to certbot
certbot      | Saving debug log to /var/log/letsencrypt/letsencrypt.log
certbot      | Plugins selected: Authenticator webroot, Installer None
certbot      | Renewing an existing certificate
certbot      | Performing the following challenges:
certbot      | http-01 challenge for example.com
certbot      | http-01 challenge for www.example.com
certbot      | Using the webroot path /var/www/html for all unmatched domains.
certbot      | Waiting for verification...
certbot      | Cleaning up challenges
certbot      | IMPORTANT NOTES:
certbot      |  - Congratulations! Your certificate and chain have been saved at:
certbot      |    /etc/letsencrypt/live/example.com/fullchain.pem
certbot      |    Your key file has been saved at:
certbot      |    /etc/letsencrypt/live/example.com/privkey.pem
certbot      |    Your cert will expire on 2019-08-08. To obtain a new or tweaked
certbot      |    version of this certificate in the future, simply run certbot
certbot      |    again. To non-interactively renew *all* of your certificates, run
certbot      |    "certbot renew"
certbot      |  - Your account credentials have been saved in your Certbot
certbot      |    configuration directory at /etc/letsencrypt. You should make a
certbot      |    secure backup of this folder now. This configuration directory will
certbot      |    also contain certificates and private keys obtained by Certbot so
certbot      |    making regular backups of this folder is ideal.
certbot      |  - If you like Certbot, please consider supporting our work by:
certbot      | 
certbot      |    Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
certbot      |    Donating to EFF:                    https://eff.org/donate-le
certbot      | 
certbot exited with code 0


Auto renewal cerbot

  • setup ssl_renew.sh script
  • add crontab -e job
  • 0 12 * * * /docker/wp/2web/ssl_renew.sh >> /var/log/cron.log 2>&1


can not update plugins

  • To add root rights to docker-compose (not working):
privileged: true
  • Set folder right
chmod -R 777 wp-content