Custom WordPress Installer Script in Virtualmin

WordPress (or any other script) can automatically install during Virtualmin > Create Virtual Server.

Virtualmin automatically creates users, MySQL database, and installs WordPress in the public_html root, then gives a link to the WordPress Installer. You can even create a custom installer with a set of plugins and themes.

To create a custom script installer with plugins and themes:

  • Download http://wordpress.org/latest.zip & unzip
    • add some themes and plugins folders in /wp-content/
    • zip as copy-of-latest.zip
  • Create a copy of /usr/libexec/webmin/virtual-server/scripts/wordpress.pl
    • name the copy custompress.pl — this is important because the script requires proper id
    • edit custompress.pl to give a new name: script_wordpress_desc “Custom WordPress”
    • replace ALL instances of script_wordpress with script_custompress (id to match filename)
    • link to your zip: 'url' => "file://localhost/path/to/copy-of-latest.zip" (~line 150 after # script_wordpress_files)
      • this must be retrievable via wget from YOUR SERVER (test this via terminal command)
    • change 'virtualmin' => 0 to NOT use virtualmin scripts repo! (~line 152)

Your custom file should now look like this:

# script_custompress_files(&domain, version, &opts, &upgrade-info)
# Returns a list of files needed by WordPress, each of which is a hash ref
# containing a name, filename and URL -- set virtualmin to 0 to use the url
sub script_custompress_files
{
local ($d, $ver, $opts, $upgrade) = @_;
local @files = ( { 'name' => "source",
           'file' => "custompress-$ver.zip",
           'url' => "https://s3.amazonaws.com/cgilligan-share/custompress.zip",
           'virtualmin' => 0,
           'nocache' => 1 } );
return @files;
}

Try the install:

  • Put custompress.pl in /usr/libexec/webmin/virtual-server/scripts/

Automatic installation with creation of new virtual server:

  • Virtualmin > System Settings > Server Templates > Default Settings > Default Script Installers
    • Custom WordPress

If you want to have the script archive download from a protected web directory, that is also possible:

'url' => "http://repo.server.com/file-ver.zip", 'nocache' => 1, 'user' => "username", 'pass' => "password"

 

Source: http://chrisgilligan.com/wordpress/automated-wordpress-installation-via-custom-virtualmin-script-installer/



1 thought on “Custom WordPress Installer Script in Virtualmin”

Leave a Reply