Skip to content

One File WordPress Deploy

This works great on Rackspace Cloud Sites, and eliminates the need to upload an archive or individual files. Script works by grabbing and unpacking the latest stable version of WordPress.

  1. Create a new file in your web root, ie: deploy.php
  2. Add the contents from below
  3. Upload the file
  4. Visit http://yourdomain.com/deploy.php
  5. When the script is complete, connect via SFTP and edit wp-config.php accordingly
  6. The script will have unpacked WordPress and deleted itself
  7. Behold the glory that is WordPress, and the fuzzy feeling that accompanies going from zero to WordPress in but a minute.
<html><head><title>One File WP Install</title></head><body><pre>
<?php
function jwwps_check_perms($name,$path,$perm) {
    clearstatcache();
    $configmod = substr(sprintf(".%o.", fileperms($path)), -4);
    $corrected = '';
    if($configmod != $perm && $_GET['jwwps-run'] == 'true') {
    	if(chmod($path, octdec($perm))) {
    		$corrected = 'Permissions Corrected';
    	} else {
    		$corrected = '! Permissions NOT Corrected !';
    	}
    }    
    echo "+$path $perm/$configmod $corrected\r\n";
    $corrected = '';
}

$url  = 'http://wordpress.org/latest.tar.gz';
$path = 'latest.tar.gz';
	$dir = dirname(__FILE__);

$fp = fopen($path, 'w');

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);

echo "Downloading $url\r\n";

$data = curl_exec($ch);
curl_close($ch);
fclose($fp);

echo "Unpacking archive...\r\n";

exec('tar -xzf '.$path,$ret);	
exec ('mv '.$dir.'/wordpress/* '.$dir);

rmdir($dir.'/wordpress');
unlink($dir.'/'.$path);

echo "Changing wp-config-sample.php to wp-config.php...\r\n";

rename($dir.'/wp-config-sample.php', $dir.'/wp-config.php');

echo "Creating .htaccess file...\r\n";

$file = fopen($dir.'/.htaccess', 'a');
fclose($file);

echo "Updating permissions...\r\n";

jwwps_check_perms("installation directory","../","0700");
jwwps_check_perms("wp-config.php","../wp-config.php",'0600');
jwwps_check_perms(".htaccess","../.htaccess","0600");
jwwps_check_perms("wp-admin/","../wp-admin","0700");
jwwps_check_perms("wp-admin/index.php","../wp-admin/index.php","0600");
jwwps_check_perms("wp-admin/js/","../wp-admin/js/","0700");
jwwps_check_perms("wp-content/themes/","../wp-content/themes","0700");
jwwps_check_perms("wp-content/plugins/","../wp-content/plugins","0700");
jwwps_check_perms("wp-content/","../wp-content","0700");
jwwps_check_perms("wp-includes/","../wp-includes","0700");

echo "Deleting self...\r\n";

unlink(__FILE__);
?>
</pre></body></html>

Schedule Your Discovery Call

Give us 30 minutes to get to know each other, to learn about your business and objectives. We'll offer solutions, advice and an honest assessment of how we can help you.

Posted in