Script for basic WordPress installation, with plugins and themes

For my work I had to make several wordpress installations with the same basic plugins and themes over and over again. Maybe you know that pain in the ass, but I got sick of downloading and extracting all the stuff manually, so I decided to write some handy script to do the job for me.

Within the script you can extend the list of plugins and themes to be downloaded, to fit your custom purposes.
Important: If new versions of plugins are available you have to edit the URLs in the array! Make sure, that all URLs lead to the actual version, when using the script.

< ?php
	* PHP script to fetch a basic and actual wordpress installation
	* to a directory name of your choice and some basic plugins and 
	* themes in an extendable list. The result will be a directory 
	* in the root directory of this script.
	* To add more plugins, simply extend the $plugins array below with
	* the URL to the plugins you chose.
	* Usage: php wordpress-install.php [<destination name>]
	* The destination name is optional. If none is given, the output
	* directory will be called "wordpress".
	* NOTE: The script is most useful, if you run it directly on the 
	* 	 server you want to install wordpress. If this is not 
	*	 possible(e.g. your hoster does not allow remote file 
	* 	 access, etc.), you can run it locally and upload the 
	* 	 resulting folder to the destination of your choice.
	* IMPORTANT: Check the actuality of the plugin URL's and update them,
	* 	      if a new version is released!
	* Author: Martin Albrecht <martin>
	* Homepage:
	* Simple function to fetch and extract a zip file, because all 
	* archives we'll download are ZIP files
	* Parameters are the URL and flags, if it is a plugin or theme.
	function DownloadZip($url=null, $plugin=false, $theme=false) {
		if( ($plugin || $theme) && !file_exists('wordpress') ) {
			echo "[!] Error: No wordpress installation found!\n";
			return 1;
		try {
			preg_match('/.*\/.*\/(.*)/', $url, $matches );
				$filename = trim($matches[1]);
			echo "[+] Downloading $filename... ";
			$data = file_get_contents($url);
			file_put_contents($filename, $data);
				echo "DONE!\n[+] Unpacking $filename... ";
					$zip = new ZipArchive;
			if( $plugin === true ) {
			} else if( $theme === true ) {
			} else {
			echo "DONE!\n";
		} catch(Exception $e) {
			return 1;

	* The plugins array. Here, you can simply add as much plugins as you want
	* by simply extending the array with the URLs to the plugin.
	$plugins = array('',
	* The themes array. The structure is the same as the plugins array.
	$themes = array('');
	// URL to the lates wordpress version
	$wordpress = '';
	// Download and unzip files...
	echo 'Beginning download of wordpress with ',sizeof($plugins)," plugins...\n";
	foreach($plugins as $plugin) {
		DownloadZip($plugin, true);
	foreach($themes as $theme) {
		DownloadZip($theme, false, true);
	// Rename directory, if name is given	
	if( $argc>=2 ) {
		rename('wordpress', $_SERVER['argv'][1]);

It’s a very simple PHP script, that only downloads and extracts wordpress, the chosen plugins and themes into a directory in the root directory of the script.
If you don’t want to copy/paste the code, here’s a download link: wordpress-install

Quick update: Of course, you need the PECL Zip library for PHP to use the ZipArchive class. See the official documentation for more information.

Similar Posts:

  • it was very interesting to read.
    I want to quote your post in my blog. It can?
    And you et an account on Twitter?

  • I would like to exchange links with your site
    Is this possible?