Tuesday, 22 February 2011

memcached on drupal 6

environment: ubuntu hardy (8.04), drupal 6.13

memcached

To install memcached, you need to install libevent first:
sudo apt-get install libevent-dev
Install memcached:
mkdir src
cd src
wget http://memcached.googlecode.com/files/memcached-1.4.0.tar.gz
tar xzvf memcached-1.4.0.tar.gz
cd memcached-1.4.0
./configure
make
sudo make install
cd ..
Create control script:
sudo nano /usr/local/bin/memcache.sh
Add the following code:
#!/bin/sh
case "$1" in
start) /usr/local/bin/memcached -d -u root -m 240  -p 11211
;;
stop)  killall memcached
;;
esac
240 is the memory limit for the instance of memcached, the unit is MB.
11211 is the port number.
make it executable :
sudo chmod +x /usr/local/bin/memcache.sh 
start a memcached instance when the server startup:
sudo nano /etc/rc.local
add:
/usr/local/bin/memcache.sh start
start a memcached instance by running:
/usr/local/bin/memcache.sh start

PECL memcache extension for PHP

install php-pear if you have not installed it yet
apt-get install php-pear
install PECL memcache :
pecl install Memcache 
Edit the php.ini
nano/etc/php5/fpm  php.ini file:
add "extension=memcache.so" to it.

Restart nginx and php5-fmp


Memcache API and Integration module

open settings.php of your drupal site ( /sites/default/settings.php ), and add the following to the end of the file :
$conf = array(
   'cache_inc' => './sites/all/modules/memcache/memcache.inc',
 );
note: you may place './sites/all/modules/memcache/memcache.inc' with 'cache_inc' => './sites/all/modules/memcache/memcache.db.inc' to cache data both to memory and database if your memcache's memory limit is small or the memcached instance go offline often. (See the README.txt of Memcache API and Integration for more details. )
download Memcache API and Integration module from http://drupal.org/project/memcache, install and enable it.
Now, the integration of memcached and your drupal site is done. You can view memcache status from /admin/reports/memcache .

source

Sunday, 13 February 2011

set up postfix to send mails to google apps

After hours of search and trying several different solution, I found that it is surprisingly simle:

apt-get install postfix
nano /etc/postfix/main.cnf


change the following

mydestination = mydomain.com, localhost.mydomain.com, localhost

to

mydestination = localhost.mydomain.com, localhost
Reboot the server. Done!

Thanks Gyaan Sutra

Saturday, 29 January 2011

Install python 2.5 on ubuntu 10.04

So, you're a Python developer and like to use the 2.5.x track instead of the 2.6.x or the 3.x track. Well, never fear! Despite the fact that 2.5.5 is not installed in 10.04, or available in the repositories, you can still install it into your system. The following steps will show you how.
Open your terminal and type the following commands line by line:
sudo apt-get install build-essential gcc
cd Downloads
wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tgz
tar -xvzf Python-2.5.5.tgz
cd Python-2.5.5
./configure --prefix=/usr/local/python2.5
make
make test
sudo make install
sudo ln -s /usr/local/python2.5/bin/python /usr/bin/python2.5
There you have it! Python 2.5.5 is installed. Now if you want to run it, you can type python2.5 from the terminal.


Source: Welcome to Ubuntu


Friday, 28 January 2011

Install virtualenv and django, no-nonesense way

Install virtualenv

Installing virtualenv is easy on a Linux or Mac system, but the instructions that follow are Linux (Ubuntu, actually) specific. First you’ll need setuptools:

sudo apt-get install python-setuptools

Then we can easy_install virtualenv:
sudo easy_install virtualenv
We need to use sudo here because it has to install to a global location. Don’t worry, this is the last time we’ll need to do something as root.

Create your virtualenv

cd to wherever it is you keep your projects (for me, in ~/src), and run:
virtualenv --no-site-packages venv
In this instance I’ve chosen venv as the name for my virtual environment. The —no-site-packages command tells virtualenv not to symlink the global site packages into my local environment, just take the Python standard library. This is important, because it helps us avoid the dependency difficulties mentioned above.
At this stage you might want to add venv to your list of ignored files, as you don’t want it to be committed to source control:
echo "venv" >> .gitignore

Installing Django

Now, the trick with virtualenv is that it creates its own Python and easy_install binaries, which means you can install/run things specifically in your environment. Let’s install Django:
./venv/bin/easy_install django
And it’s done. easy. You might also want to install the MySQL bindings and IPython for ease of use:
./venv/bin/easy_install ipython python-mysql
To start a new Django project, you’ll note that a django-admin.py file will have been installed for you in the environment:
./venv/bin/django-admin.py startproject myapp
Obviously you can skip this step if you have an existing Django project.

Running Django

Now the last step, which is probably obvious by now, is to run Django’s runserver with the virtual Python binary:
cd myapp
../venv/bin/python manage.py runserver 0.0.0.0:8000
And you’re away!


Source: Bradley Wright


Friday, 31 December 2010

Disable Root SSH Login on Debian

Before we begin, you should make sure that you have a regular user account and that you can su or sudo to root from it. So  do these first:


adduser usrer1
assign a passwd to user1. and then add it to sudoers. But first need to install sudo:


apt-get install sudo
add this line inside to 


        nano /etc/sudoers


user1  ALL=(ALL) ALL


Open the file up while logged on as root.
nano /etc/ssh/sshd_config
Find this section in the file, containing the line with “PermitRootLogin” in it.
#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
Make the line look like this to disable logging in through ssh as root.

PermitRootLogin no
Now you’ll need to restart the sshd service:

/etc/init.d/ssh restart
Now nobody can brute force your root login, at least.

Source: How-to Geek

Monday, 27 December 2010

install the latest nginx

You can get the latest stable version of Nginx from the Nginx PPA on Launchpad:
You will need to have root privileges to perform the following commands.
 
sudo su -
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main" >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update 
apt-get install nginx

Source: nginx wiki

Upgrade Ubuntu server

aptitude update
and install the package update-manager-core:
aptitude install update-manager-core


Then run

do-release-upgrade

More details in howtoforge

Friday, 24 December 2010

'add-apt-repository: command not found'

add-apt-repository isn't installed by default. You have to install the python-software-properties package first.

sudo apt-get install python-software-properties

Thursday, 9 December 2010

Install Postgresql 8.4 on Ubuntu 10.10

Install postgres and the python libraries:
sudo apt-get install postgresql-8.4 postgresql-client-8.4 python-psycopg2
Modify the config file to allow local connections:
sudo nano /etc/postgresql/8.4/main/pg_hba.conf
Add the line:
local     all         all     md5
Save the changes to the file and restart the server.
sudo /etc/init.d/postgresql restart
Set the password for the postgres user:
sudo passwd postgres
Change to the postgres user:
su - postgres
Create a new Database:
createdb mydb
Login to the postgres shell and point to our new database:
psql mydb
Now from the postgress shell create a user and give him access to the database:
mydb=> CREATE USER myuser WITH PASSWORD 'myPassword';
mydb=> GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
mydb=\q
Done!

Source:  Videntity's Blog


Sunday, 5 December 2010

batch rename in Linux command line

The most intuitive way is  'sed' a loop. like this


for file in *.*; do mv $file `echo $file | sed 's/foo/bar/g'` ; done;
-----