Warning! Installing to http://localhost/ is not supported. Please use http://localhost.localdomain/ instead." );
}
define('WP_INSTALLING', true);
$dirs = array( dirname(__FILE__), dirname(__FILE__) . "/wp-content/" );
function printheader() {
?>
WordPress › Installation
Server Summary";
print "If you post a message to the µ support forum at http://mu.wordpress.org/forums/ then copy and paste the following information into your message:
";
print "";
print "
ERROR: $err";
clearstatcache();
$files = array( "htaccess.dist", ".htaccess" );
while( list( $key, $val ) = each( $files ) ) {
$stats = @stat( $val );
if( $stats ) {
print "$val
";
print " uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "
\n";
print " size: " . $stats[ 'size' ] . "
";
print " perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "
";
print " readable: ";
print is_readable( $val ) == true ? "yes" : "no";
print "
";
print " writeable: ";
print is_writeable( $val ) == true ? "yes" : "no";
print "
";
} elseif( file_exists( $val ) == false ) {
print "$val
";
print " FILE NOT FOUND: $val
";
}
}
print "
";
}
function do_htaccess( $oldfilename, $newfilename, $base, $url ) {
// remove ending slash from $base and $url
$htaccess = '';
if( substr($base, -1 ) == '/') {
$base = substr($base, 0, -1);
}
if( substr($url, -1 ) == '/') {
$url = substr($url, 0, -1);
}
$err = '';
if( is_file( $oldfilename ) ) {
$fp = @fopen( $oldfilename, "r" );
if( $fp ) {
while( !feof( $fp ) )
{
$htaccess .= fgets( $fp, 4096 );
}
fclose( $fp );
$htaccess = str_replace( "BASE", $base, $htaccess );
if( touch( $newfilename ) ) {
$fp = fopen( $newfilename, "w" );
if( $fp ) {
fwrite( $fp, $htaccess );
fclose( $fp );
} else {
$err = "could not open $newfilename for writing";
}
} else {
$err = "could not open $newfilename for writing";
}
} else {
$err = "could not open $oldfilename for reading";
}
} else {
$err = "$oldfilename not found";
}
if( $err != '' ) {
print "Warning!
";
print "There was a problem creating the .htaccess file.
";
print "Error: ";
if( $err == "could not open $newfilename for writing" ) {
print "Could Not Write To $newfilename.";
} elseif( $err == "could not open $oldfilename for reading" ) {
print "I could not read from $oldfilename. ";
} elseif( $err == "$oldfilename not found" ) {
print "The file, $oldfilename, is missing.";
}
print "
";
filestats( $err );
print "Please ensure that the webserver can write to this directory.
";
print "If you use Cpanel then read this post. Cpanel creates files that I need to overwrite and you have to fix that.
";
print "If all else fails then you'll have to create it by hand:";
print "
- Download htaccess.dist to your computer and open it in your favourite text editor.
- Replace the following text:
- BASE by '$base'
- HOST by '$url'
- Rename htaccess.dist to .htaccess and upload it back to the same directory.
";
die( "Installation Aborted!" );
}
}
function checkdirs() {
global $dirs;
$ret = true;
foreach( $dirs as $dir ) {
if( false == is_writeable( $dir ) ) {
$err[] = $dir;
}
}
if( is_array( $err ) ) {
?>Warning!
One or more of the directories must be made writeable by the webserver. You will be reminded to reset the permissions at the end of the install.
Please chmod 777 directory-name
or chown
that directory to the user the web server runs as (usually nobody, apache, or www-data)
Refresh this page when you're done!
Quick fix:
chmod 777
Warning! .htaccess already exists.";
print "";
print "
A file with the name '.htaccess' already exists in this directory and I cannot write to it. Please ftp to the server and delete this file from this directory!
";
print "Offending file: " . realpath( '.htaccess' ) . "
";
print "
";
}
return $ret;
}
function step1() {
?>Installing WordPress µ
Welcome to WordPress µ. I will help you install this software by asking you a few questions and asking that you change the permissions on a few directories so I can create configuration files and make a directory to store all your uploaded files.
If you have installed the single-blog version of WordPress before, please note that the WordPress µ installer is different and trying to create the configuration file wp-config.php youself may result in a broken site. It's much easier to use this installer to get the job done.
What do I need?
- Access to your server to change directory permissions. This can be done through ssh or ftp for example.
- A valid email where your password and administrative emails will be sent.
- An empty MySQL database.Tables are prefixed with
wp_
which may conflict with an existing WordPress install. - Wildcard dns records if you're going to use the virtual host functionality. Check the README for further details.
If the mod_rewrite
module is disabled ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.
";
if( function_exists( "apache_get_modules" ) ) {
$modules = apache_get_modules();
if( in_array( "mod_rewrite", $modules ) == false ) {
echo "Warning! It looks like mod_rewrite is not installed.
" . $mod_rewrite_msg;
}
} else {
?>Please make sure mod_rewrite
is installed as it will be activated at the end of this install.
$line) {
switch (trim( substr($line,0,16) )) {
case "define('DB_NAME'":
fwrite($handle, str_replace("wordpress", $dbname, $line));
break;
case "define('DB_USER'":
fwrite($handle, str_replace("'username'", "'$uname'", $line));
break;
case "define('DB_PASSW":
fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
break;
case "define('DB_HOST'":
fwrite($handle, str_replace("localhost", $dbhost, $line));
break;
case "define('VHOST',":
fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line));
break;
case '$table_prefix =':
fwrite($handle, str_replace('wp_', $prefix, $line));
break;
case '$base = \'BASE\';':
fwrite($handle, str_replace('BASE', $base, $line));
break;
default:
fwrite($handle, $line);
break;
}
}
fclose($handle);
chmod('wp-config.php', 0644);
define( 'VHOST', $vhost );
}
function step3() {
global $wpdb, $current_site, $dirs, $wp_version;
$base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) );
if( $base != "/") {
$base .= "/";
}
$domain = $wpdb->escape( $_POST[ 'basedomain' ] );
$domain = str_replace( 'http://', '', $domain );
if( substr( $domain, 0, 4 ) == 'www.' )
$domain = substr( $domain, 4 );
if( strpos( $domain, '/' ) )
$domain = substr( $domain, 0, strpos( $domain, '/' ) );
$email = $wpdb->escape( $_POST[ 'email' ] );
if( $email == '' )
die( 'You must enter an email address!' );
$weblog_title = $wpdb->escape( $_POST[ 'weblog_title' ] );
// set up site tables
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_email', '".$email."')" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'admin_user_id', '1')" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'registration', 'none')" );
$wpdb->query( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, '$domain', '$base' )" );
$wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" );
$wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'blog_upload_space', '10' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'fileupload_maxk', '1500' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'site_admins', '" . serialize( array( 'admin' ) ) . "' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'allowedthemes', '" . serialize( array( 'classic' => 1, 'default' => 1 ) ) . "' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'illegal_names', '" . serialize( array( "www", "web", "root", "admin", "main", "invite", "administrator" ) ) . "' )" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'welcome_email', 'Dear User,
Your new SITE_NAME blog has been successfully set up at:
BLOG_URL
You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
Login Here: BLOG_URLwp-login.php
We hope you enjoy your new blog.
Thanks!
--The Team @ SITE_NAME')" );
$wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, 1, 'first_post', 'Welcome to SITE_NAME. This is your first post. Edit or delete it, then start blogging!' )" );
$pass = substr( md5( rand() ), 5, 12 );
$user_id = wpmu_create_user( 'admin', $pass, $email);
$current_site->domain = $domain;
$current_site->path = $base;
$current_site->site_name = ucfirst( $domain );
wpmu_create_blog( $domain, $base, $weblog_title, $user_id, array() );
update_blog_option( 1, 'template', 'home');
update_blog_option( 1, 'stylesheet', 'home');
if( constant( 'VHOST' ) == 'yes' ) {
update_blog_option( 1, 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
} else {
update_blog_option( 1, 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
}
update_blog_option( 1, 'rewrite_rules', '');
$msg = "Your new WordPress MU site has been created at\nhttp://{$domain}{$base}\n\nLogin details:\nUsername: admin\nPassword: $pass\nLogin: http://{$domain}{$base}wp-login.php\n";
wp_mail( $email, "Your new WordPress MU site is ready!", $msg, "From: wordpress@" . $_SERVER[ 'HTTP_HOST' ] );
?>Installation Finished!
Congratulations! Your WordPress µ site has been configured.
You can log in using the username "admin" and password
Directory Permissions
Please remember to reset the permissions on the following directories:
You can probably use the following command to fix the permissions but check with your host if it doubt:
chmod 755
Further reading
- If you run into problems, please search the WordPress µ Forums where you will most likely find a solution. Please don't post there before searching. It's not polite.
- There is also the WordPress µ Trac. That's our bug tracker.
Thanks for installing WordPress µ!
Donncha
wpmu version:
No-www
WordPress µ strips the string "www" from the URLs of sites using this software. It is still possible to visit your site using the "www" prefix with an address like but any links will not have the "www" prefix. They will instead point at .
The preferred method of hosting blogs is without the "www" prefix as it's more compact and simple.
You can still use "" and URLs like "www.blog1." to address your site and blogs after installation but internal links will use the format.
www. is depreciated has a lot more information on why 'www.' isn't needed any more.