Comments (18)
@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.
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.
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.
@bjuppa This driver fixes my issue. Thank you!
from valet.
Glad to hear @phpanos ! And thanks to my former colleague @carolineschouenborg for the collaboration!
from valet.
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.
@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.
@rawcreative Typo. Fixed. :) It works with subdirectories but not subdomains.
from valet.
I'm running into a 404 with this driver in the .valet/Drivers directory :(
from valet.
So is there a solution for multisites on valet yet? Having same problem as @fabianhenzler when trying @clifgriffin driver.
from valet.
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.
@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.
@mohsinr Glad to hear it worked for you.
Open to ideas on the wp-admin slash problem!
from valet.
@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.
@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.
@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.
@phpanos Thanks a lot for sharing, it solved my issue also with multisite, on Valet.
from valet.
Closing as it seems there are some solid options for custom drivers here.
from valet.
Related Issues (20)
- Warning: require_once(./cli/includes/require-drivers.php): Failed to open stream with custom driver for Symfony project HOT 7
- Running Valet with ExpressVPN not work HOT 21
- Any error in the system gives a 502 Gateway error and php-fpm.log file size in increased by ~1.1gb HOT 4
- update 4.0 bug
- Upgraded to Apple M1 now Valet services are erroring after being resintalled HOT 10
- nginx: [warn] the "http2_push_preload" directive is obsolete & the "listen ... http2" directive is deprecated HOT 2
- 502 Bad Gateway : upstream prematurely closed connection while reading response header from upstream HOT 6
- My extensions all stopped working after upgrading to v4 HOT 4
- Valet share not works HOT 2
- PHP 8.3 HOT 5
- Valet install - not starting nginx and dnsmasq HOT 1
- When using valet, sys_get_temp_dir() does return /var/tmp instead of /var/folders/7s/jq24sk81665c1j4y3v9l3vth0000gn/T HOT 4
- Space in "Application Support" Causing Error During "valet share" Command HOT 1
- error 502 when i use mongodb atlas connection mongodb+srv://connection-link HOT 2
- npm run dev throws Failed to load resource: net::ERR_CERT_COMMON_NAME_INVALID after upgrading to macOS Sonoma 14.4.1 HOT 1
- Couldn't Install Laravel Valet HOT 2
- AWS S3 temporaryUrl fails on Valet HOT 2
- Share with Expose HOT 1
- NET::ERR_CERT_AUTHORITY_INVALID HOT 14
- Not working valet php command to proxy calls on Macbook M3 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valet.