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…

Install Python Boto on CentOS 6

I’ll quickly take you through installing Python & Boto on CentOS 6 for use with Amazon Web Services (AWS).

Boto is an interface to access all of the Amazon Web Services via the Python programming language. Using Boto you can write some handy scripts to automate simple things like starting or stopping EC2 instances or taking regular snapshots of your servers..

All the syntax listed here is executed via the command line. Simply open a terminal window and you’re good to go

Installing Python and Python development libraries:

I install the python-devel package as you’ll find you may require them in the future when attempting to install additional Python packages.
Continue reading…

Install FastCGI with PHP in Apache on CentOS 6

How to install FastCGI with PHP in Apache on CentOS 6.

Here’s a quick and simple way to get an Apache virtual host configured have FastCGI handle PHP. This is useful if you wish to use suEXEC or have tighter control over the usage of PHP. THis could be restricting certain PHP fuctions etc.

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.

Step 1: Install Packages

First step is make sure we have the required packages installed. Assuming you already have the PHP module installed, we’ll just need to install a couple of extra packages:

Continue reading…

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]

Tutorial – Passwordless SSH Using Private Keys with CentOS 6

This document we’ll go through the process of configuring SSH client to login without a password using a private key. This can be a convenient, fast and potentially more secure way to access a remote system… Best thing, it’s actually very simple to achieve!

Step 1: Generate Your Key

Start by being logged into your local system and generate your private key using the command “/usr/bin/ssh-keygen”:

We now have a generated private and public key set, the key’s are typically created as /home/user/.ssh/id_rsa & /home/user/.ssh/id_rsa.pub.

[box type="warning"] Beware that your private key is an extremely valuable file. It’s like storing your password in a file. If obtained, could be used by another person to access your systems. Back it up and keep it safe!![/box]

Step 2: Share Your Key

To use your private key, you must share your public key with a remote server. Simply put, the remote server keeps a copy of your public key, which it uses to match against your private when you attempt to login.

There is a utility which automatically installs our public key onto a remote host; ssh-copy-id. Obviously it won’t work unless you already know the password of the account on the remote host.

…and that’s it. The ssh-copy-id program automatically copied our shared key into /home/user/.ssh/authroized_keys file on server2.

Step 3: Login with no Password

Assuming you’ve followed the above steps, all you simply have to do now is login to the system as per normal.

..boom and you’re in, no password entry required!
[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]

[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]

Apache PHP-CGI SuExec Session Issues

After enabling php-cgi and suexec to handle your site in Apache, you may discover issues with your web applications working incorrectly. This could simply be a session issue which is result of the suexec user being unable to write into /var/lib/php/session directory.

[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]

You can verify this problem simply by looking websites error log.

First, lets identify the SuExec user configured for your site. Simply open your Apache configuration file and identify value set for “SuexecUserGroup”.

As you can see the value “user1″ has been set as the SuExec user. Now we need allow user1 access to the /var/lib/php/session directory. The simplest way to do this is to add user1 into the apache group. This is done by editing your /etc/group file and appending the line for the Apache group with your user.

Look for the apache group and append your user, save and close the file (:wq)

….and you’re done, you don’t even have to restart Apache.

[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]