Using FastCGI with Nginx for Performance on a VM

This weekend I decided to play around with the configuration on my Rackspace Cloud Server. Since our various websites have been doing well lately, the relatively low-powered machine I am running on is starting to fill up its available RAM. So far so good but as everyone quickly learns – running out of memory and hitting the swap space is a performance killer. Since I want my sites to continue to do well, I decided to take action before they hit the RAM limit and start swapping to disk.

This is the old architecture I had deployed. Apache – the Internet’s workhorse – to perform all of the PHP processing, with Nginx as a reverse proxy, passing dynamic (PHP) requests to Apache but serving static files directly to give Apache a break and cut down its footprint.

Read more

Share

PHP accelerator

Even though compilation is very fast, it still has a resource and time cost, especially on high-traffic servers. We can improve our response times by more than 5x by pre-caching our compiled opcode for direct execution later. There are a few PHP accelerators which accomplish this for us:

Xcache
Xcache is my favourite and is the one I use in my own configurations. It works by caching the compiled PHP opcode in memory so PHP can be directly executed by the web server without expensive disk reads and processing time. Many caching schemes also use Xcache to store the results of PHP rendering so individual pages don’t need to be re-processed.

APC (Alternative PHP Cache)
APC is a very similar product to XCache – in fact XCache was released partially as a response to the perceived lag APC’s support for newer PHP versions. APC is essentially the standard PHP Accelerator – in fact, it will be included by default in PHP 6. As much as I like XCache, it will be hard to compete with built-in caching.

Read more

Share

Install Memcache

By default PHP loads and saves sessions to disk. Disk storage has a few problems:

1. Slow IO: Reading from disk is one of the most expensive operations an application can perform, aside from reading across a network.
2. Scale: If we add a second server, neither machine will be aware of sessions on the other.

Enter Memcached
I hinted at Memcached before as a content cache that can improve application performance by preventing trips to the database. Memcached is also perfect for storing session data, and has been supported in PHP for quite some time.

Why use memcached rather than file-based sessions? Memcache stores all of its data using key-value pairs in RAM – it does not ever hit the hard drive, which makes it F-A-S-T. In multi-server setups, PHP can grab a persistent connection to the memcache server and share all sessions between multiple nodes.

Installation
Before beginning, you’ll need to have the Memcached server running. I won’t get into the details for building and installing the program as it is different in each environment. On Ubuntu it’s as easy as aptitude install memcached. Most package managers have a memcached installation available.

Read more

Share

Understanding Linux CPU Load

You might be familiar with Linux load averages already. Load averages are the three numbers shown with the uptime and top commands – they look like this:

load average: 0.09, 0.05, 0.01

Most people have an inkling of what the load averages mean: the three numbers represent averages over progressively longer periods of time (one, five, and fifteen minute averages), and that lower numbers are better. Higher numbers represent a problem or an overloaded machine. But, what's the the threshold? What constitutes "good" and "bad" load average values? When should you be concerned over a load average value, and when should you scramble to fix it ASAP?

First, a little background on what the load average values mean. We'll start out with the simplest case: a machine with one single-core processor.

The traffic analogy

A single-core CPU is like a single lane of traffic. Imagine you are a bridge operator … sometimes your bridge is so busy there are cars lined up to cross. You want to let folks know how traffic is moving on your bridge. A decent metric would be how many cars are waiting at a particular time. If no cars are waiting, incoming drivers know they can drive across right away. If cars are backed up, drivers know they're in for delays.

So, Bridge Operator, what numbering system are you going to use? How about:

Read more

Share

How to distribute root certificates as exe files

We start by creating a folder. We call it cer_as_exe and here we put our root certificate that we want to distribute and a small installation script.

image

 Our installation script is not that big. ;)

image

@echo off
certutil -addstore -f -enterprise -user root %tmp%\root_ca.cer > NUL
del /F %tmp%\root_ca.cer > NUL
del /F %tmp%\install.bat > NUL

 This is a very small script that installs a root certificate from a file to the root certificate container in the certificate store for the computer and the user. Then it does a quick cleanup by removing the original root certificate file and installation script that is unpacked in to the %tmp% folder by our installer. Now we need to pack everything as an .exe file that will install our root certificate automatically. ;)

Read more

Share

Reset root Password for Redhat/CentOS/Sl Linux 5.x

You can log in using single-user mode and create a new root password.

To enter single-user mode, reboot your computer. If you use the default boot loader, GRUB, you can enter single user mode by performing the following:

  1. At the boot loader menu, use the arrow keys to highlight the installation you want to edit and type [A] to enter into append mode.

  2. You are presented with a prompt that looks similar to the following:

    grub append> ro root=LABEL=/
  3. Press the Spacebar once to add a blank space, then add the word single to tell GRUB to boot into single-user Linux mode. The result should look like the following:

    ro root=LABEL=/ single
  4. Press [Enter] and GRUB will boot single-user Linux mode. After it finishes loading, you will be presented with a shell prompt similar to the following:

    sh-2.05b#
  5. You can now change the root password by typing

    passwd root

    You will be asked to re-type the password for verification. Once you are finished, the password will be changed. You can then reboot by typing reboot at the prompt; then you can log in to root as you normally would.

Share

Create Customer Linux Distribution

Remastersys

We’ve previously covered Remastersys. It’s one of a group of tools that create your ISO files using the filesystem on which it’s being run. You essentially clone your current Debian/Ubuntu install and make it into a live CD. This makes it extremely easy to customize every little thing about your distro, because you’re actually running it and can changing settings normally as you go. Because of the flexibility of the program, it’s also more complex than some of the other options.

Linux Live Scripts

This is a set of shell scripts to convert your existing system into a live CD or USB image. It works similarly to Remastersys, but does not require you to be running Debian or Ubuntu. There is no GUI here, and your distribution may require you to manually install certain kernel modules for the scripts to run.
Live-Magic

This is a Debian/Ubuntu tool that can create CD, USB, and netboot images. It’s much simpler to use than Remastersys, but it does not use your running system to build the image. Instead, you follow a “wizard” and choose your configuration options as you go. The program will pull the packages from your repositories and install them into your image. Live-Magic can be installed via the normal package managers. Ubuntu users can click here.

Revisor

Revisor is a very nice remastering tool for Fedora. It gives a wide variety of media types and includes some customization features not found some of the other graphical tools, such as package-by-package selection or browsing by category. Revisor also allows you to choose whether your creation will be a live system or an installer.

Instalinux.com

The really interesting thing about Instalinux is that it allows you to create an ISO image online. At the website, you can choose which distribution to base it on as well as the packages. Instalinux will create a small bootable ISO (approx. 30mb) which, when booted, will begin the install and fetch the other packages from the Internet. This may be the most versatile tool on the list, and the web interface makes it extremely simple to use. It won’t, however, provide you with a full live desktop environment.

SUSE Studio

Somewhat similar to Instalinux, SUSE studio allows you to use a web interface to create a custom distribution or “appliance”. It tops the charts in supported media, by including output for CD, DVD, USB stick, hard drive, VMware, VirtualBox, and Xen. Unfortunately, SUSE Studio is an invite-only program. You can request an invitation from the website. Being backed by a large company, SUSE Studio is of course much more polished than Instalinux.

Src:
http://maketecheasier.com/6-tools-to-easily-create-your-own-custom-linux-distro/2010/04/08

Share

zimbra admin password reset

To reset the administrative password:

su - zimbra
zmprov sp <admin email address> <new password>

To get a list of all administrators:

su - zimbra
zmprov gaaa

To access the admin console:

https://YOURHOST:7071

Remember that the administrative console (sometimes) requires a full email address as the login name, so you may be using the correct password and the wrong login!

Share