dd if=/dev/zero of=test bs=64k count=16k conv=fdatasyncA samle taken now:
My Desktop result: 100MB/s
Dedi (under 7 load): 58.6MB/s
UK VPS (no load): 76.9 MB/s
Bursnet VPS: 118 MB/s
dd if=/dev/zero of=test bs=64k count=16k conv=fdatasyncA samle taken now:
apt-get update
apt-get upgrade
apt-get install nano
apt-get install --reinstall language-pack-en
apt-get install libxml2-dev build-essential python-dev python-pip
apt-get install python-software-propertiesSince uwsgi is natively supported from nginx 0.8(?) onward, you need to use the latest nginx package (which is 1.xx) instead of the archaic nginx 0.7x still in debian packages. To install the latest nginx,
Now install uwsgi package:
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
add-apt-repository ppa:uwsgi/release
apt-get update
apt-get -y install uwsgi-python
/ /www
/dje /proj
/static
apt-get install python-virtualenv
mkdir /www
cd /www
virtualenv dje
cd /www/dje
source bin/activate
pip install django
python /www/dje/bin/django-admin.py startproject proj
mkdir static
nano deploy.py
import osYou are done with the django side, now make uwsgi configs:
import sys
from os.path import abspath, dirname, join
from site import addsitedir
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
from django.conf import settings
os.environ["DJANGO_SETTINGS_MODULE"] = "proj.settings"
# sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
nano /etc/uwsgi-python/apps-available/django.xmlAnd paste in it:
<uwsgi>
<socket>127.0.0.1:4000</socket>
<pythonpath>/www/dje</pythonpath>
<app mountpoint="/">
<script>wsgihandler</script>
</app>
</uwsgi>
ln -s /etc/uwsgi-python/apps-available/django.xml /etc/uwsgi-python/apps-enabled/django.xml
service uwsgi-python restartAnd to install mysql :
service nginx restart
apt-get install mysql-serverapt-get install python-mysqldb
php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
sudo aptitude purge $php_installed
apt-get install python-flup nginx subversion python-mysqldb
nano /etc/nginx/nginx.conf
user www-data; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; # multi_accept on; } http { include /etc/nginx/mime.types; access_log /var/log/nginx/access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_comp_level 6; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
nano /etc/nginx/sites-available/foo.com
server {
listen 80;
server_name www.foo.com foo.com;
if ($host != 'foo.com') {
rewrite ^/(.*)$ http://foo.com/$1 permanent;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
fastcgi_pass 127.0.0.1:7718;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
location /robots.txt {
alias /www/foo/media/robots.txt;
}
location /site_media/ {
expires 7d;
alias /www/foo/media/;
}
location /media/ {
alias /www/env/lib/python2.6/site-packages/django/contrib/admin/media;
}
}
ln -s /etc/nginx/sites-available/foo.com /etc/nginx/sites-enabled/foo.com
sudo /etc/init.d/nginx restart python /www/foo/manage.py runfcgi host=127.0.0.1 port=7718 pidfile=/www/foo/foocom.pid maxspare=2
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
apt-get install python-setuptools
easy_install pipThen
pip install virtualenv
pip install virtualenvwrapper
nano ~/.bashrc
# virtualenvwrapper
export WORKON_HOME=~/.virtualenvs
source /usr/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source ~/.bashrc
mkdir ~/.virtualenvs
mkvirtualenv --no-site-packages myenv
workon myenv
pip install PinaxAnd replicate a project:
pinax-admin setup_project -b social myproj
To repair, just issue this command:
Man pagemysqlcheck -uroot -pxxxxx --auto-repair --optimize --databases your_db
is a perl script for mysql optimization.
wget http://mysqltuner.com/mysqltuner.pl
chmod +x mysqltuner.pl
./mysqltuner.pl
I acheived amazing performance boost (server load dropped form 10 to 1) following the suggestions of this script, i.e.:
General recommendations:
Add skip-innodb to MySQL configuration to disable InnoDB
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (> 64M)
table_cache (> 64)
touch /etc/nsd3/nsd.confCheck these to figure out how to set up php5-fpm : (in case the instructions in the first link not works, install fpm from source, as describe in howtoforge )
apt-get install nsd3
apt-get install nginx
mkdir -p /srv/mysite
adduser rootuser
usermod -G www-data rootuser
mysql -u root -p
CREATE DATABASE mysitedb;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mysitedb.* TO 'mysiteuser'@'localhost' IDENTIFIED BY 'password#';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON mysitedb.* TO 'mysiteuser'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
quit;
cd /srv/mysite
wget http://ftp.drupal.org/files/projects/drupal-6.20.tar.gz
tar zxvf drupal-6.20.tar.gz
mv drupal-6.20/* .
rm -r drupal-6.20 drupal-6.20.tar.gz
cd sites/default/
cp default.settings.php settings.php
chown www-data:www-data settings.php
chmod 775 settings.php
mkdir files
chown www-data:www-data files
chmod 775 files
sudo apt-get install libevent-devInstall memcached:
Create control script: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 ..
Add the following code:sudo nano /usr/local/bin/memcache.sh
240 is the memory limit for the instance of memcached, the unit is MB.#!/bin/sh case "$1" in start) /usr/local/bin/memcached -d -u root -m 240 -p 11211 ;; stop) killall memcached ;; esac
make it executable :start a memcached instance when the server startup:
sudo chmod +x /usr/local/bin/memcache.sh
add:sudo nano /etc/rc.local
start a memcached instance by running:/usr/local/bin/memcache.sh start
/usr/local/bin/memcache.sh start
install PECL memcache :apt-get install php-pear
Edit the php.inipecl install Memcache
add "extension=memcache.so" to it.nano/etc/php5/fpm php.ini file:
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. )$conf = array( 'cache_inc' => './sites/all/modules/memcache/memcache.inc', );
apt-get install postfixnano /etc/postfix/main.cnf
mydestination = mydomain.com, localhost.mydomain.com, localhost
to
mydestination = localhost.mydomain.com, localhostReboot the server. Done!