Recently I was faced with a dilemma where my host’s cPanel did not allow me to install WordPress into the root directory (i.e. without creating a new folder). If I left the instllation URL blank, it returned the error, “You must specify an installation directory!”. This particular host was using ‘Site Software v0.9.7′ for WordPress installation, and not Softaculous which I much prefer (Softaculous allows you to leave this field blank).
In any case, I searched for a solution on the matter and it was recommended that I nominate public_html as the folder since this is where all the public files exist. This was a poor suggestion though, because the automatic installation software ended up creating and installing into that folder, rather than using the host’s root directory. In the end, however, it made no difference because I would still need to move the files, regardless of the folder’s name.
Anyway, how do you (easily) move WordPress to the root directory?
Essentially there are only three main steps:
- Update your URL in WordPress’ general settings
- Move files from current folder into root directory
- Update the file path for uploaded media (see the comment below the article)
… Simple enough, but I’ll outline all the little details in between so as not to make any assumptions about your WordPress expertise. It’s important to follow these steps in the correct order. Also, please note that your site will be down during the time it takes you to move the files from one folder to the other (usually less than a minute).
- Back up any files in your root directory, such as index.php or your htacess file.
- Log in to your WordPress website and go to Settings > General (if you’ve only just installed it, this will be;
- In both the WordPress and Site Address URL fields, backspace over the folder name where WordPress is currently installed so that only your full domain name appears (e.g. ‘http://www.freenichewebsites.com’).
- Next, don’t panic! When you click Save your site will be (temporarily) inaccessible.
- Go back to your cPanel, then open File Manager.
- Open the folder where WordPress is installed by double-clicking the folder icon.
- Select all files in the directory (hold down CTRL or use SHIFT while selecting).
- Next, click the ‘Move File’ icon from the cPanel toolbar (a dialogue box will open displaying all the files that will be moved).
- In the last field of the dialogue box, you want to delete the folder name so that cPanel will move the files into the root directory (i.e. into ‘/public_html’). When ready, click ‘Move File(s)’.
- Lastly, while still in cPanel, go back to the root directory and DELETE the folder (which should now be completely empty).
- Your site should now be up and running in the root directory of your domain. [Edit February 21, 2014: There is one additional step - see the comment further below.]
The reason why we use cPanel and not FTP to move the files, is that the server will be much faster to complete the process. Like your hard drive, it can perform this function in seconds, rather than hours, and it avoids unnecessary downloading and uploading of your files.
I hope this has helped. As always, you’re welcome to leave a comment if you need something clarified.
If you’re anything like me, your website has multiple MySQL databases and, after a while. it can start to become difficult to manage. At times, when things go wrong, you can rely on your wp-config.php file to recover your database name and password… But what if you make the horrible mistake of overwriting your existing wp-config.php file with the wrong one. or simply deleting it by accident?
“Error Establishing a Database Connection”
This happened to me recently, and I spent a number of hours searching forums and knowledge bases trying to figure out how to fix it. Most discussions involved trying to insert a new password directly into the MySQL database using special hashing techniques (encrypting a new, plain text password), and then updating your wp-config.php file accordingly. But the solutions I found is so much easier!
It’s a simple case of adding a new user to your database
The only thing you need for this solution to work is the name of your database, and you can easily get this through your cPanel. This fix should get your site back up and running in less than five minutes:
- Log in to your cPanel, and go to MySQL Databases.
- Scroll to the section that says ‘MySQL Users’ > ‘Add New User’, then create a new user, remembering to copy your username and password into a safe location.
- Scroll to ‘Add User To Database’, then add the user you just created to the relevant database. If you’re lucky, you’ll only have one database to choose from. If there’s more than one, look for a WordPress database. The syntax is usually username_wp123 (where username is the first eight characters of your host login, and the numbers were randomly generated at the time of installation).
- Next, grant ALL PRIVILEGES to the new user.
- Now it’s just a simple matter of inserting this information into a new wp-config.php file. If you’ve deleted all instances of this file, you can use wp-config-sample.php to create a new one (this file is included in your WP root directory by default).
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
- Edit, save, then upload the file via FTP into your root WordPress directory.
- Your website should now function normally! (If not, leave a comment.)