Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress domain mapping and config ? #12

Closed
jehanf opened this issue Mar 25, 2021 · 3 comments
Closed

WordPress domain mapping and config ? #12

jehanf opened this issue Mar 25, 2021 · 3 comments

Comments

@jehanf
Copy link

jehanf commented Mar 25, 2021

Hello from the home of the Baguette,

First of all, thanks for the work, looks really amazing.

I played a little with it while looking to migrate from a vagrant dev env to a docker one, and stamble upon something that looks more like an interrogation than a real issue.

I have a WordPress install configured as : my-site.localhost, which default to php7.4. Works great.
my-site.php72.localhost redirects automatically to my-site.localhost, which is not the wanted behavior, as I would like to try it on PHP7.2 without changing the WordPress options.

Is there a way to achieve that ?
Or should I define a virtual host dedicated to this particular install and simply change the handler for .php files to the version of WordPress I want to try (I'm not sure on how to do that without breaking that smart domain mapping) ?

Thanks !

@mcnamee
Copy link
Contributor

mcnamee commented Mar 25, 2021

Hi @jehanf
my-site.localhost, my-site.php72.localhost and my-site.php74.localhost - all should just work (mapping to the respective PHP version). If there's a redirect in place - it's likely to either be a .htaccess redirect (in your repo) or PHP (Wordpress) redirecting.

There's no redirects in place with the Docker environment.

@wireblue
Copy link
Member

wireblue commented Mar 25, 2021

As Matt suggested above, the simplest fix would be to change or remove the HTTP redirect that is happening. Most likely that means updating the site's URL in the wp_options table.

I wouldn't recommend it, but if you wanted to force Docker Dev to use a specific hostname and PHP combination you could always manually edit the Apache config. Perhaps find one of the Virtual Host blocks that is roughly what you'e after, copy-paste to the top of the file (so it takes precedence), and adjust it to suit.

Run docker-compose up -d once you've made the changes to activate them.

Example Config

# ...

# Custom PHP 7.2 website
<VirtualHost *:*>
    ServerName my-site.localhost                      # Only use these rules if your domain is found

    UseCanonicalName Off
    VirtualDocumentRoot /var/www/html/my-site         # Hard-code the site name/folder here

    <FilesMatch "\.php$">
      SetHandler proxy:fcgi://php72-fpm:9000          # Force it to use PHP 7.2 here
    </FilesMatch>
</VirtualHost>

# ...

@jehanf
Copy link
Author

jehanf commented Mar 26, 2021

Hi,

Thank you for the really quick and precise answers, they should do the trick.

@jehanf jehanf closed this as completed Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants