Skip to content

cPanel

Created: 2016-07-05 22:54:02 -0700 Modified: 2020-05-26 13:29:18 -0700

  • ”WHM” is “WebHost Manager”
  • Name servers (kw: nameservers) are managed through your domain registrar, not cPanel.

cPanel → Redirects → Select your site from the dropdown → https://example.com, check “Redirect with or without www” and “Wild Card Redirect”.

If you want something like “SOME_SUBDOMAIN.example.com” to redirect, then you have to make the subdomain first before being able to set up the redirect.

Allowing AutoSSL to work with redirects

Section titled Allowing AutoSSL to work with redirects

I wanted android.bot.land to link to the Google Play Store (i.e. not my server, this site). So I set up a non-wildcard redirect so that just android.bot.land will link to that, then AutoSSL can still work.

They just call their tool the “Zone Editor”, so if you ever need to add a TXT record, you can do so through that page. There’s nothing really difficult about it.

There’s a Let’s Encrypt plug-in that’s super easy to use. I just went to that plug-in and clicked “Issue” for each subdomain. I did NOT include the “www” versions of each subdomain since I didn’t have those configured in Route53 (my DNS provider).

Just follow the reference link’s instructions. The whole thing takes maybe 2 minutes.

I did not treat the email as an alias, and I set the reply-to address to the one on cPanel, not my typical Gmail address, that way responses will go to the cPanel address.

I had to set the port to 465.

You take the SMTP server from what cPanel tells you.

After that, it’s helpful to add a cPanel Forwarder to your personal email address (so that you can receive mails in Gmail in addition to being able to send them from Gmail).

Setting up a MySQL database really quickly

Section titled Setting up a MySQL database really quickly
  1. Use MySQL Databases to create a database, a user, and add the user to the database with all privileges. Alternatively, use the MySQL Database Wizard to do all of this.
  2. Use phpMyAdmin through the cPanel to manage the database.
  3. Use a PHP script like this (name it db.php):
<?php
$servername = "localhost";
$username = "name";
$password = "pw";
$dbName = "foo";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
  1. Ensure that worked by connecting to the URL where db.php is located.
  2. Write queries using $conn->query(“SELECT 1”); (reference). Here’s a quick example of some simple queries I tried:
// Simple INSERT
$result = $conn->query("INSERT INTO `donations`(`ip`, `amount`) VALUES (\".$ip."\, ".$amount.");");
if (!$result) {
$error = mysqli_error($conn);
if (strpos($error, 'Duplicate') === 0) {
echo '{error: "dupe"}';
} else {
echo '{error: "unknown"}';
}
die();
}
// Simple SELECT
$result = $conn->query("SELECT SUM(amount) AS amount, COUNT(1) as num_donators FROM donations;");
if (!$result) {
die();
}
$resultAsArray = $result->fetch_assoc();
$amount = $resultAsArray["amount"];
$numDonators = $resultAsArray["num_donators"];
echo json_encode($resultAsArray);

You can enable it right through cPanel. If you configured Gmail to send your mail through POP/IMAP, then I believe you don’t need a DKIM signing key on Gmail since it’ll go through your domain in the end anyway.

With WordPress and MediaWiki, I was unable to connect to the database on BounceWeb. The server administrators had reconfigured a bunch of stuff, and this script didn’t work as testconnection.php:

<?php

$link = mysql_connect(‘localhost’, ‘oenxnet_wp293’, ‘PASSWORD’);

if (!$link) {

die(‘Could not connect: ’ . mysql_error());

}

echo ‘Connected successfully’;

mysql_close($link);

?>

Taken from: http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/

I went into MySQL Databases through cPanel and edited oenxnet_wp293. I chose “all privileges” and clicked “Make Changes” and I got some error about “There is no such grant defined for user ‘oenxnet_wp293’“. Apparently you need to contact the site administrators when this happens.

NOTE: before contacting them, try explicitly changing your MySQL password to what you think it is. You can do this through the “MySQL Databases” section in cPanel.

”Domain already exists in Apache configuration”

Section titled ”Domain already exists in Apache configuration”

I got this error: The domain “botland.net” already exists in the Apache configuration.

Turns out my CPanel was being managed by Leaf, and a LONG time ago I had botland.net pointing at something else, so he just reset it for me.

External emails stopped sending and receiving

Section titled External emails stopped sending and receiving

Note: for general problems, just search for “Email Deliverability” in cPanel itself and it should tell you which issues are there. You can then just click “Repair” (it may generate an intermediate suggestion, in which case just click “Repair” again to accept it). 500

Problem: I can send an email from between addresses when both are “@mydomain.com”, but not when the sender is some other domain.

Potential causes:

  • Check to make sure your MX record points to the correct IP address as reported by “Shared IP Address” in the “General Information” section of the cPanel landing page.
  • Remember that you can’t set MX record to an IP address (reference). Just make an “A” record representing the IP address you want to set the MX record to:
    • Make an “A” record named “mx.yourdomain.com”
    • Then, make an MX record that points to “mx.yourdomain.com”
    • You do not need a subdomain at “mx.yourdomain.com” for this to work since this is just for DNS records.
  • Finally, cPanel’s default MX-record TTL seems to be 4 hours, so you may fix this immediately but not be able to verify the fix for several hours depending on caching time.

Note: if you ever update your MX record because your email had broken, you may also need to update any email clients that you use. I had email set up through adamlearns.live, but then I made Firebase Hosting control the main IP address, so there were no MX records any longer. When I went to configure Gmail again, cPanel said that I should use mail.adamlearns.live, but it was a CNAME for Firebase’s hosting, so I had to make it a CNAME for mx.adamlearns.live (an “A” record I made just to point to the original IP from before I set up Firebase). However, the TTL was 4 hours, so I had to wait.