I’ve wanted a blog site for a while and finally decided to make it happen. So, here we go with my first post. Let’s talk about how this came together.
I was glad to find that my domain name was available after searching on GoDaddy.com. I researched their product offerings and discovered that they offered WordPress hosting for about $5/mo. They included e-mail hosting for my domain but required payment up front. I looked around a little more and found that BlueHost.com provides the same type of service for about $3/mo. However, they require a 3 year contract and upfront payment. I have experience with Azure so I checked them out. They offer an attractive option to stand up a template via PaaS web app service. However, this option would cost money, not include e-mail hosting and reduce the flexibility of having access to the actual host. I have wanted to get experience with AWS so I looked at them next. They offer a free tier that allows me to stand up an EC2 instance with WordPress installed. Free service plus AWS experience won me over.
I go back to GoDaddy, create an account and purchase petesepulveda.com for about $12/year and I opted for the privacy protection. I didn’t want people to be able to find my address by doing a simple WhoIs search. I have the domain name now and need somewhere to point it to. This is where I created an account with AWS and spun up an instance according to the documentation here. Ok, so now we have a domain name and a WordPress server. Time to find a WordPress theme, e-mail hosting and productivity apps.
Sure, I could have just paid for this service with GoDaddy. However, I decided to go with Google Apps which would allow me to have Gmail as my backend and the use of Google Apps. I’ve always used Microsoft products and decided it was time to get some experience with Google Apps. Who knows, perhaps Google Apps may be a good fit in my next company. Anyhow, you basically sign up for Google Apps where you get 30 days for free and then it only costs $5/mo/user. After you sign up you configure your e-mail to work with your custom domain name.
Gmail provides you with a TXT DNS record so that you can verify that you own your domain name. You have to go back to GoDaddy, find your domain name and click on the Manage DNS option. Look for the link to add a new record. The type will be TXT and name will basically be @. You then go back to the Gmail setup and tell Gmail to verify the domain. Once verified Gmail will give you a list of SMTP servers that you should direct email to. You have to go back to the DNS management page in GoDaddy and create an MX record for each SMTP server that Gmail provides you. Use the recommended priority and remove any MX records that GoDaddy may have already configured.
Almost there, now go back to the Gmail configuration and create an e-mail address for the user account that was created when you signed up for Google Apps. I made mine email@example.com and also created an alias of firstname.lastname@example.org because I was stupid enough to put that e-mail address on my resume that I was already sending out. Wanted to ensure I didn’t lose any e-mails so a simple alias fixed that.
Make sure you test your changes. You can go for broke and just send an e-mail to your new address and see if it shows up in your new Gmail mailbox. If that doesn’t work then make sure DNS is resolving correctly by opening up the command prompt on your PC and typing in “nslookup”. Now that you are in nslookup you need to type “set type=mx” so that nslookup knows to query for MX records. Now type in your domain name, hit enter and you should see the SMTP servers that you added in your manage DNS page. If you don’t see them then verify your configurations were saved in GoDaddy.
Let’s find a good Word Press Theme. I wanted a template that would highlight my resume and capabilities. This will be my living resume and also my personal technology blog. After a quick google search I landed on ThemeForest and selected the Perfect CV theme. I thought it was clean and professional. I purchased the theme which allowed me to download a zipped file. Congratulations you now have a theme.
Now we need to figure out how to add it to your WordPress site. Remember, you spun up a WordPress site on an AWS instance??? You need to go into your AWS console and find your running instance. After you find your running instance you want to highlight your instance and then click on the <Actions> button then <Instance Settings>–><Get System Log>. Scroll to the bottom of the log and you’ll find the admin password that was generated when the system was built. Go back to the AWS console and look at the instance you selected previously. You should see a public IP address that was assigned to the instance. Take this IP address and use it in the URL http://<your IP address>/admin. This should bring up the Admin login for your WordPress instance. The user name is “user” and the password is what you recovered from the System Log.
Look on the menu for <Appearance> hover over this and select <Themes>. At the top there is an option to add a new theme. Select this option and then navigate to the zipped theme files you previously downloaded. There is no need to unzip the zipped contents as WordPress will take care of this for you. I made the mistake of unzipping first and then trying to add the theme. I ran into an error and had to research until I figured out that I just needed to provide the zipped file.
If you choose the same theme that I did then you start by going to <Appearance> and <Customize>. It’s pretty self explanatory at this point to configure the look and feel. Just remember that you sometimes have to go back to the WordPress admin site when adding Experience and Education. You’ll basically jump back and forth between the <Appearance>–> <Customize> and the Admin site to get everything working.
Point Custom Domain to Your Site
You don’t want users having to type in your IP address as the address. You need to go back to GoDaddy.com DNS Management and create some Host “A” records that point to your public IP address. I created a host record for @ and another one for “www” that both point to the public IP address for my WordPress server. After you create them you should be able to navigate to your site using your new domain name.
Now, I get to talk about some fun I had trying to get e-mail to work for not only my WordPress site but also the “Contact Me” form in the theme that I installed. If you bare with me I will get to the last step that you have to do in order to get e-mail to work. Ok, so everything is supposed to just work right? Yeah, not so much for me. I couldn’t get the Contact Form to send an e-mail. So, naturally I look into the Admin page and notice that my WordPress instance came with some Plug-ins. Well, did these come with the Theme or with the WordPress install. I didn’t know so I assumed they were needed for the Theme I installed. Yeah, I know that we should never assume in technology but I did.
I first turned my attention to the Contact Form 7 plug-in which I assumed was used to provide the form in the Theme. Wrong, it was pretty frustrating to make changes to the Plug-in settings and see absolutely no affect on the site. While troubleshooting the “Contact Form” issue I learned that the entire site could not send e-mail as well. This capability is completely independent of any themes. I was able to verify that by going to http://petesepulveda.com/login and clicking the “Lost your password” link. When the site cannot e-mail you that means you have a WordPress issue and not a Theme issue.
I solved this problem by installing the wpMandrilla plug-in. Mandrill uses MailChimp which is pretty popular for e-mail. I created a new account on Mandrill.com which allows you to send/receive up to like 2,000 e-mails a month for free. They also provide you with some nice analytics and logs for troubleshooting. Anyhow, during the setup process you have to generate a client id which basically allows you to provide authentication for using their API. I did this, enabled the plug-in and configured Mandrilla to send e-mails to my custom e-mail address. This solved the problem with my WordPress site being able to send e-mail. However, I still could not send e-mails via the Contact Form on my theme. While troubleshooting I figured out that I could only send e-mails using the Contact Form if I put in my email@example.com address as the from address. Any other e-mail address would cause Mandrilla to reject the e-mail because it was thinking I was trying to spoof the from address which in essence I guess I was.
At this point in time I still hadn’t figured out that the Contact Form 7 plug-in had nothing to do with my theme. So, I’m messing around in there trying to figure out how to not spoof the from address and include the person’s e-mail address in the body. Needless to say that was a fruitless effort. I decided that Mandrilla was not the correct solution and looked at another plug-in called “Postman SMTP”. This plug-in uses the Gmail API and as such requires you to verify that you own your domain. You need to put in SPF and DKIM domain records in your DNS configuration on Go Daddy and generate a key to use their API. After configuring the plugin and my DNS, I was able to send e-mails using this plugin. However, every e-mail that came from the Contact Form showed that it came from me and did not include the e-mail address that the user typed in the “From” field in the form. That presents a challenge when trying to reply.
After performing additional research I learned that the Theme and it’s form should “just work” and that all it needs is the PHP mail() function. I decided to disable all of the mail related plugins along with the Contact Form 7 plugin. Now it’s time to ensure that mail() function is working on my server. You need terminal access to the server so here is how to do that. Login to your AWS console, select your instance and click Connect. You will be presented with a screen that shows your public DNS record for your instance. You need to download putty.exe and puttygen.exe if you don’t already have these apps. Just do a google search for putty download and you’ll find them easily. You have to first use puttygen.exe to convert your AWS private key to a format that putty.exe likes. After you convert the key from a .pem to .ppk file you save it and open putty.exe. On the first screen of putty.exe you look on the left hand side and drill down to Connection –> SSH –> Auth and select your .ppk file. You then take the public DNS entry you gathered from AWS console and use that for the host name to connect to. Create the connection and you should be into your AWS instance.
Once in your AWS instance you need to verify that sendmail is installed. You can easily do that by running apt-get install sendmail . If it tells you that sendmail has already been installed then you can proceed to testing sendmail. If not, then choose Y to install and configure sendmail. After sendmail has been installed you can test by creating a small test script as shown below.
error_reporting( E_ALL );
$from = “firstname.lastname@example.org”;
$to = “email@example.com”;
$subject = “PHP Mail Test Script”;
$message = “This is a test from the script”;
$headers = “From:” . $from;
echo “Test email sent”;
Save the file as test-mail.php. Now test the ability to send e-mail by typing php ./test-mail.php . If it tells you that “test e-mail sent” then you’re good to go. If you’re like me that would be too easy and you’ll actually get an error message. I got an error message that /usr/bin/sendmail did not exist. Well, that was correct because sendmail was actually in /usr/sbin/. So, PHP was looking in the wrong place. That’s great! Now, if I only knew how to tell PHP to look in a different place. After googling I discovered that I had to edit the php.ini file. I did a locate php.ini command and found the location of the php.ini file. I opened the file for editing using VI and searched for “sendmail”. I found a commented out line that had the path to sendmail. I edited the line to say /usr/sbin instead of /usr/bin and saved the file. I restarted the WordPress instance by running service bitnami restart . I tested the Contact Form on my site and it actually worked.
I hope this blog helps you out if you are trying to setup a site similar to mine. If not, I at least hope you can relate to the struggle to figure out new technologies. Such a great feeling when you finally solve the problem. Please drop me a line if you found this article helpful in any way or have any other specific details that you think should be added to this post.