├── license.txt ├── README.md └── wp-setup.php /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 by Gilbert Pellegrom 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### This repo is no longer maintained. If you would like to take over ownership please [get in touch](mailto:gilbert@pellegrom.me). 2 | 3 | # WordPress Setup 4 | 5 | WordPress Setup is a script you can literally drop into your development environment (or live setup) that will, once run, 6 | automatically download the latest version of WordPress and create the database for you, so you can skip straight 7 | on to installing WordPress. 8 | 9 | [Watch the Demo](http://screenr.com/P65) 10 | 11 | ## Requirements 12 | 13 | * PHP 5 or greater 14 | * MySQL 4.1.2 or greater 15 | * MySQL user with "CREATE DATABASE" privileges 16 | 17 | ## Usage 18 | 19 | * Download and extract 20 | * Put the wp-setup.php script in your (development) root directory 21 | * Navigate to the script in your web browser 22 | * Insert the required information and sit back and wait for the magic to happen 23 | * Done 24 | 25 | ## FAQ 26 | 27 | ### Can't I just use WP Multisite? 28 | 29 | Yes of course. But sometimes your development environment might restrict you from using WP multisite. 30 | For example if you use localhost with a port number (http://localhost:8080) you won't be able to install 31 | WP Multisite. 32 | 33 | Or maybe you just want to use sepearte installations for each WP site. WordPress Setup makes that easy. 34 | 35 | ### Why can't I have a "wordpress" directory in the same folder? 36 | 37 | WordPress Setup works by downloading and extracting the latest version of WordPress to a folder called 38 | "wordpress" and then renames that folder to whatever name you chose for your installation. It does this because 39 | of the way WordPress is archived in the ZIP file (don't ask). 40 | 41 | ## License 42 | 43 | WordPress Setup is released under the MIT license. 44 | -------------------------------------------------------------------------------- /wp-setup.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | WordPress Setup 13 | 18 | 19 | 20 |

WordPress Setup

21 | Error: The installation directory '. $base_dir .'/'. $install_name .' already exists.

« Back

'); 73 | } 74 | if(is_dir($base_dir .'/wordpress') && (!isset($_POST['overwrite']) || $_POST['overwrite'] != true)){ 75 | die('

Error: The directory '. $base_dir .'/wordpress already exists.

'. 76 | '

This directory will be overwritten. Are you sure you want to continue?'. 77 | '

78 | 79 | 80 | 81 | 82 | 83 |

'); 84 | } else { 85 | if(!isset($_POST['overwrite']) || $_POST['overwrite'] != true){ 86 | if(!mkdir($base_dir .'/wordpress', 0777)){ 87 | die('

Error: Failed to create the directory '. $base_dir .'/wordpress. Please create this manually.

'); 88 | } 89 | } 90 | } 91 | 92 | echo '

Downloading the latest version of WordPress...

'; 93 | $zip_file = $base_dir .'/'. $install_name .'.zip'; 94 | 95 | if(function_exists('curl_init')){ 96 | $fp = fopen($zip_file, 'w'); 97 | $ch = curl_init('http://wordpress.org/latest.zip'); 98 | curl_setopt($ch, CURLOPT_FILE, $fp); 99 | curl_setopt($ch, CURLOPT_TIMEOUT, 60); 100 | $data = curl_exec($ch); 101 | curl_close($ch); 102 | fclose($fp); 103 | 104 | if($data === false){ 105 | die('

Error: Failed to download the latest version of WordPress.

'); 106 | } 107 | } else { 108 | $data = @file_get_contents('http://wordpress.org/latest.zip'); 109 | if($data === false){ 110 | die('

Error: Failed to download the latest version of WordPress.

'); 111 | } else { 112 | file_put_contents($zip_file, $data); 113 | } 114 | } 115 | 116 | echo '

Unzipping archive...

'; 117 | $zip = new ZipArchive; 118 | $res = $zip->open($zip_file); 119 | if($res === TRUE){ 120 | $zip->extractTo($base_dir); 121 | $zip->close(); 122 | unlink($zip_file); 123 | } else { 124 | echo '

Error: Failed to unzip the archive '. $zip_file .'. Please unzip manually.

'; 125 | } 126 | 127 | if(!@rename($base_dir .'/wordpress', $base_dir .'/'. $install_name)){ 128 | echo '

Error: Failed to rename '. $base_dir .'/wordpress to '. $base_dir .'/'. $install_name .'. Please do this manually.

'; 129 | } 130 | 131 | echo '

Creating database...

'; 132 | $con = @mysql_connect($db_host, $db_user, $db_pass); 133 | if(!$con){ 134 | die('

Error: '. mysql_error() .'

'); 135 | } 136 | if(!mysql_query('CREATE DATABASE '. $install_name, $con)){ 137 | echo '

Error: '. mysql_error() .'

'; 138 | } 139 | mysql_close($con); 140 | 141 | echo '

Success! Continue »

'; 142 | } else { 143 | echo '

Error: You must include '. comma_list_ended($error) .'

'; 144 | } 145 | 146 | } else { 147 | $running = false; 148 | } 149 | 150 | if(!$running){ 151 | ?> 152 |
153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 |
Lowercase and underscores please. Used for site slug and database name (e.g. "test_wp" would create http://localhost/test_wp etc.)
Will be "localhost" most of the time
Must be a user with "CREATE DATABASE" privileges (probably root)
175 |

176 |
177 | 178 | 181 | 182 | --------------------------------------------------------------------------------