Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

358
Vistas
What is the best strategy to switch from localhost to another environment in wordpress?

I have a wordpress which works fine in localhost. Now we need to deploy it on our testing environment using docker. Deploy php files with docker was fine. I configured worpdress to use environment variables instead hardcoded values in wp-config.php.

docker run -d --name wordpress -it --rm -p 80:80 \
-e DB_HOST=10.10.10.10:3306 \
-e DB_USER=root \
-e DB_PASSWORD=secret \
-e DB_NAME=wordpress \
-e AUTH_KEY=$RANDOM_KEY \
-e SECURE_AUTH_KEY=$RANDOM_KEY \
-e NONCE_KEY=$RANDOM_KEY \
-e LOGGED_IN_KEY=$RANDOM_KEY \
-e AUTH_SALT=$RANDOM_KEY \
-e SECURE_AUTH_SALT=$RANDOM_KEY \
-e LOGGED_IN_SALT=$RANDOM_KEY \
-e NONCE_SALT=$RANDOM_KEY \
-e WP_DEBUG=true \
-e DISABLE_WP_CRON=true \
-e TZ=America/Lima wordpress:5.7.2

The problem is in the database deployment. I exported a dump from my localhost and imported to my new testing database. I saw that in the database dump, all the urls are hardcoded with localhost:

table wp_options
'siteurl','http://localhost'

table wp_posts
'you should go to <a href=\"http://localhost/wp-admin/...''

table wp_users
1,'admin','****','admin','admin@mail.com','http://localhost'

When I try to access to my testing domain, assets are being downloaded from localhost, ignoring my domain. I understand that this behavior is due to the hardcoded "localhost" in the exported db from developer machine.

errors

Research

  • WP on localhost to wordpress's domain

    • I which show another way to export the database from localhost.
  • WP_SITEURL and WP_HOME

    • I'm not a wordpress/php programmer, so I don't know if these variables can be dangerous.

Questions

  • What is the best strategy to move from localhost to another environment in wordpress for a devops pipeline in which all is handled with variables and human intervention is not required?
  • Would a simple string replacement (localhost > wordpress.testing.com) in the mysql dump work?
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The wordpress domain is controlled by setting 2 database options:

  • site_url
  • home

If you don't want to change it in database you can do it in wp-config.php

define('WP_SITEURL', $_ENV["USER"]);
define('WP_HOME', $_ENV["HOME"]);

You can make it read from an environment variable and then set that inside the container.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda