Need Advice? CALL: +61 417949565

Riksi - web design and development

  • Home
  • ABOUT US
  • OUR WORK
  • BLOG
  • CONTACT US
  • Home
  • BLOG
  • Web developing
  • MySQL
  • WordPress on multi-environment

WordPress on multi-environment

WordPress on multi-environment

Running the same WordPress code with all credentials on multi-environment (like local, staging & live site) is not an easy job.

The following code will make it easy. Its added multi config file to WordPress and can save different credential with no conflict.

Get started

First download the following code and then add it to the root of your WordPress site.
https://github.com/studio24/wordpress-multi-env-config

Modify the “wp-config.env.php” file and add each environment URL to it.

Finally create a wp-config.”environment”.php file and add the database credential.(Replace environment with local, staging or production)

How it works

The system detects what environment the current website is in and loads the relevant config file for that environment.

By default the environment is defined by the hostname, though you can also set this as an environment variable.

Config files are then loaded according to the current environment. There is support for loading a local config file for sensitive data, which is intended to not be committed to version control.

Example usage:

You need to update the wp-config.env.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
 
$env = [
    'production'  => [
        'domain' => 'domain.com',
        'path'   => '',
        'ssl'    => false,
    ],
    'staging'     => [
        'domain' => 'staging.domain.com',
        'path'   => '',
        'ssl'    => false,
    ],
    'development' => [
        'domain' => 'domain.local',
        'path'   => '',
        'ssl'    => false,
    ],
];
 
 

Nick
Saturday, 02 February 2019 / Published in MySQL, Web developing, Wordpress

What you can read next

Adding ‘blog’ to URL
Add Password Protection to any Folder with .htaccess file
Using WordPress Functionality outside wp

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archive

  • General
    • Smart Home
  • Web developing
    • command line
    • CSS
    • General
    • git
    • Javascript
    • Laravel
    • Magento
    • MySQL
    • PHP
    • Security
    • Shopify
    • Wordpress

Recent Posts

  • Install HomeAssistant on Raspberry pi

  • Shopify ERR_INVALID_ARG_TYPE Error

Riksi

Riksi is a creative, professional & cutting-edge custom web design and development company.

HERE TO HELP

  • BLOG
  • Contact Us
  • Our Work
  • About Us

New on Blog

  • Install HomeAssistant on Raspberry pi

    To install it, We need to connect the SD card t...
  • Shopify ERR_INVALID_ARG_TYPE Error

    fix the Internal Server Error occurred while in...

GET IN TOUCH

T: (+61) 417 949 565
Email: [email protected]

Contact Us
Fill out the form and our team will be in touch with you promptly. Thank you for your interest!

AU & NZ
T: (+613) 9014 9495
T: (+61) 417 949 565
Email: [email protected]


US & Canada
Email: [email protected]

NAME

EMAIL

PROJECT TYPE
PROJECT BUDGET

MESSAGE

Could not authenticate you.

Whats on Instagram

Loading...

Tags

.htaccess calculation cherry pick composer content css deployer documentation error flex general knowledge get started git git stash hack javascript log mysql package password php PHP Trick replace scss shopify sidebar ssh symlink sync trick ubuntu windows 10 wordpress trick wp
  • GET SOCIAL
Riksi - web design and development

© 2020 All rights reserved. Riksi.com.

TOP