 Good afternoon everybody, I'm going to now have some live coding and mostly I guess it's development operations, as I'm only kind of doing the configuration, so I'm not actually changing any of the code. But I'm Yusi Kinnolan, I've been working with Frantic, with WordPress related stuff and also Angular related stuff for three years now, and I've also helped other developers to increase the productivity and this multi-site thing is one of those. One of those topics that somebody wanted to have multi-sites, I don't know if there is really business reasons to have multi-sites, maybe blocks and kind of subsites, it's kind of nice to have more granularity on the admins and so on, but well, it's a business case that if somebody wants a multi-site then they want to have it. So let's just get our hands dirty. You should note that my presentation is informed that when you download it or look it from the internet you can follow up all my steps, you only need to create a Heroku account and you are ready to go and make your own multi-site. So let's start. So this is basically describing that what are the prerequisites that these instructions are using. So we use on Frantic only Max. I heard today that some people are using Windows, no offense for Windows, I don't really know that if these tools would actually work on Windows, but maybe. At least they work on Linux, so I've seen loads of Heroku and also this deployment guys written for Linux. And this is based on this Petroc. So the Petroc is the way to go on cloud deployment and its structure is a little bit different that you have used on WordPress, but it really works, works on at least on our case. And these modifications for the Petroc, it's open source, so we have made it publicly available, so I didn't create a minimal fork to my own GitHub, I just used the one that we are using on Frantic. And it's really usable by anybody, so I like to add open source to WordPress stuff. So regularly you just install the stuff and it works, so on our case the homebrew makes it very easy to make. Easy to make, you just install the correct stuff like libraries and MySQL and PHP stuff and others. Composer is important on our case as this Petroc, it's kind of built that all that you have on WordPress are Composer plugins. And you use WPagagist repositories to get the stuff so you don't actually update anything regularly with this VP admin. You will just bump the versions and push it to cloud with this Composer log file updated, so the versions will be used also on there. So it's kind of bringing immutability to WordPress world, which is kind of also on Node.js and Angular world immutability is the way to go, so whatever you do it just works. One particular thing on this Frantic template is that we've made it also impossible so it makes this Heroku file, which can read only for WordPress directory, so you would just see some errors if you try to update anything. But that's minor detail. And second most important thing is that we are using the same tool chain that Heroku uses to run PHP apps. So this PHP tool chain, so it's built back on Heroku. So it needs enchings web server with this configuration and this real IP, it's basically used so that you can use this HTTP header remote address for the true users address, not any load balancers or CDNs address, so it's only doing that. And then also on this instructions I'm using, Node module reverse proxy and I will tell later why I need to use this but it's related to the multi-site. So usually on this time if I would have installed those I need to some time to test those but luckily for you I did this testing already back on that table one hour ago so everything works. Or it should be. All right, so then it's time to set up the development repository. So let's just do that. Let's call our site wordcamp.frc.io. I have already set up all the name services so it will also work without any hassle. All right, I'll just remove the git there and add n-file to this git ignore. So I can look to example n-file here. What's there? So basically, well, I'm creating empty git repository and then just committing everything. So this commit is only needed for me so Heroku uses git for transporting the data there so I will need everything committed here. After that, then I have to set up the local environment so I won't set up everything that I regularly would use locally so I don't set up local reddies. I'm not set up in these S3 buckets to be used on local development. Those can be done just later on Heroku site. So I'm just basically putting this very, very simple configuration to my n-file. So now I have the local environment and obviously I need to create a bicycle database and actually update it so that I can use it here. And I've also created this localhost.frc.io. If you wonder what it's all about, so it's a fully qualified domain name pointing to your local host. It's needed in our case because we also have this multisite stuff which I will be using this wildcard domain so we have everything.localhost.frc.io. But then I'm just, I'm actually removing the composer.loc so I can do a fresh install. So I'm going to explain why it's doing the install that what this composer configuration. So it's basing to the betrok default. So it has these two repositories. It has these betrok out-horse sets and you can edit on your project needs. But as this is boilerplate it's using the default so we are just following the upstream. And there are some repositories and support forums and other set here and also the repositories that it's using. So on our case we have our custom version of this Amazon S3 and CloudFront plugin and it's only because of gravity forms. So this Amazon S3 and CloudFront it's nowadays it's called offload S3. So they do have a plugin system implemented but it's missing some of the hooks needed by gravity forms. So we are now using just this forked version because of this but I know we should actually make patches for the upstream so that we can get the hooks and you know it would be the sensible thing to do. As open source developer but let's now just use this forked version or we are not actually using it on this but it's on the configuration. And then this Heroku build part it's added as a development requirement so it's just the same as they use on Heroku deployment side. And then there's a bunch of dependencies like we use Redis and GD which are bundled on the host system so those X packages I like that. And we use couple of caching plugins on those so Amazon web services sent grid for email sending and so on. And those VP does n packages are just helper packages that can be used to expose something that's on Heroku configuration which is a regular environment like on my local dot n. But it's basically Heroku specific so if this would be for example a Docker project then probably we would need to implement similar kind of helper packages. So we can use those built in bundles on Docker and we are using PHP version 5.6 and WordPress version 4.3.1 or equivalent. Then there are some post and update and post install hooks so many of you who are deeper in technical knowledge of WordPress so WordPress has pretty sophisticated caching system and on our case we are using bad cache and object cache so we are just copying the files from this Composer installs packages into place so that the WordPress can use those. And this sunrise.php is related to the multisite configuration so it's used to use real domain name so we have something.localhost.frc.io so with this MU domains plugin we can hook that we have www.something.com which is equals as some sub domain. And then there is installer parts defined so basically it just defines that if you have those WordPress MU plugins it puts them under web app. MU plugins, regular plugins under plugins and teams under web app teams. And WordPress is installed under web slash WordPress. Previously people have used more like something like public for entire web route and WordPress installation directory as WordPress. All right so Composer install should have been done here so yes it's ready now. And I need to add now this as I previously told that I need this reverse proxy so it was here it wasn't actually here so yeah so I need to run sudo for this reverse proxy so basically this WordPress multisite it's if I use subdomains. For the moment it cannot use any port on it so you can use regular HTTP or HTTPS but you are not able to use any custom port like on locally I usually use port 5000 for some reason. But on this case we use reverse proxy to do the proxying. I don't want to run any PHP stuff really with root privileges. So we just reverse proxy. All right so it's listening there. And then I have now this Composer installation done here so well loads of stuff installed so. Can't just run this local Heroku environment which is part of this Heroku build pack which was installed here. All right so it works so I can go now to my local host F3.io. Actually now we have the first demo effect so I need to do. I need to do this plus all. Ready CLI so I forgot that actually this Composer did copy those classes in place so I'm really using now also local it is ready. All right so let's put the good title and then. Just some password talking about good passwords that's why I have one password. All right then and logging in. Yeah I have no local WordPress running. I don't have any multi site really the stuff yet. So here comes the configuration so basically I'm gonna now uncomment. To basically allow this WordPress so so I have made those changes on the bedrock template so I can use a little bit less of these multi site related configurations. So it's just easing the installation and it's also also described on the next slides so. Let's go quickly through the enabling the multi site so when we actually enable this environment variable. Then this there on on this config slash application dot php file which is part of bedrocks modular system. Then it's basically well it's only setting the VP internal flag allowing the multi site through so it doesn't do anything but that but the other configuration variable this VP multi site main domain. It's actually setting more like I did put this if it's set so then it said multi site through sub domain install through domain current site as this main domain. And it also sets the path as less and also this default site ID will be the number one so it's the first site that you have created. But I guess we just we just now stop this local and then allow the multi site and run it again. I guess I'm opening a secondary browser if I can so right so now the tools I have a network setup here. On a network setup all what this does is to add the multi site related configuration to this VP's database. So it doesn't do anything else you have to on regular multi sites about setups you would have to do everything this manually. Like this so you would have to copy paste this but on our case it's already on this bedrock boilerplate so so then I can just go back here. And comment this was the reverse proxy so I will uncomment the last one which sets the main domain and get this heroku logo running again. And now I actually have to do real again so yes now I have this network admin enabled on multi site is totally configured. And I can start adding couple of sites here so. So let's add something something on something else. And I can actually go directly there so so you can see that it's else.localhost.frc.io so so this is a sub sites admin. So it works. All right so pretty much the thing is already done on locally so. We have the main site which which has the multi multi site admin and also controlling to create new sites and so on. And then the site one site two with this site admin rights you are able to do as much as everything that you would regularly do with this kind of regular single site WordPress sites. So it isn't that different but of course now the domain is anything.localhost.frc.io. So for actually actually if you want to locally test that everything works so then you are in luck you can enable this sunrise. This WordPress MU domain mapping plugin. You can activate it also locally. And you will then have domain setting so you can set for example that this I happen to know that this something dot localhost.frc.io. It has this ID 11 so I will put just ID 11 there and I will put put for example. Workup.org there and make it the primary site so it means that it will use only this www.workup.org there. That's not on any domain name so it's only demonstrating how it works locally so don't be afraid. Nothing can go wrong. So I'm just editing my local host file so you can actually with this kind of approach you can develop everything locally and only deploy it when you need. So then it's www.workup.org so I'm overriding locally this regular name services so. And then if I go there so it will then. But this actually the main site. Actually it's actually number two so I made a mistake there so www.workup.org and then put it there. Yes it's again this yeah but well. I guess it should have been site ID 2. Well at least this works on Heroku I tested this so I didn't test it locally so maybe I should have tested it. So I'm removing this line from my local configuration and we could actually go how to deploy it on Heroku. So this first part on creating this app I already did it just so that I have my local privileges correct. So let's go to the work camp. So here we just we would say this create but it's already there so I'm adding then remote. Remote add and it's called Heroku. Regular Heroku will add it if you have this sheet repository initialized by itself. The app is named WordCamp. Then I update the remotes and I'm just looking that do I have anything so I have one web server there so I'm putting it off. Just a kind of good practice that if you publish a wordpress somewhere without actually having the data there so obviously it will display this registration screen so it's kind of good that you don't allow anybody to go there. Just to kind of do and I will also add on. I needed this Maya school so it's clearly be on Heroku. So I'm adding one and then I'm adding ready so so these two are something that we need because we have those installation post installation and post update hooks on place. All right so afterwards we have now added those so then it's about the end of. So we need to add those VP allow multisite and VP multisite main domain to Heroku. At the moment our configuration it only includes the database related stuff. So so I'm just re-adding the same that I have locally there. VP multisite main domain. But on this Heroku case obviously this local house doesn't work there since it's local house. It's not anything on the Internet. It's your own machine. So I have made word cramp.frc.io which I can use there. And I already have this local setup done so I don't want to do it twice. So one of my colleagues has made a Heroku plug-in that automates deploying the local database back and forth to Heroku. So on our case I'm pushing the local word cramp database and doing the search and replace there. So I'm replacing all localhost.frc.io basically this word on database with word cramp.frc.io. So the search and replace is something that you could run standalone. So it only does this calculating the serialization parameters which are word for specific. So localhost.frc.io and word cramp.frc.io. And it was this helper script was kind enough to read the environment from Heroku. So it will use the credentials that well you can see on the screen. So if you are quick enough you can go with your MySQL client and put something there just if you want. So how it works in practice so it does loads of things like dumping and running the search and replace stuff. But plain and simple it's installable as Heroku plug-in so it's fairly easy to use compared to doing the manual command line steps. All right so I'm just closing this local ones now as we move to do the remaining stuff on Heroku. All done. So if everything went fine I can now just scale it up. Well I have to add the domains word cramp.frc.io and also this wild card domain. So this also Heroku specific thing. So now if we go to word cramp.frc.io it should have the site there. Site management as well. I don't have SSL certificate so you should use SSL but you need to install the certificate manually. So in my case I am going to destroy the app so he is just to demonstrate how it works. So basically all the data that I have locally is now on Heroku. And obviously for the sites something.wordcramp.frc.io it works. Let's look if the plug-ins yes it's already active. Network active somehow actually it doesn't work. So basically I'm now missing so probably I will just do. So these are the usual things that when you do something and you worry about it then it doesn't work as it worked when you tried it the first time. All right and then word cramp and then I run Heroku local here and open this. And then I have to now I actually got it so I have to go to network admin. Yeah it was here. All right so I'm just adding one site here so we can have the remaining time. So I have prepared something nice. So I'm using a custom domain now it's number 11. So I should be able to do this now so I have WordCampRules.com said now it actually added it so. So obviously I'm going to check that why it didn't work locally but it might have to do that this MU plug-ins. MU domain plug-in actually does a DNS look up. So if it does so then well you cannot do anything for this but to have a local DNS server of course. Well I only now need to add domains. This WordCamp.Axrules.com actually is by the way my brand made. I made this Axruler.com domain as his birthday present some time ago. So if it now works you will see the page. Axrules yes now it worked. So basically this DevOps stuff with WordPress is pretty fancy if you have this kind of tool. So these two important parts on this tool set. So it's this Heroku build back and the second part is the bedrock. So it makes you that you can run almost identical environments locally and on Heroku and do syncing back and forth. So I've used it for example to do some customer requested changes that are very time consuming to do like input in the content. I do it locally and then I can just with the button press I can push it live. Obviously there would be some other methods to do that with WordPress but it's kind of very convenient that you can preview everything. Well you could also use staging site if you have one. So then the customer can actually input the data there and then use the same Choseps clear DP dump tool to pull it and push it to another Heroku app. So it would work perfectly on this. And the multi size stuff is generally it works with this wild card domain but it doesn't work that way pretty well on the other way. So the other way and doing multi size on practical level would be to have your site dot com slash multi size URL. So unfortunately it doesn't work that easily. And the reason is that on this pet rock WordPress is installed to a separate directory. So if you would have a regular WordPress setup that you have WordPress installed on your web route then you can use this alternative method. It's actually how to docker container instructions they are using WordPress installed in this default location. So the Docker instances you would also use this other one. But I guess let's use the remaining time for questions I guess there might be few. Thank you you'll see we're running bit late so we've got time for just a couple of questions anyone. There's one over there in the third row. So you guys are running WordPress on Heroku in production right now. Yes. So what's the rationale behind that. Has it been working great for you to would you recommend doing that for other companies maybe. Does it scale well. Yeah it's been working pretty well so so basically it enables us to optimize the performance in great detail. So we can basically use variety of services like this Redis and previously we used this Memcac here. Which is Memcac interface service so so we can use that kind of stuff and also implement if some customer for example has very very heavy menu system. We can implement transients based on this and optimize them so that we can basically basically test it in advance. And why we are using those cases is just that we can scale it up so we can tell that run with 10 workers. Right right so you can use caches. My question was more about have you run into any issues with the performance of Heroku because I've had quite a lot of people complain about how the routing system works with Heroku and doesn't really fit with my SQL applications and PHP applications. For example with sessions that's a big thing with Heroku I think the sessions are really shared between the are what were they called instances in Heroku. So far there hasn't been any session related stuff so basically Heroku has their own load balancer so it kind of works out of the box. But of course there's always these cases that for example one client wanted to have that you do this SSL login for regular users but use the same session on HTTP site. And their rationale was that they are advertising this aggregator. They had ads with used HTTP links so they lost some revenue because of HTTPS and obvious it is well everybody is moving to HTTPS so definitely it's not an issue in couple of years. Okay one more question are there any stairs over there. How you manage multiple local WordPress installation in this kind of setup when you install the web server through brew. So if I'm running multi sites obviously I have to have to basically point this reverse proxy only to one local address but I can have easily a dozen of this Heroku local instances running. So it will just look for the next available port starting from the 5000 or you can define it with just port whatever you want. So nobody is actually limiting you to use this local host on any port but it's only this multi site that it doesn't support the port. So I'm actually thinking of contributing to the WordPress core so that we could get the ports also. So at least intranets would benefit on having different default port. Thank you very much Jussi. Let's give him a round of applause.