Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 234 lines (185 sloc) 7.458 kb
* Name: Wordpress Self-Installer
* Author: Jordan Andree
* Author URL:
* Script URL:
* Notes: Script is still a work-in-progress and currently only supports Linux/Unix based development enviroments
class config {
var $host = 'localhost'; /* Database Host */
var $user = 'USER'; /* Database User */
var $pass = 'PASSWORD'; /* Database Password */
$c = new config();
$con = mysql_connect($c->host, $c->user, $c->pass );
if(!$con) die ('<h2>DATABASE CONNECTION ERROR</h2>');
if(!function_exists('curl_exec')) die('<h2>cURL Extension missing</h2>');
define('DS', '/');
<html lang="en">
<title>Wordpress Self-Installer</title>
<style type="text/css">
@import url(,italic);
@import url(;
@import url(;
body {margin:0px; font-family:'Molengo', Arial, Helvetica, Sans-serif; font-size:.80em; background:#222; color:#888 ;}
h1, h2 { color:#0085AF; text-shadow:0px 1px 1px #000; margin:0px 0px 20px; font-family:Georgia, serif; font-weight:normal; border-bottom:1px solid #404040; padding:0px 0px 10px;}
h1 {font-size:250%; color:#ccc;font-family: Georgia, Serif; font-style:normal;}
h2 {font-size:180%;}
a { color:#bbb; text-decoration:none;}
a:hover { color:#fff;}
#wrap { width:960px; padding:10px; margin:0 auto;}
.header { width:920px; margin:0px 0px 10px 0px; background:#0085AF !important;}
.header h1 { border:0px; margin:0px; padding:0px;}
.header em {float:right; color:#07566F; margin:8px 10px 0px; font-size:140%;}
.databases, .create, .output, .header { padding:20px; background:#333; -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; }
.databases, .create, .output, .header { -moz-box-shadow:0px 1px 1px rgba(0,0,0,.2); box-shadow:0px 1px 1px rgba(0,0,0,.2); -webkit-box-shadow:0px 1px 1px rgba(0,0,0,.2);}
.databases { margin:10px 0px 0px 0px; width:220px; float:left;}
.databases ul { padding:0px; margin:0px; list-style-position:inside; list-style-type:circle;}
.create { margin:10px 0px 10px 0px; float:right;width:640px; }
.output { margin:10px 0px 0px 0px; float:right; width:640px;}
.copyright { font-size:80%; padding:10px; float:right; width:660px; color:#333;}
.copyright a { color:#555;}
.copyright a:hover { color:#666;}
<div id="wrap">
<div class="header">
<h1>Wordpress Self-Installer</h1>
<div class="databases">
<ul><h2>Wordpress Installs</h2>
$query = mysql_query("SHOW DATABASES");
$read = opendir(BASE.DS);
while(false !== ($dir = readdir($read))){
if(is_dir(BASE.DS.$dir.DS) && $dir != '.' && $dir != '..'){
echo '<li><a href="'.$dir.'">'.$dir.'</a></li>';
<div class="create">
<h2>Create New Wordpress Installation</h2>
<form action="wordpress.php?action=new" method="post">
<label for="name">New Wordpress Installation Name:</label>&nbsp;&nbsp;<input type="text" name="name" size="40" />
<!--<br /><br />Include filler Posts, Comments, and Pages&nbsp;&nbsp;<input type="checkbox" name="filler" id="filler" checked="false">-->
<br /><br />
<input type="submit" value="Submit" />
<div class="output">
<h2>Installation Progress</h2>
<div id="none">None yet!</div>
case 'new':
$name = $_POST['name'];
echo '<style>#none { display:none}</style>';
echo 'Installation Name required';
define('ABSPATH', BASE.DS.$name.DS);
echo 'Creating database...';
// first creat our database
$create_db = mysql_query("CREATE DATABASE {$name}");
// database done!
echo 'Done!<br /><br />';
/** Wordpress Download **/
echo 'Downloading latest version of Wordpress...';
// curl init
$ch = curl_init();
// get latest tar
// file intance
$filename = 'latest.tar.gz';
$save = fopen($filename, 'a');
// ask curl to save latest to our file handle
curl_setopt($ch,CURLOPT_FILE, $save);
// execute
$latest = curl_exec($ch);
// close curl connection
// close file
echo 'Done!<br /><br />';
/** Wordpress File and Directory Setup **/
echo 'Unpacking Wordpress core files...';
// make directory
mkdir(BASE.DS.$name, 0755);
// execute tar of file
$tar = "tar -xvzf $filename -C $name/";
$results = system(escapeshellcmd($tar), $retval);
// delete tar
// make temp dir
$rand = rand(1,10000);
$tmpdir = 'tmp_'.$rand;
mkdir(BASE.DS.$tmpdir, 0755);
// copy wordpress installation to tmp dir
rename(ABSPATH.'wordpress'.DS, BASE.DS.$tmpdir.DS);
// copy tmp dir files to new dir with set name
rename(BASE.DS.$tmpdir.DS, ABSPATH);
echo 'Done!<br /><br />';
echo 'Setting up Wordpress <code>wp-config.php</code> file...';
/** Wordpress Configuration Setup **/
$wp_config_sample = ABSPATH.'wp-config-sample.php';
$file = fopen($wp_config_sample, 'r');
$file_text = fread($file, filesize($wp_config_sample));
// setup config with params
$file_text = str_replace('database_name_here', $name, $file_text);
$file_text = str_replace('username_here', $c->user, $file_text);
$file_text = str_replace('password_here', $c->pass, $file_text);
$new_config = fopen(ABSPATH.'wp-config.php', 'w');
fwrite($new_config, $file_text);
echo 'Done!<br /><br />';
// add filler content if selected
/* $filler = $_POST['filler'];
echo 'Inserting filler Posts, Comments, and Pages';
// include our fresh wordpress config so we can use some WP functions
include ABSPATH.'wp-config.php';
// params for posts and comments per post **to be editable later**
$number_of_posts = 25;
$number_of_comments_per_post = 5;
$lorem = '';
// loop it now
for($i = 0; $i <= $number_of_posts; $i++){
$newpost = array();
$newpost['post_title'] = $heroname;
$newpost['post_content'] = nl2br($story);
$newpost['post_status'] = 'publish';
$newpost['post_author'] = 1;
$newpost['post_type'] = 'post';
$newpost['post_category'] = array(1);
$post_ID = wp_insert_post( $my_post);
echo 'Done!<br /><br />';
} */
echo 'You will be redirected to setup your Wordpress site name and admin account in 15 seconds<br />';
echo '<a href="'.$name.'">Click Here</a> to go there immediately';
// and redirect
echo '<meta http-equiv="Refresh" content="15;URL='.$name.'">';
return false;
} ?>
<div class="copyright">
crafted by <a href="">jordan andree</a>. this script wouldn't be possible without <a href="">wordpress</a>
<br clear="all" />
Jump to Line
Something went wrong with that request. Please try again.