Jump to content

Sites Manager (ProcessSitesManager)


kongondo
 Share

Recommended Posts

Sites Manager

 

16 September 2018:

FOR NOW, PLEASE DO NOT USE THIS MODULE IN A PRODUCTION SITE. A  RECENT ProcessWire UPDATE HAS BROKEN THE MODULE. I AM WORKING ON A FIX.

 

################

 

Sites Manager is a module for ProcessWire that allows Superusers to easily create/install ProcessWire sites on the same serverspace the module is running in. Only Superusers can use the module. You can create both stand-alone and multi-sites.

 

Single/Stand-alone Sites

Stand-alone or single-sites are sites that will run in their own document root/directory with their own wire and site folders, .htaccess, index.php, etc. In other words, a normal ProcessWire site.

Multiple Sites

Multi-sites are sites that will run off one wire folder (shared amongst two or more sites) each having their own site folder and database. In this regard, it is important to note that Sites Manager is not in itself a multiple sites solution! Rather, it is a utility that helps you create multi-sites to be run using the ProcessWire core multiple sites feature. For more on this core feature, see the official ProcessWire documentation, specifically the solution referred to as Option #1.

Option #1 approach requires the site admin to initially install ProcessWire in a temporary directory for each new site. The directory then needs to be renamed as site-xxx, where ‘xxx’ is any name you want to use to differentiate the installation from other sites, before it is moved to the webroot. For instance, site-mysite, site-another, site-whatever. In addition, the /wire/index.config.php file must be copied/moved to the webroot. Each time a site is added, the index.config.php has to be edited to add ‘domain’ => ‘site-directory’ key=>value pairs for the site. This process can become a bit tedious. This module aims to automate the whole multi-site site creation process.

The module is based off the official ProcessWire installer. Creating a site is as simple as completing and submitting a single form! You also have the option to type and paste values or reuse a pre-defined install configuration.

 

The module will:

  • Install a ProcessWire site in your named directory, applying chmod values as specified

  • Move the directory to your webroot

  • Update/Create a Superuser account as per the submitted form, including setting the desired admin theme and colour

  • For multi sites, update sites.json (used by index.config.php to get array of installed sites)

 

For multi sites, the only difference in relation to the core multi-sites index.config.php is that this file is slightly different from the one that ships with ProcessWire.

Download from GitHub: Sites Manager (Beta Release)

Features

  1. Install unlimited number of sites in one (multi-sites) or independent (single-site) ProcessWire installs.
  2. Install by completing a Form, Typing or pasting in configurations or using pre-created install configurations.
  3. Choose an Admin Theme to auto-install along with the site installation.
  4. For single-sites installation, download, save and reuse ProcessWire versions of your choice.
  5. Install and maintain site profiles for reuse to create other sites.
  6. Create install configurations to speed up installation tasks.
  7. Client and server-side validation of site creation values.
  8. Edit uploaded profiles (e.g., replace profile file).
  9. Lock installed sites, configurations and profiles to prevent editing.
  10. Bulk delete items such as site profiles, installed site directories and/or databases (confirmation required for latter two).
  11. View important site details (admin login, chmod, etc).
  12. Links to installed sites home and admin pages.
  13. Timezones auto-complete/-suggest.

Pre-requisites, Installation & Usage

Please see the documentation.

Technicalities/Issues

  • Only Superusers can use the module.

  • ProcessWire 2.7 - 3.x compatible

  • Currently using ProcessWire 2.7 installer (install.php)

  • For multi-sites, potential race condition when sites.json is being updated on a new site install vs. index.config.php accessing the json file?

  • Not tested with sub-directory installs (for instance localhost/pw/my-site-here/)

  • Currently not doing the extra/experimental database stuff (database charset and engine)

Future Possibilities

  • Install specified modules along with the ProcessWire install

  • Profile previews?

Credits

  1. @ryan: for the ProcessWire installer

  2. @abdus: for the index.config.php reading from JSON idea

  3. @swampmusic: for the challenge

Video Demo

Demo  showing how quick module works on a remote server [YMMV!]. Video shows downloading and processing two versions of ProcessWire (~takes 7 seconds) and installing a single/stand-alone ProcessWire 3 site using the new Admin Theme UI Kit (~2 seconds) on a remote server.

 

Screens

1

sites-manager-001.thumb.png.114a764e0d801f4c367d037147dbd552.png

2

sites-manager-002.thumb.png.f1b6f75cf5dcb2df9661a0f21664baca.png

 

 
  • Like 18
Link to comment
Share on other sites

Really cool project. I am used to developing individual sites that with separate wire directories but it gets tedious to update each and every one of them, and not to mention duplicate /wire/ directories. I was thinking of moving to the official multi-site solution, but I'll start with your module. Thanks for sharing it with us.

50 minutes ago, kongondo said:

index.config.php reading from JSON idea

Although for simple configurations this may not matter, I've found out that using PHP files for configuration files are much easier to handle, and doesn't need parsing at all. It's as simple as this:

<?php // mysite.config.php

return [
    'site' => 'mysite',
    'domain' => 'mysite.com'
];

<?php // ConfigReader.php

$configs = [];
foreach(configFiles in configDir) {
    $configs[] = include(configFile);
}

https://github.com/mrkrstphr/array-config

To export as php configuration files you can use

http://php.net/manual/en/function.var-export.php

Major disadvantage is that it's php only whereas JSON is almost universal.

 

  • Like 5
Link to comment
Share on other sites

Cool stuff!

The profiles you mention: are they a different format from the profiles produced by ProcessExportProfile?

Just wondering because you said...

51 minutes ago, kongondo said:

Future Possibilities

  • Install specified modules along with the ProcessWire install

...but site profiles from ProcessExportProfile can include modules, so wasn't sure.

  • Like 2
Link to comment
Share on other sites

1 hour ago, Robin S said:

The profiles you mention: are they a different format from the profiles produced by ProcessExportProfile?

Just wondering because you said...

...but site profiles from ProcessExportProfile can include modules, so wasn't sure.

No, they are not different. I have not used ProcessExportProfile (but I've been thinking, how nice we have it; it will play nicely with ProcessMultiSites). I assume though that it exports the same type of profiles that ship with ProcessWire (the site-default, etc). so it should work.

What I meant is that, say, you have a blank profile. You want to use that to install several sites. Those sites have different module needs. When creating a site you will be able to paste or select module class names to fetch (live) and install along with the site creation. I haven't thought it through properly and it would mean a delay while the modules are being downloaded.  

Edited by kongondo
  • Like 3
Link to comment
Share on other sites

4 minutes ago, kongondo said:

What I meant is that, say, you have a blank profile. You want to use that to install several sites. Those sites have different module needs. When creating a site you will be able to paste or select module class names to fetch (live) and install along with the site creation. I haven't thought it through properly and it would mean a delay while the modules are being downloaded.  

exactly what i was talking about here: 

 

see also @abdus comment on top of page2

i don't like site profiles. i think they are far too unflexible mostly because of the reason kongondo said. a possibility to define modules that get installed by default would be great! maybe this module could be extended to a kind of advanced PW installation kit? for example it could also be nice to use it to install a single-site setup in a different directory on the server (in other words, having the possibility to choose wheter the new site should be installed as single or as multisite).

it would also be easy to choose the core version to use for single-site setups by defining the URL like this: https://github.com/processwire/processwire/archive/3.0.36.zip or that https://github.com/ryancramerdesign/ProcessWire/archive/2.7.2.zip

thanks for creating and sharing this module with us kongondo!

  • Like 3
Link to comment
Share on other sites

1 hour ago, bernhard said:

i don't like site profiles. i think they are far too unflexible

They ARE useful though ;) Think of them as the simplest way of SHARING a site – as a starting point – with the community and it is also needed by the PW installer. No more, no less. Great feature! :D

  • Like 1
Link to comment
Share on other sites

3 hours ago, bernhard said:

for example it could also be nice to use it to install a single-site setup in a different directory on the server (in other words, having the possibility to choose wheter the new site should be installed as single or as multisite).

Yeah, I had similar thoughts when drafting the module. This is quite easy to accomplish. Actually, one other reason the module is alpha is that it could end up being more than a multi site thingy, hence I would need to change the Class name. 

3 hours ago, bernhard said:

it would also be easy to choose the core version to use for single-site setups by defining the URL like this: https://github.com/processwire/processwire/archive/3.0.36.zip or that https://github.com/ryancramerdesign/ProcessWire/archive/2.7.2.zip

Cool idea. I'll have a think.

  • Like 2
Link to comment
Share on other sites

great to hear that :)

hm... what do you think of splitting it into 3 parts:

  1. some kind of advanced pw-installer
  2. a process module to handle multisite installations
  3. a single php file that grabs the pw-installer similar to the online installer from soma (https://github.com/somatonic/PWOnlineInstaller/blob/master/grabpw.php)

hm... thinking about point 3 i'm not sure if that makes sens, but i'll leave it here for discussion. maybe it would be easier to do a git clone kongondos-great-pw-installer than creating an index.php, copying some lines of php that basically would do the same as my mentioned git clone?! what do you think?

i think it would be great to make the installation process as easy as possible and on the other hand more flexible than the one we already have (yes, i know we already have site profiles and whoever likes them please continue using them :D;) ). so if the installer was able to install a list of modules it could also install point 2 of my list!

i also think that this installer should be able to load standard setups of a pw-site from any url. be it a json file or some php-setup like abdus mentioned - don't know what would be better. but imagine an installer with one inputfield at the top that says:

Quote

load installation-configuration from URL: ...

this would make it possible to

  1. save your own basic pw-setups as simple gists
  2. share setups with others (eg on the forum for debugging, similar to the concept of VMs)

and all you would have to do was to put in an URL form the basic setup (that the browser should remember), choose admin username + password and database connection info. done :)

maybe a lot of what i want is already doable by adrians module toolkit? but still i think the process of installing pw in general can be optimized. or am i just missing some great options we may already have (like wireshell for example)? or can we use composer like this?

  • Like 1
Link to comment
Share on other sites

On 05/10/2017 at 7:07 AM, abdus said:

I was thinking of moving to the official multi-site solution, but I'll start with your module.

Just to clarify to those that might be confused by this line. This module is not a multi-site solution. It is a multi-site helper. You will still be using the official ProcessWire mulit-site solution. The module only helps you to auto-mate some of the manual tasks. The only notable difference is the how index.config.php is structured.

 

20 hours ago, bernhard said:

hm... what do you think of splitting it into 3 parts:

  1. some kind of advanced pw-installer
  2. a process module to handle multisite installations
  3. a single php file that grabs the pw-installer similar to the online installer from soma

I am not keen on splitting the module like this since it can, with a little tweaking, already achieve a standalone(single) installation. The only differences between a multi-site and single site are:

multi-site

  1. location of site folder -  located in same folder as the main site folder (e.g. /www/main-site/site/ for the main site and /www/main-site/site-something/ for the installed site
  2. site folder named site-something
  3. uses the existing wire folder (/www/main-site/wire/)
  4. needs index.config.php

single site

  1. location of site folder - located in its own folder (e.g. /www/another-site/site/)
  2. site folder named 'site'
  3. uses its own wire folder (/www/another-site/wire/)
  4. does not need the index.config.php

This means that all we have to do is (like you suggested earlier) tell the module in which directory on your server you want to install the single site, do the htaccess.txt renaming and copy over the wire folder as well as its index.php, LICENSE.txt, etc. That's all there is to it. The database stuff routines remain the same. So, I am thinking of a radio button to choose whether you are installing a single versus multi site, blah blah.

Edit:

In respect of selecting ProcessWire versions,  the module could check if you have a zip file in a designated folder to unzip from and if not, download the ProcessWire version of your choice, or something along those lines.

20 hours ago, bernhard said:

i also think that this installer should be able to load standard setups of a pw-site from any url. be it a json file or some php-setup like abdus mentioned - don't know what would be better. but imagine an installer with one inputfield at the top that says:

What is a standard setup :)? I am a bit jittery about the module communicating with any URL. I would prefer all that such setups are loaded locally. Maybe I am just being paranoid here :)

20 hours ago, bernhard said:

save your own basic pw-setups as simple gists

I was thinking of saving this locally. That's what I was intimating by this:

On 05/10/2017 at 6:57 AM, kongondo said:

Create installation profiles and/or allow JSON/CSV install configurations (useful for repetitive values, e.g. where Superuser email doesn’t change)

 

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

Update: Multi Sites Version 0.0.2.

Multi Sites can now install single/stand-alone sites! The Multi Sites in the name now means installing and managing multiple sites :P! For single sites use, the module now downloads, strips, compresses and save ProcessWire versions of your choice for reuse (rather than downloading each time you install a single site). These ProcessWire files can be refreshed on demand, e.g. when a new version of ProcessWire comes out. README is now complete. See changelog for more details.

Download from GitHub.

Changelog

  1. Support for installing single/stand-alone sites.
  2. Added Type or Paste and Install Configuration methods for creating sites.
  3. Create and edit site install configurations.
  4. Download, store and restore various versions of ProcessWire (for single-site installations).
  5. UI enhancements.

I'll update first post later.

Screens

1

multisites-version-002-001.thumb.png.68d53d6c6b893052a71068bfb71627b9.png

2

multisites-version-002-002.thumb.png.45bfc60ef15cda727665baa8a3e12bf5.png

3

multisites-version-002-003.thumb.png.094b8fe96bf13f28ec7f71f445aa7501.png

4

multisites-version-002-004.thumb.png.ead01014f6e663b87376a995b6d56ac8.png

Edited by kongondo
  • Like 6
Link to comment
Share on other sites

7 hours ago, kongondo said:

Multi Sites in the name now means installing and managing multiple sites :P!

Great news! Now I just have to find the time to try it out... BTW, how about renaming it to something like Sites Manager? Is it too late to rename it to something more descriptive and less confusing? There is another group of modules with almost the same name:

also:

Multiple solutions with multiple multies in their names are a bit confusing ;) 

  • Like 1
Link to comment
Share on other sites

2 hours ago, szabesz said:

BTW, how about renaming it to something like Sites Manager? Is it too late to rename it to something more descriptive and less confusing? There is another group of modules with almost the same name:

Not, it's not late at all. In fact, I forgot to mention it. I was looking for name suggestions! (one of the reasons I still left it in Alpha, actually). Thanks! I like sites manager. Let's see if there are more suggestions.

All,

Module Name

Name suggestions for this module please? We currently have:

  1. Sites Manager

Upgrading

Please note, version 002 includes some templates not in version 001. A re-installation is required I am afraid.

  • Like 1
Link to comment
Share on other sites

Can't wait to use this for something... Now all I need is a nice big client that needs multiple sites. ;-)

59 minutes ago, swampmusic said:

I am buried deep in vuejs these last weeks

In this boat as well. Vue is awesome! Somewhat of a paradigm shift, but fine - just the reactivity system on its own is great!

Link to comment
Share on other sites

Update: Multi Sites Sites Manager Version 0.0.3.

Multi Sites is dead! :o Long live Multi Sites!! :)

Happy to announce Beta Release of Sites Manager.

Please note, no upgrade path from versions 001 or 002 of Multi Sites. I have updated the first post.

Download: GitHub

Demo: Remote server single site install (PW 3.x + AdminThemeUIKit).  YouTube

Documentation: GitHub

Changelog

  1. Changed name to Sites Manager (formerly Multi Sites). Thanks to @szabesz for suggestion.
  2. Fixed bugs in Type or Paste method (key=value pairs must now be separated by new line).
  3. Beta release.
Edited by kongondo
minor cleanup
  • Like 3
Link to comment
Share on other sites

  • 10 months later...

Hi @DxJR,

Welcome to the forums and ProcessWire. Thanks for testing the module. What ProcessWire version are you using? A recent ProcessWire update seems to have broken the module. I noticed this when setting up some sites last week. I've not had a chance to debug it yet. I am quite busy at the moment and don't know when I'll look into it. Until then, please do not to use the module in production sites. I'll update the first post.

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...