The next to last paragraph in the first article on this subject went like this,
Going hand in hand with Cpanel is WHM, the WebHost Manager (this will be important in the next section) Their user documentation is here and here. If your web host uses Apache they are most likely going to be using Cpanel and WHM as the control panel and manager for the hosting service. Once you have signed up with a web host you are now dabbling in web hosting, at least vicariously. WHM is your best friend when managing a web host. You should probably get to know your new best friend better.
If your site is part of another site, you might have more to do than just trying to break your new web host’s software. You have real work to do breaking other stuff first. Before doing anything else, even if you have a completely new site, you should probably make sure that you have a clean backup of your current website. This is the kind of common advice that gets a well duh response, but every time there is an unrecoverable oops event, it is because someone ignored the well duh advice. Backing up isn’t the easiest thing to do with a hosted web account. It isn’t easy because a simple duplication of your online files will not give you something that you can restore your site from. Backup in cpanel requires you to backup your files and databases separately if you want them to be available to be used to restore an oops event. So do a backup, and then keep reading.
No, Seriously. Backup!
Done? Good. So now you want to create your new website, right? A personal place all your own to host your blog on. You want to create a separate web site because you are borrowing space from a lifelong companion not known for her neat, organized workspace (Ouch! Don’t throw things at me! It’s true and you know it!) and you’d like to know what part of this mess is yours to deal with. This will require you to access WHM, the WebHost Manager. Since you are creating an account for yourself (or myself, in this case) be generous. But don’t worry, you can change the package and account settings later. As is typical with linux GUI’s, some of the settings will say they have been changed or can have particular values, but the implementation of the setting may fail because of limitations that your web host places on your account. This is the one bright point about hosting for yourself, the thing I told you that you didn’t want to do in the first installment of this series. The only bright spot in self hosting, being able to set any hosting variable to any allowed value. This isn’t necessarily a good thing.
Make sure that autoSSL is included as part of the feature set of whatever package you end up creating. SSL? Secure Sockets Layer. It allows you and your visitors to establish an encrypted connection between the two of you. AutoSSL generates a certificate for you at your new hosting location, so you will want it enabled. If it isn’t, you will not be able to be certified as an HTTPS location on the web, and that is bad on today’s internet using todays browsers. WHM will generate an error if you set your bandwidth to unlimited and disk usage to unlimited when you set up your package, and this error will keep you from successfully creating an SSL certificate. You can set the bandwidth to 100GB if you want (one hell of a lot of data) It just can’t be unlimited. Like I said, not a good thing to be able to muck about with all the settings.
Once you have your package set up the way you want it, the way you are allowed to set it up, create your account from the create new account tab on the sidebar menu. Select the package you just created. If you followed your web hosts rules correctly it should show as green and selectable. If you aren’t planning to resell or offer to piggyback your needy relatives on your web host, you can skip package creation and just go straight to account creation. When you get to the menu for “select package” simply toggle the Select Options Manually checkbox, and you can piss off your web host all over again by selecting values that aren’t allowed while simultaneously creating your account. This will save you the trouble of trying to figure out what your web host will allow while creating the package that you will only need once anyway, but you won’t get to give it that special name if you don’t create the package in advance. For me, naming is important. You may be content to let someone else pick the names you use. To each his own.
Get the important stuff right! Check the domain name. Check the user name. Write down the password. Make sure the email address is a working email address. The only default setting that I needed to change on our web host was toggling the recommended setting for mail routing to Automatically Detect Configuration because, again, if if the host can find it, it will find it. If not, you can always figure out what it is later. Hit Create and you are done.
Now comes the fun part, and when I say fun I mean tooth extraction levels of pain. But fun, you know? Since you are migrating your (my) wordpress installation, you’ll have to duplicate the SQL database that makes the installation do what it does in its current location. SQL? Sequel. Structured Query Language. You don’t really need to know what it does (but the link will tell you all about it) you just need to know that you need it. If you only copy the files from the software installation that you are migrating, you may or may not notice parts of your installation working the same way later. You’ll need to access PHP admin. PHP? It’s yet another scripting language (see? Fun!) PHP stood for Personal Home Pages back at the dawn of time, but now stands for Hypertext Pre-processor. I think we’re up to version 7 as I type this. I seriously couldn’t care less. I wish I could work up to caring at least a little. Trying to make Linux work for a decade burned me out on caring about coding, one failed install at a time. AutoCAD Lisp was a walk in the park next to getting Linux to run on mystery hardware. Now I just want the software to WORK, DAMMNIT! I want it to work pretty much 24/7 without my having to do anything about it. It’s enough to make you wish you had the money to pay Squarespace to do this all for you. But I digress.
Accessing the PHP manager will allow you to copy out your SQL commands so that they can be applied to your new account. You’ll want to follow the directions of your web host for doing this. Just make sure you verify which SQL command list is associated with your current install beforehand, then go to the PHP manager, highlight the right SQL database (not expand it) in the sidebar, select the export tab (detailed) and make sure that add DROP TABLE/ VIEW/ PROCEDURE/ FUNCTION is selected (this should be in the options section) Export as SQL. Next you will go into your new account, use the SQL wizard to create a new database, associate the database with the user for the account, and then import the SQL file you downloaded earlier. Wipe the sweat off your brow, because that was the hard part of this process.
Time to export all those collected years of hard work. Don’t slip up! Grab your current install of WordPress from the directory that it is in. It should be about twenty-two files, four of which are folders, including one named wp-content. Once you have located those files, zip them up through the cPanel file manager interface, and download them to your local drive. Then you open your new account, go to the file manager, and upload the same zip file to a directory there. I suggest using the tmp directory. That is what temporary directories are for, things you will delete later. move the files and folders from where they land in tmp and paste them to the public_html folder. Verify that the file and folder structure matches your previous files and folders before doing anything else.
Now it is back to coding, again (I’m sorry) You will need to edit your wp-config file in order to modify a few commands so that they point to the new SQL database. This is where writing down your username, password and SQL command list name comes in handy. Open the wp-config.php file in a text editor, like Windows notepad or the native editor in CPanel. Scroll to the lines in the file that say DB_NAME, DB_USER and DB_PASSWORD and then modify the SQL database name username and password with the information that you wrote down previously. Because you wrote it down like I said, right?
Put on your dunce cap, because it’s time for a test! Don’t Panic! This is a website test, you won’t have to cram for the exam. To conduct this test you will need to modify your WordPress config file in the new location, similar to what we did in the last paragraph. There are other ways to test the configuration including logging into the wordpress installation directly and altering the file storage location in settings, and modifying the SQL database to point to the new location, but the test method I chose was modifying the wp-config.php file because I was in that file already. Insert two lines into the code that read as follows, replacing yoururl with the URL that your new installation is currently residing at.
After you do that go back to your original installation location and backup the existing WordPress installations wp-config.php file. After you do that replace the wp-config.php file with an empty text file by creating a new file with that name. This is just a test, and if you backed up like I told you to, you can always revert to the correct wp-config.php if the test fails. Then open your browser and type in your test URL and click on a few links to make sure that everything displays properly.
Nothing sideways? Everything where it is supposed to be and working correctly? Great!
Once you are satisfied that the new installation is working correctly, you can reedit the new locations wp-config.php with your real URL name, and then redirect your URL to point to the new location on your web host. You do this from within CPanel in your old location, deleting the URL from the Domains menu, and then adding the URL to your new location. Once you have successfully moved the URL to your new web host location, you are done. Log back on your site and bask in marvel of your unique genius and programming wizardry. Unless of course, the site doesn’t come up like it is supposed to. If not, go back through the steps and make sure you hit all the points correctly.
If all else fails, even the cheapest of web hosting sites will have some form of chat available to paying customers. Log on the chat and see if they can help you. Just don’t panic. It’s just electrons whizzing around in space. It isn’t the end of the world if the website is down a few days. You’ll get it back up because you made a backup, and you didn’t delete the old installation yet.
Wait. You did make a backup, right? Oops?