Install Nginx on CentOS 6 and Amazon Linux AMI

This how to guide details the process to install Nginx on CentOS 6 and Amazon Linux AMI.

Nginx (pronounced engine-x) is gaining popularity as an alternative to using Apache. I won’t weigh in on the argument as to which is better, as they each have their own strengths and weaknesses which I’m sure there are plenty of other documents available on the internet which discuss these at great length. Instead I will show you a simple way to get up and running with Nginx on CentOS or Amazon Linux AMI.

Continue reading…

KVM Virsh Console Access to Linux VM – CentOS 6

This document will show you how to get virsh console access to guest virtual machines.

The console command within virsh is an excellent feature to have working for your virtual environments. For example, it can be really handy to watch a machine boot without launching a GUI tool ie. virt-manager. I personally find virsh console access a quicker way to configure networking settings which may not be able to be achieved via SSH, other than using virt-manager.

[box type="info"] Just note that this document assumes CentOS 6 for all example code and references. Syntax, file locations and codes may vary based on your distribution.[/box]

Typically out of the box, when you install a new CentOS 6 virtual machine, the “virsh console” command will not work…

Step 1: Configure Serial Terminal

On your new CentOS 6 virtual machine, you’ll need to configure ttyS0. This serial interface is how “virsh console” gains access to your virtual machine.

Log into your virtual machine…

Create new ttyS0 config file

Copy/Paste the following config

Step 2: Allow login into ttyS0

By default CentOS will not allow a user to login via ttyS0 unless we modify securetty.

Add the following to the end of the file and save it.

Step 3: Start ttyS0

Make ttyS0 available, from your terminal execute the following command

Step 3: Test Virsh Console

From your KVM server, connect to the console of your virtual machine

Step 4: Configure Access to Boot Output

To watch your virtual machines boot/shutdown messages we need to make a couple of changes to your boot process.

Edit your grub config

Your kernel entry may look something like this

You’ll want to remove the “rhgb” option, this is the boot splash screen. The “quiet” entry hides a lot of boot messages, I remove so more detail is outputted.

Finally you’ll want to add “console=ttyS0″ to send the boot messages to your virsh console. Your kernel line may now look like this

[author] [author_image timthumb='on']http://mcdee.com.au/wp-content/uploads/2012/11/photo.jpg[/author_image] [author_info]Andrew McDonald is an IT Systems Admin and all round technology junkie. Absolutely a jack-of-all-trades and not one to shy away from a challenge.


[/author_info] [/author]

Tutorial – Install SSL Certificate in Apache Virtual Host on CentOS 6

In this tutorial I’ll take you through installing a SSL certificate and intermediate certificate in an Apache virtual host running on CentOS 6.

You’ll need to generate your servers private key which is used to create your certificate signing request (CSR) and also matched to your public SSL certificate. The CSR contains the details about the domain name, your organisation and server details. The CSR is passed onto the company you wish to purchase your certificate from. They use your CSR to create the public SSL certificate that your users need to access your web services securely.

The public SSL certificate that you get created must then be copied onto your server. You’ll then configure Apache to load that SSL Certificate, along with an intermediate certificate if required, to provide secure access to your web services (typically a website).

[box type="info"] Just note that this document assumes CentOS 6 for all example code and references. Syntax, file locations and codes may vary based on your distribution.[/box]

Step 1: Setup Simple Directory Structure

I like to maintain a simple directory structure for my SSL certificates, you may skip this step however just make sure you substitute my directory paths with yours.

Step 2: Generate Servers Private Key

You may already have a private key created for your server, however I’d suggest creating a new one. This due to the fact that most CSR’s require 2048bit encoding.

[box type="warning"] Note, you can set a pass phrase on your certificate to make it more secure, however the downside to doing this is that you will be prompted for the password everytime Apache starts up. Securing the key via file system permissions and general server security is my recommendation.[/box]
Check the file was generated where you wanted it

Change the file permissions so that only the root user can read the file

Step 3: Generate the CSR

Now we can generate our CSR, the entry fields are self explanatory.

[box type="info"] If you are wanting to generate a wildcard certificate ie. secure all subdomains, then all you need to is enter *.website.com for the Common Name prompt[/box]
Lets have a look at what a CSR looks like.

Step 4: Generate your Public SSL Certificate

This step will vary depending on the vendor you use. However you will be required to provide a copy of your CSR (as seen above). You’ll need to copy/paste all lines including the BEGIN/END certificate request lines into your vendors request system. I’d suggest reading their examples of this process.

Once you’ve successfully submitted your CSR, your vendor will then provide you a SSL certificate. It may be attached to an email as a .crt file, or could just be text in the body of an email. If they have provided you with just text, then copy/paste the text (including the BEGIN/END lines) into file on your server. If it’s a file then copy it onto your server.

I’d suggest naming and placing the SSL certificate file into

If you received instructions to install an intermediate certificate, then copy it as

Step 5: Configure Apache to use SSL

In this example I’ll show you how to install the SSL certificate into an virtual host. So firstly we need to make sure Apache is configured to support port 443 for name-based virtual hosting.

You’ll need to make sure that the line “NameVirtualHost *:443″ exists in your Apache configuration file.

If the above command doesn’t return any result, then you’ll need to add “NameVirtualHost *:443″ into httpd.conf. Just search for NameVirtualHost and add it on the next line.

Now you’ll need to add a new entry that contains your virtual host configuration for SSL. I would suggest you simply copy/paste your existing VirtualHost configuration and simply modify the directive to be . Then within the context of your newly created directive add the additional SSL settings. See below for an example:

…Restart Apache and you’re done!!

[author] [author_image timthumb='on']http://mcdee.com.au/wp-content/uploads/2012/11/photo.jpg[/author_image] [author_info]Andrew McDonald is an IT Systems Admin and all round technology junkie. Absolutely a jack-of-all-trades and not one to shy away from a challenge.


 [/author_info] [/author]