Coder Social home page Coder Social logo

WordPress Multisite about valet HOT 18 CLOSED

rawcreative avatar rawcreative commented on August 23, 2024
WordPress Multisite

from valet.

Comments (18)

clifgriffin avatar clifgriffin commented on August 23, 2024 10

@rawcreative @lauhakari I created a custom driver for handling subdirectory multisite installs:
https://github.com/Objectivco/WordPressMultisiteSubdirectoryValetDriver

It won't work with subdomains (and will in fact break them). A workaround to use this driver in tandem with subdomains is to modify the serves() function to something like this:

    	$multisite_paths = array(
    		"/Users/you/Sites/foo",
    	);
    	
        return in_array($sitePath, $multisite_paths); 

Then you can just add the site to the list for each additional subdirectory install.

from valet.

bjuppa avatar bjuppa commented on August 23, 2024 9

I was involved in creating a custom driver for wordpress multisite at my former workplace, maybe it can help somebody: https://github.com/fewagency/best-practices/blob/master/Wordpress/multisite-url-rewrites.md

from valet.

nicgutierrez avatar nicgutierrez commented on August 23, 2024 1

hey @clifgriffin , I managed to get my mu wp app just by changing the nginx config file. If that's something you're interested in, I can share it with you.

That said, I'm not sure what's going to happen when I'll update valet. Does anyone know if my changes to the ~/.valet/Nginx/{site}.dev file will disappear?

from valet.

phpanos avatar phpanos commented on August 23, 2024 1

@bjuppa This driver fixes my issue. Thank you!

from valet.

bjuppa avatar bjuppa commented on August 23, 2024 1

Glad to hear @phpanos ! And thanks to my former colleague @carolineschouenborg for the collaboration!

from valet.

lauhakari avatar lauhakari commented on August 23, 2024

Ran into similar problems yesterday when I was to test some multisite stuff locally.
First setup the MU with /blog/, but as you say didn't work at all. But then I switched it to subdomain instead and that works just fine. The caveat is that you have to manually valet link all the subdomains you want to use, in the same folder. But seems to work fine =)

from valet.

rawcreative avatar rawcreative commented on August 23, 2024

@clifgriffin I'm a little confused by your comment. So this does, or does not work with subdirectories? You said it's a driver for handling subdirectory installs, but then said it won't work with subdirectories and breaks them.

from valet.

clifgriffin avatar clifgriffin commented on August 23, 2024

@rawcreative Typo. Fixed. :) It works with subdirectories but not subdomains.

from valet.

fa8ster avatar fa8ster commented on August 23, 2024

I'm running into a 404 with this driver in the .valet/Drivers directory :(

from valet.

phpanos avatar phpanos commented on August 23, 2024

So is there a solution for multisites on valet yet? Having same problem as @fabianhenzler when trying @clifgriffin driver.

from valet.

clifgriffin avatar clifgriffin commented on August 23, 2024

The only 404 I see is when going to /wp-admin/ with no PHP file specified.

Just noticed it recently honestly...is that what you guys are seeing?

from valet.

mohsinr avatar mohsinr commented on August 23, 2024

@clifgriffin Great work! It worked for sub-sites without me doing any extra work!

Yes if for network we go to /wp-admin we see 404 however this works fine /wp-admin/index.php as it is dev env so no issues as Sub sites in sub folders working great. Thank you!!!

from valet.

clifgriffin avatar clifgriffin commented on August 23, 2024

@mohsinr Glad to hear it worked for you.

Open to ideas on the wp-admin slash problem!

from valet.

mohsinr avatar mohsinr commented on August 23, 2024

@nicgutierrez can you please share your nginx config file and how you implemented it. As my mu install has stopped working and it is showing 404 with or without the driver from @clifgriffin (It worked great before but just a week ago i upgraded some stuff on composer and now everything else works but multisite.)

from valet.

clifgriffin avatar clifgriffin commented on August 23, 2024

@nicgutierrez I wouldn't think those changes would be upgrade safe.

@mohsinr If you're seeing a 404 when going to wp-admin, try adding a slash to the end. I haven't had a chance to track down that bug. PR's are welcome.

from valet.

nicgutierrez avatar nicgutierrez commented on August 23, 2024

@clifgriffin bummer! thanks for confirming.

I used to have a custom valet driver for this but for some reasons the loading time was incredibly slow, that's why I decided to change the config file. I'll just leave it here just in case.

server {
    listen 80;
    server_name blog.dev www.blog.dev *.blog.dev;
    return 301 https://$host$request_uri;
}

map $uri $blogname{
    ~^(?P<blogpath>/[^/]+/)files/(.*)       $blogpath ;
}

map $blogname $blogid{
    default 1;
}

server {
    listen 443 ssl http2;
    server_name blog.dev www.blog.dev *.blog.dev;
    root /Users/nic/blog;
    charset utf-8;
    index index.php;

    location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
        internal;
        alias /;
        try_files $uri $uri/;
    }

    ssl_certificate /Users/nic/.valet/Certificates/blog.dev.crt;
    ssl_certificate_key /Users/nic/.valet/Certificates/blog.dev.key;

    location ~ ^/files/(.+) {
        try_files /wp-content/blogs.dir/1/files/$1 /wp-includes/ms-files.php?file=$1 ;
        access_log off; log_not_found off; expires max;
    }

    #avoid php readfile()
    location ^~ /blogs.dir {
        internal;
        alias /Users/nic/blog/wp-content/blogs.dir ;
        access_log off;     log_not_found off; expires max;
    }

    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*\.php) $2 last;
    }

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log /Users/nic/.valet/Log/nginx-error.log;

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/Users/nic/.valet/valet.sock;
    }
}

from valet.

mohsinr avatar mohsinr commented on August 23, 2024

@phpanos Thanks a lot for sharing, it solved my issue also with multisite, on Valet.

from valet.

mattstauffer avatar mattstauffer commented on August 23, 2024

Closing as it seems there are some solid options for custom drivers here.

from valet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.