2 define('WP_INSTALLING', true);
4 if (!file_exists('../wp-config-sample.php'))
5 die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
7 $configFile = file('../wp-config-sample.php');
9 if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
12 if (isset($_GET['step']))
13 $step = $_GET['step'];
16 header( 'Content-Type: text/html; charset=utf-8' );
18 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
19 <html xmlns="http://www.w3.org/1999/xhtml">
21 <title>WordPress › Setup Configuration File</title>
22 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
23 <style media="screen" type="text/css">
31 font-family: Georgia, "Times New Roman", Times, serif;
53 padding: 5px 5px 5px 20px;
58 .step a, .step input {
69 border-top: 1px solid #ccc;
77 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
79 // Check if wp-config.php has been created
80 if (file_exists('../wp-config.php'))
81 die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p></body></html>");
87 <p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
89 <li>Database name</li>
90 <li>Database username</li>
91 <li>Database password</li>
92 <li>Database host</li>
93 <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
95 <p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
96 <p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready, <a href="setup-config.php?step=1">let’s go</a>! </p>
103 <form method="post" action="setup-config.php?step=2">
104 <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
107 <th scope="row">Database Name</th>
108 <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
109 <td>The name of the database you want to run WP in. </td>
112 <th scope="row">User Name</th>
113 <td><input name="uname" type="text" size="25" value="username" /></td>
114 <td>Your MySQL username</td>
117 <th scope="row">Password</th>
118 <td><input name="pwd" type="text" size="25" value="password" /></td>
119 <td>...and MySQL password.</td>
122 <th scope="row">Database Host</th>
123 <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
124 <td>99% chance you won't need to change this value.</td>
127 <th scope="row">Table Prefix</th>
128 <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
129 <td>If you want to run multiple WordPress installations in a single database, change this.</td>
133 <input name="submit" type="submit" value="Submit" />
140 $dbname = trim($_POST['dbname']);
141 $uname = trim($_POST['uname']);
142 $passwrd = trim($_POST['pwd']);
143 $dbhost = trim($_POST['dbhost']);
144 $prefix = trim($_POST['prefix']);
145 if (empty($prefix)) $prefix = 'wp_';
147 // Test the db connection.
148 define('DB_NAME', $dbname);
149 define('DB_USER', $uname);
150 define('DB_PASSWORD', $passwrd);
151 define('DB_HOST', $dbhost);
153 // We'll fail here if the values are no good.
154 require_once('../wp-includes/wp-db.php');
155 $handle = fopen('../wp-config.php', 'w');
157 foreach ($configFile as $line_num => $line) {
158 switch (substr($line,0,16)) {
159 case "define('DB_NAME'":
160 fwrite($handle, str_replace("wordpress", $dbname, $line));
162 case "define('DB_USER'":
163 fwrite($handle, str_replace("'username'", "'$uname'", $line));
165 case "define('DB_PASSW":
166 fwrite($handle, str_replace("'password'", "'$passwrd'", $line));
168 case "define('DB_HOST'":
169 fwrite($handle, str_replace("localhost", $dbhost, $line));
171 case '$table_prefix =':
172 fwrite($handle, str_replace('wp_', $prefix, $line));
175 fwrite($handle, $line);
179 chmod('../wp-config.php', 0666);
181 <p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
186 <p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>