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 Oracle database support in PHP CentOS 6

Howto install Oracle database support in PHP for CentOS 6 and Amazon Linux AMI.

To access an Oracle database from PHP you need to use the OCI8 extension. I will take you through the quick process of getting it up and running.

This guide assumes you already have Apache and PHP installed in your environment running on either CentOS 6 or Amazon Linux AMI. It also assumes the Oracle database you wish to connect to is on a remote host.

Continue reading…

Nice and Simple AWS EC2 Start Stop Script – Python

Here is a nice and simple AWS EC2 start stop script written in Python and run from the command line. The parameters are just start|stop and the name of your instance.

I’ve written it so it uses the tag Name instead of requiring the specific instance ID. The script’s ideal usage may be to schedule the start|stop of an instance at particular times of the day. So you might have a test server you use during 10AM and 3PM Monday to Friday. With this script you could setup a scheduled task on a remote computer to start|stop the instance based on your schedule, saving you money!

Prerequisites

In order to run this script you’ll need to have Python and the AWS library Boto installed on your computer. Remember this can be any computer with an internet connection (ideally not the EC2 instance you plan on stopping/starting). The script will run on Linux and Windows.

I’ve previously written guides on installing Python and Boto into Linux environments. If you use Windows, you will find many guides stepping you through this process.
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…

Python MySQL Backup Script

Here is a simple python based MySQL backup script. It will individually dump all your MySQL databases and then tar gzip them to a specified location.

Having Python installed is the only real prerequisite.

Script Details

Note, that the script isn’t verbose unless there is an error. This is so you can schedule it as a cron job, and only get an email when something goes wrong.

It also uses a configuration file as a security precaution. The reason for using a config file, it prevents the user and password being visible in the running processes list. So for example if you were running a mysqldump and put password into your command line, another user could query the running processes and see the password.

I typically store my scripts in the /usr/local/bin directory of my Linux systems. In general, it’s a good place to store custom scripts and applications.

You’ll also need to create your configuration file, like below:

In my case, I store the config file as /etc/mysql.cnf however make sure that it’s only readable by the root user.

Continue reading…

Setup Python / Boto for AWS on Ubuntu 13.04

I’ll quickly take you through configuring Ubuntu 13.04 so you can use Python and Boto 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-dev 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…

Allow SFTP but prevent SSH Shell Access CentOS 6

Quick guide to configure SFTP access but prevent SSH logins.

A standard CentOS install already configured with openssh-server package (and its dependancies) is all we need to get started.

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

Scenario

You’ve got a specific user which only requires encrypted access to the files of their hosted web site. However we don’t want the user to be able to see or access any other user or system data on the server (chroot or jail).

Step 1: Configure SSH

We’ll need to open up /etc/ssh/sshd_config file and make a few adjustments.

You’ll need to look for the following line:

And you’ll want to comment out that line and add some additional information below.

Save and close sshd_config file to complete that step. Also note you’ll need to restart the sshd service before the settings will take affect.

Continue reading…

Adempiere Startup Script for CentOS

This is a simple Adempiere startup/init script for CentOS.

I’ve coded it to execute the application server inside a screen session. This allows you to easily monitor the application servers output in real-time. This script should be valid for all versions of Adempiere, I’ve tested with 3.6 and 3.7.

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

Prerequisites

You’ll need to have the screen package installed, to check run the following:

If the screen package is missing, use yum to install it

Lastly, you’ll need to set $ADM_HOME to your Adempiere directory.

Installation

Copy/paste the script into a new file named “/etc/init.d/adempiere”.

You’ll need to make the script executable.

Create all the rc entries, and configure the Adempiere service to boot on system boot

Continue reading…

Tutorial – Configure IPTables for NFS Server on CentOS 6

This tutorial will take you through configuring iptables to allow client connections to your NFS service.

Allowing access to your NFS shares isn’t as simple as opening up a single protocol/port combo. There’s a quite a number of different ports required utilizing both TCP and UDP. We also need to make our lives easier to statically setting the ports for some of the NFS related services.

[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: Configure NFS Ports

The NFS service uses the RPC Bind service to advertise the protocols/ports it’s using. To make our iptables config nice and clean, we’ll statically configure these ports rather than leave it up to the RPC God to decide.

Edit the NFS port definitions file

Un-comment the following lines and save the file.

Now restart the NFS and RPC Bind services

Continue reading…