{"id":18459375,"url":"https://github.com/juniordiscart/local-wordpress-docker-https","last_synced_at":"2026-05-14T21:06:28.185Z","repository":{"id":206093996,"uuid":"714469228","full_name":"juniordiscart/local-wordpress-docker-https","owner":"juniordiscart","description":"A step-by-step guide to take your live WordpRess site into a local Docker environment, accessible over HTTPS.","archived":false,"fork":false,"pushed_at":"2023-11-09T08:15:24.000Z","size":2724,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T08:43:28.506Z","etag":null,"topics":["docker","https","local-development","wordpress"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juniordiscart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-04T23:51:33.000Z","updated_at":"2023-11-16T15:42:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7c122fc-92a4-4b13-8951-0326d5113967","html_url":"https://github.com/juniordiscart/local-wordpress-docker-https","commit_stats":null,"previous_names":["juniordiscart/local-wordpress-docker-https"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/juniordiscart/local-wordpress-docker-https","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2Flocal-wordpress-docker-https","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2Flocal-wordpress-docker-https/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2Flocal-wordpress-docker-https/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2Flocal-wordpress-docker-https/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juniordiscart","download_url":"https://codeload.github.com/juniordiscart/local-wordpress-docker-https/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juniordiscart%2Flocal-wordpress-docker-https/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33043297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","https","local-development","wordpress"],"created_at":"2024-11-06T08:22:56.221Z","updated_at":"2026-05-14T21:06:28.166Z","avatar_url":"https://github.com/juniordiscart.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Local WordPress development with HTTPS in Docker\n\nThis step-by-step process will guide you through taking your live website into a local Docker\ncontainer for local testing, including setting up the necessary certificates to test with HTTPS.\n\n## Pre-requisites\n\n1. [Docker](https://docs.docker.com/engine/install/)\n2. [Docker Compose](https://docs.docker.com/compose/install/)\n3. [Docker daemon](https://docs.docker.com/config/daemon/start/) should be running.\n4. [mkcert](https://github.com/FiloSottile/mkcert) and a local certificate authority should've already been installed\n   using `mkcert -install`.\n\n## Downloading website content\n\nThe first step is to have a local copy of your WordPress site's content. Most hosting providers provide you with FTP\naccess to your website's content. Check your control panel at your hosting provider to get access credentials.\nIn this example, we're using Filezilla to access and download the content.\n\n![](./img/FTPCopy.png)\n\nWe're interested in the following items:\n\n* The `wp-content` folder. This contains all images, video's, etc.\n* The `wp-config.php` file. This contains the configuration variables of your WordPress website.\n* If you have other custom changes made to the WordPress installation, you may download the relevant files as well.\n\nDepending on your site's size, this may take a while.\n\nYour hosting provider may offer alternative ways to get access, but the main point is to download the above-outlined\nfolder and file.\n\n## Downloading database content\n\nThe next step is to obtain a copy of your WordPress database. Here, again, your hosting provider usually offers access\nto your site's database through the control panel, either by providing login-details to the database server, or a button\nto directly connect you to it with `phpMyAdmin`.\nHere, the `phpMyAdmin` interface is used. Look for the database that represents the WordPress installation. The\ndatabase of interest is usually called `wordpress`, or the name of your site. If you're in doubt which one to select,\ncheck the tables names. WordPress tables usually have a specific prefix, e.g. `www_` or `wp_`.\n\n1. Click on the database root so that the database is properly selected.\n2. Navigate to the Export tab.\n3. Optionally, tweak some settings if you want to customise the export.\n4. Press the Export button.\n\n![](./img/ExportPMA.png)\n\nYour download will be a large `.sql` file.\n\nIf you were provided with remote access details to your database, use your favorite database management tool,\ne.g. `Datagrip` or `DBeaver` to extract the WordPress data.\n\n## Setting up local folder structure\n\nOn your system, on a location where you want the local copy of your WordPress website to reside, create a new folder,\ne.g. `MyWebsite`, and set up the file structure as shown in the diagram below. Copy the `wp-config.php` file and\nthe `wp-content` folder in the `Wordpress` folder. Any other files or folders in the diagram are just empty ones for\nnow.\n\n```\nMyWebsite\n│   docker-compose.yml\n│   default-ssl.conf\n│   \n└───Wordpress\n│   │   wp-config.php -\u003e This is the Wordpress file you downloaded earlier.\n│   │\n│   └───wp-content -\u003e This is the Wordpress folder you downloaded earlier.\n│       │   ...\n│   \n└───certs -\u003e Empty folder.\n```\n\n## Docker compose\n\nOpen the `docker-compose.yml` file. This file will set up a `phpMyAdmin` container for database management.\nIf you prefer to use a different tool, such as `DataGrip` or `DBeaver`, you can leave out the `phpMyAdmin` service from\nthe Docker compose file, and use your preferred tool later on.\n\n```Docker\nversion: '3.9'\n\nservices:\n  db:\n    image: mysql:8.0\n    container_name: \"db\"\n    volumes:\n      - db_data:/var/lib/mysql\n    restart: always\n    ports:\n      - \"3306:3306\"\n    environment:\n      MYSQL_DATABASE: wordpress\n      MYSQL_ROOT_PASSWORD: somewordpress    # Change this if you want.\n      MYSQL_PASSWORD: wordpress             # Change this if you want.\n      MYSQL_USER: wordpress                 # Change this if you want.\n      \n  phpmyadmin:\n    image: phpmyadmin/phpmyadmin\n    container_name: pma\n    links:\n      - db\n    environment:\n      PMA_HOST: db\n      PMA_PORT: 3306\n      PMA_ARBITRARY: 1\n      UPLOAD_LIMIT: 50M    # Change this if your database export is larger.\n    restart: always\n    ports:\n      - 8080:80\n\nvolumes:\n  db_data:\n```\n\nIn your terminal, navigate to the `MyWebsite` folder and run the following command:\n\n```Shell\ndocker compose up -d\n```\n\nThis will download the services and its dependencies. It may take some time the first time you run it. This will set up\na `MySQL` database and a `phpMyAdmin` instance, which should be available in your browser after it has done downloading\nand starting the containers.\nNavigate to the following address in your web browser: `localhost:8080`. The compose process will also have\ncreated a `wordpress` database in your `MySQL` instance.\n\nTry to connect using the credentials you've set up in the compose file.\n\n![](./img/phpMyAdminSignin.png)\n\nIf you're using a different database management tool, try to see if you can connect to the `MySQL` instance.\n\nNote here that you should connect using `localhost` rather than using the name `db` (as shown above for `phpMyAdmin`),\nbecause the name `db` is resolved by the `phpMyAdmin` container inside the internal Docker network. For your database\nmanagement program, port `3306` is already exposed the host system.\n\n![](./img/DataGripConnectionTest.png)\n\n## Uploading WordPress database content\n\nThe following steps will be for when you're using `phpMyAdmin`. If you use a different database management tool, these\nsteps should be a general guideline of what you should do.\n\n1. Sign in to your database with your root credentials as set up in the Docker compose file.\n2. Select the `wordpress` database, in the column on the left side, so that this database is active and selected.\n3. Go to the Import tab.\n4. Browse to the `.sql` file you got earlier from your database export.\n5. Optionally, set up different import options. The defaults should be fine if your export was also left to default.\n6. Import the database. Depending on the size of your file, this may take some time.\n\n![](./img/phpMyAdminImportDatabase.png)\n\n## Setting up local site address and certificates\n\nWith the WordPress site data imported in the database, some changes to the data have to be made to reflect that\nit's no longer running on the server of your hosting provider. Otherwise, some plugins or processes may redirect you\nback to the live site.\n\nTo do this, you first have to decide on a local name for your site, e.g. if your live site was called `mywebsite.com`,\nconsider for this local version `mywebsite.dev`, or `mywebsite.test`. Some plugins,\nlike [Slider Revolution](https://www.sliderrevolution.com/faq/licensing-information-for-staging-sites-and-localhost/),\nwill accept the same license key if your website address has a 'development' extension.\n\nWith `phpMyAdmin` or your preferred database management tool open, set the `wordpress` database active and selected,\nopen up the query console, and enter the following queries:\n\n```SQL\nUPDATE www_options SET option_value = replace(option_value, 'mywebsite.com', 'mywebsite.dev') WHERE option_name = 'home' OR option_name = 'siteurl';\n  \nUPDATE www_posts SET post_content = replace(post_content, 'mywebsite.com', 'mywebsite.dev');\n  \nUPDATE www_postmeta SET meta_value = replace(meta_value,'mywebsite.com','mywebsite.dev');\n```\n\nThis will update the data in the tables to refer to your local website, rather than the live version.\n\n**Note:** pay attention to the site addresses and the `www_` prefix for the tables. The prefix is one that may differ\nper WordPress install. Another common prefix is `wp_`. Update this query to reflect the prefix being used in your\nWordPress installation.\n\nWith the database all set up, the appropriate certificates for HTTPS can be created. Navigate to the `certs` folder in\nyour project's root directory, and enter the following command:\n\n```Shell\nmkcert mywebsite.dev\n```\n\nThis will create a certificate and a key file for your local site.\n\nNext, the `hosts` file on your system needs to be edited to resolve the site address to the local ip address.\nThis process differs per platform:\n\n### Windows\n\n1. Run notepad as administrator.\n2. Open the `hosts` file at `C:\\Windows\\System32\\drivers\\etc`.\n3. Add the following line at the end of the file: `127.0.0.1 mywebsite.dev`\n4. Save the file and close notepad.\n\n### macOS and Linux\n\n1. In your terminal, enter: `sudo nano /etc/hosts`.\n2. Enter your password.\n3. At the end of the file, add: `127.0.0.1 mywebsite.dev`.\n4. Press `Ctrl + O` to save.\n5. Press `Ctrl + X` to exit.\n\nFinally, open the `default-ssl.conf` file in your project's root directory, set its contents to the following,\nand edit it to match your local site address:\n\n```\n\u003cVirtualHost *:443\u003e\n  DocumentRoot /var/www/html\n  ErrorLog ${APACHE_LOG_DIR}/error.log\n  CustomLog ${APACHE_LOG_DIR}/access.log combined\n  SSLEngine on\n  ServerName mywebsite.dev\n  SSLCertificateFile  /etc/ssl/certs/mywebsite.dev.pem\n  SSLCertificateKeyFile /etc/ssl/certs/mywebsite.dev-key.pem\n  \u003cFilesMatch \"\\.(cgi|shtml|phtml|php)$\"\u003e\n          SSLOptions +StdEnvVars\n  \u003c/FilesMatch\u003e\n  \u003cDirectory /usr/lib/cgi-bin\u003e\n          SSLOptions +StdEnvVars\n  \u003c/Directory\u003e\n\u003c/VirtualHost\u003e\n```\n\nThis is the configuration for the underlying Apache webserver that will be used in your WordPress container, and will\ndirect it to where it should look for the certificate and key files to properly handle a secure connection.\n\n## Setting up WordPress container\n\nOpen the `wp-config.php` file, the one you downloaded in the very first step. Double check that the following parameters\nin the file match in value to those set up for the `db` service in your `docker-compose.yml` file:\n\n* `DB_HOST` should refer to the name of the host the MySQL database is running on: `db`.\n* `DB_NAME` versus `MYSQL_DATABASE`.\n* `DB_USER` versus `MYSQL_USER`.\n* `DB_PASSWORD` versus `MYSQL_PASSWORD`.\n\nIn the `wp-config.php` file, you should find a variable named `$table_prefix` in there that sets the table prefix.\nMake sure this corresponds to a value that you expect as was used in updating the site address for local use,\ne.g. `www_` or `wp_`.\n\nNow, with the `docker-compose.yml` file open, add WordPress to `services`:\n\n```Docker\n  wordpress:\n    depends_on:\n      - db\n    image: wordpress:latest     # Either use the latest version, or the version of your live site.\n    container_name: \"wordpress\"\n    ports:\n      - \"443:443\"\n    restart: always\n    environment:\n      WORDPRESS_DB_HOST: db:3306\n    working_dir: /var/www/html\n    volumes:\n      - ./Wordpress/wp-content:/var/www/html/wp-content\n      - ./Wordpress/wp-config.php:/var/www/html/wp-config.php\n      - ./certs:/etc/ssl/certs:ro\n      - ./default-ssl.conf:/etc/apache2/sites-available/default-ssl.conf\n```\n\nWith WordPress added to the compose file, rebuild and start the WordPress container:\n\n```Shell\ndocker compose up --build -d\n```\n\nIf your terminal is not back already in your project's root directory, navigate to it now.\nCopy out the `docker-entrypoint.sh` file from the `wordpress` container, so that it can be modified:\n\n```Shell\ndocker cp wordpress:/usr/local/bin/docker-entrypoint.sh docker-entrypoint.sh\n```\n\nOpen this file in your text editor, and replace the final line of the file with the following:\n\n```Shell\na2enmod ssl\na2ensite default-ssl\nservice apache2 restart\nservice apache2 stop\nexec \"$@\"\n```\n\nThis will enable the `ssl` module in the Apache webserver and will direct it to use the configuration that\nwas set up earlier.\n\nSave and close the file. Open the Docker compose file again and add the following volume mapping for the `wordpress`\nservice:\n\n```Docker\n- ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh:ro\n```\n\nThat should be all! Now, rebuild again and your website should be up and running! A full copy of\nthe `docker-compose.yml` file can be found [here](./docker-compose.yml).\n\n```Shell\ndocker compose up --build -d\n```\n\nIn your web browser, navigate to your local webpage and notice that it's using HTTPS. Success!\n\n![](./img/MyWebsiteHttpConfirmed.png)\n\n## Troubleshooting\n\nSome issues might pop up because your site is now running on a different address than it was before.\n\n### Slow loading\n\nYour hosting provider may have set up some PHP parameters that are optimised for loading web pages. You can adjust\nseveral parameters yourself by adding additional configuration files and mapping them to the WordPress container's\nPHP config directory. Some personal settings I have applied are included below:\n\n* A `wordpress.ini` file:\n\n```Ini\nmax_input_vars = 5000\nmax_execution_time = 300\npost_max_size = 50M\nupload_max_filesize = 50M\n```\n\n* A `uploads.ini` file:\n\n```Ini\nfile_uploads = On\nmemory_limit = 64M\nupload_max_filesize = 64M\npost_max_size = 64M\nmax_execution_time = 600\n```\n\nMap the files in the `wordpress` service's volumes:\n\n```Docker\n- ./Wordpress/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini\n- ./Wordpress/wordpress.ini:/usr/local/etc/php/conf.d/wordpress.ini\n```\n\nRebuild, and restart your containers.\n\n### Signing in\n\nNote that signing in through `wp-admin` still needs to be done using the original e-mail addresses. If your site's\nadministrators signed up with addresses such as `user@mywebsite.com`, those addresses should've remained the same.\nIn [this section](#setting-up-local-site-address-and-certificates), only content links, meta-data and the site's url\nwere changed. User credentials and login information should be untouched.\n\n### Database connection error\n\nIn some cases, plugins and themes may store data that references to the live site's address still, which can show up as\ndatabase connection errors. This can get fixed by disabling all plugins through updating a database value. You can enter\nthe following SQL query (note the table prefix again):\n\n```SQL\nUPDATE www_options\nSET option_value = \"a:0:{}\"\nWHERE option_name = \"active_plugins\";\n```\n\nGoing into the plugins section of your administrator page, you can start activating them again one by one, to see if\nany particular plugin is causing trouble. You may have to delve into its stored data to see if you need to update\nsome additional values or settings.\n\n### WordPress asks for FTP credentials\n\nBy default, WordPress will try to work using FTP to manage files on the host system. This is cumbersome and not\nefficient. To let WordPress use the file system directly, add the following to your `wp-config.php` file:\n\n```PHP\ndefine('FS_METHOD', 'direct');\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniordiscart%2Flocal-wordpress-docker-https","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuniordiscart%2Flocal-wordpress-docker-https","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniordiscart%2Flocal-wordpress-docker-https/lists"}