One constantly posted question on LowEndBox and LowEndTalk is — how to get the same setup as LowEndBox, a WordPress site that runs on cheap VPS with 80MB of memory? Instead of doing a step-by-step explanation (damn I hate writing long blog posts), I decided to wrap it into a bash script that does it all.
![]() | ![]() |
![]() | ![]() |
It is based on my previous script here, and it has been tested on both Debian 5 “Lenny” and Ubuntu 10.04 “Lucid Lynx”. Sorry no other distributions are supported. It is currently hosted at github so feel free to branch it and tune it to your heart’s desire.
Usage
Here is a quick step by step on how to set up a WordPress blog running on Nginx, PHP/FastCGI and MySQL on a low end box. Let’s assume that you are going to set up a blog on hostname “blog.example.com“.
- Go and buy a cheap VPS. Yes, you know where to find cheap virtual servers under $7/month, don’t you? 🙂 I am using my 6 pound/year RackVM VPS with 128MB memory to test this script, and the performance turns out to be quite good. YMMV.
Make sure it is either a Debian or a Ubuntu distro though.
- After gaining root access to your VPS,
# wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh ... # bash setup-debian.sh system ... # bash setup-debian.sh exim4 ... # bash setup-debian.sh nginx ... # bash setup-debian.sh mysql ... # bash setup-debian.sh php ... # bash setup-debian.sh wordpress blog.example.com ...
- Now altering your DNS entry to point
blog.example.comto your new VPS (or alter your local/etc/hostsentry). Navigate to it from your browser, and you should be presented with WordPress set up page. Fill in your blog’s name, admin’s password and contact email, and your new WordPress is online!Just repeat the last step (running
bash setup-debian.sh wordpress <hostname>) to set up more blogs on the same box.
That’s it!
Software Stack
It’s pretty similar to my own stack that runs LowEndBox.com.
- dropbear to replace openssh. Invoked from xinetd.
- inetutils-syslogd to replace rsyslog.
- exim4 to replace sendmail (if installed). Re-configured to allow Internet delivery.
- cron
- nginx
- mysql. Re-configured to remove innodb support, remove query cache and reduce key buffer size.
- php with built-in FastCGI interface. Running only 1 child process and respawn after 5,000 requests.
The lowendscript is also
- Removing some commonly bundled applications that should not be there in the first place for a minimal distro (apache2, sendmail, bind9, samba, nscd, etc).
- MySQL root is given a new password (which can be found in
~root/.my.cnf) - Installing each WordPress site under /var/www/<hostname>. It will create appropriate database, users and password for the site.
I have to say that it is still “work in progress”, but if you want to figure out the internals please check the source code of that bash script.
Memory Usage
I am testing the same script on the following 3 systems:
- Ubuntu 10.04 64bit (RackVM)
- Debian 5 64bit (RackVM)
- Debian 5 32bit (VPSGuy)
They are all showing different memory usage. I am taking the snapshot of memory usage AFTER 10 page loads on the WordPress blog that has been created to ensure PHP process is fully loaded.
Ubuntu 10.04 64bit
root@ubuntu64:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.5 23300 1536 ? Ss 06:58 0:00 init
root 10124 0.0 0.5 23576 1496 ? Ss 07:34 0:00 dropbear -i
root 15742 0.0 0.7 17880 1944 pts/0 Ss 07:35 0:00 -bash
root 15754 0.0 0.4 14960 1084 pts/0 R+ 07:35 0:00 ps aux
root 24290 0.0 0.3 12508 788 ? S 07:22 0:00 /usr/sbin/syslo
root 24524 0.0 0.3 21064 1004 ? Ss 07:22 0:00 cron
root 25689 0.0 0.3 19512 972 ? Ss 07:22 0:00 /usr/sbin/xinet
mysql 26346 0.0 4.2 61812 11248 ? Ssl 07:23 0:00 /usr/sbin/mysql
www-data 27920 0.0 2.6 87768 7048 ? Ss 07:23 0:00 /usr/bin/php-cg
www-data 27922 0.5 15.0 122460 39432 ? S 07:23 0:04 /usr/bin/php-cg
103 30162 0.0 0.3 44356 1000 ? Ss 07:24 0:00 /usr/sbin/exim4
root 30267 0.0 0.3 28104 932 ? Ss 07:24 0:00 nginx: master p
www-data 30268 0.0 0.8 28744 2196 ? S 07:24 0:00 nginx: worker p
root@ubuntu64:~# free
total used free shared buffers cached
Mem: 262144 100500 161644 0 0 0
-/+ buffers/cache: 100500 161644
Swap: 0 0 0
Memory Usage: 98.1MB
Debian 5 64bit
debian64:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 10304 740 ? Ss 12:22 0:00 init [2]
106 1414 0.0 0.3 42708 1004 ? Ss 12:26 0:00 /usr/sbin/exim4
www-data 1655 0.0 2.5 72028 6560 ? Ss 12:26 0:00 /usr/bin/php-cg
www-data 1657 0.9 11.7 98500 30928 ? S 12:26 0:03 /usr/bin/php-cg
www-data 3126 0.0 0.7 28380 1912 ? S 12:29 0:00 nginx: worker p
root 7668 0.1 0.5 23340 1528 ? Rs 12:31 0:00 dropbear -i
root 7831 0.0 0.6 17472 1716 pts/0 Ss 12:32 0:00 -bash
root 7836 0.0 0.3 14720 980 pts/0 R+ 12:32 0:00 ps aux
root 20169 0.0 0.3 18540 936 ? Ss 12:22 0:00 /usr/sbin/cron
root 24462 0.0 0.2 12236 732 ? S 12:25 0:00 /usr/sbin/syslo
root 25637 0.0 0.3 19256 952 ? Ss 12:25 0:00 /usr/sbin/xinet
root 25694 0.0 0.5 28380 1552 ? Ss 12:25 0:00 nginx: master p
root 32427 0.0 0.2 3872 588 ? S 12:26 0:00 /bin/sh /usr/bi
mysql 32466 0.0 3.0 50420 8124 ? Sl 12:26 0:00 /usr/sbin/mysql
root 32468 0.0 0.2 3772 592 ? S 12:26 0:00 logger -p daemo
debian64:~# free
total used free shared buffers cached
Mem: 262144 61008 201136 0 0 0
-/+ buffers/cache: 61008 201136
Swap: 0 0 0
Memory Usage: 59.6MB
Debian 5 32bit
debian32:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 1980 688 ? Ss 23:34 0:00 init [2]
root 14064 0.0 0.1 1704 512 ? S 23:52 0:00 /bin/sh /usr/bi
mysql 14119 0.0 1.7 20056 6968 ? Sl 23:52 0:00 /usr/sbin/mysql
root 14120 0.0 0.1 1628 536 ? S 23:52 0:00 logger -p daemo
www-data 15968 0.0 1.2 16352 4996 ? Ss 23:53 0:00 /usr/bin/php-cg
www-data 15971 0.5 4.7 29436 18576 ? S 23:53 0:01 /usr/bin/php-cg
root 16040 0.0 0.3 2700 1464 ? Rs 23:53 0:00 dropbear -i
root 16119 0.0 0.1 1880 684 ? S 23:44 0:00 /usr/sbin/syslo
root 16133 0.0 0.3 2780 1536 pts/0 Ss 23:54 0:00 -bash
root 17728 0.0 0.2 2352 896 ? Ss 23:45 0:00 /usr/sbin/xinet
www-data 17758 0.0 0.3 5004 1488 ? S 23:54 0:00 nginx: worker p
root 27834 0.0 0.3 4548 1236 ? Ss 23:47 0:00 nginx: master p
root 28146 0.0 0.2 2296 896 pts/0 R+ 23:57 0:00 ps aux
102 32065 0.0 0.2 6104 900 ? Ss 23:49 0:00 /usr/sbin/exim4
debian32:~# free
total used free shared buffers cached
Mem: 262144 44272 217872 0 0 0
-/+ buffers/cache: 44272 217872
Swap: 0 0 0
Memory Usage: 43.2MB
So to put that in summary form
- Ubuntu 10.04 uses significantly more memory than Debian 5 (PHP5.3/MySQL5.1 vs. PHP5.2/MySQL5.0). So pick your distro wisely and maybe you don’t need the latest and greatest if your application does not need it.
- 32bit also uses quite a bit less than 64bit, running exactly the same version of stack. That pretty much confirms what I posted before.
And hopefully the above script is useful for your next WordPress splog farm 😛




Well the young padawan — it is your opportunity to figure out exactly why it is using 500MB of memory. A simple `ps aux` would tell you a lot where all that memory went 🙂
Thanks to both above -LEA’s solution worked. 🙂
@LEA: ps aux. And this is result 😀
Spot the odd one out 🙂 Your process pid=582 seems to be doing naughty things.
That’s right! How can i solve this? I run wordpress blog with high traffic (online at the same time is 100-200)
@Above – Run;
kill 582
And it will kill the command.
@Jackk: did it, but ram usage still high: 513 😀
Run ps aux again for me..
jack
@ Jack: please see pics:
http://img201.imageshack.us/img201/5628/screenshot2807201022161.jpg
http://img227.imageshack.us/img227/2526/screenshot2807201022160.jpg
@ Jack: please see pics:
img201.imageshack.us/img201/5628/screenshot2807201022161.jpg
img227.imageshack.us/img227/2526/screenshot2807201022160.jpg
@minhmeo
just wondering, why there are so many kernel processes in your ‘ps aux’ result in comment #43.
@bekanosky: hard to say cos i’m newbie here 😀
I added your Gtalk id, can you help me to install this? I will give you my vps, then you install it and write steps you did to make it running fine. Is it OK?
Thanks!!!
quick suggestion: install php5-fpm from the dotdeb.org repositories instead of the default PHP fastcgi implementation.
btw, my suggestion is to improve the script, not for any special problem 🙂
@minhmeo
I already write tutorial about this nginx-phpfcgi-mysql-wordpress in indonesian.
If not lazy, i will have translated it to english.
And i think, this lowendscript do much more than what i wrote.
So, just make sure to execute this script properly and i’m sure it will be okay.
57.59ram on rackvm debian
Thanks for publishing this package, seems to work great!
Admin, many thanks for the install script, please if anyone can add drupal along with?
What about using a flat-file blog instead of WordPress? It may not be as powerful, but it won’t require a MySQL Server running.
Could you add setting up phpmyadmin to the script ? cause I can’t seem to get it working on nginx ?
@Maller – I can help you setup the script. Send me an email on the email address on the page below.
http://178.63.252.43/email.txt
@Maller: you can follow tutorial here, auto script:
http://www.rockia.com/2010/05/how-to-set-up-lnmp-on-debian-ubuntu-or-centos
@maller
you can try sql buddy. jquerty based; very simple and lightweight.
http://www.sqlbuddy.com/
Hello,
The Cron system doesn’t seem to work on my system?
Jack
I found that why my ram usage is so high. Because i’m using Xen VPS 🙁
How can i reduce ram usage?
Someone smart should add a low resource SMTP/IMAPD (or POP3) addition to this stack. 🙂
@Raj – In my opinion it’s easier and better to out source your email to something like Google Apps. Google Apps provide 50 emails accounts free of charge for each of your domains – each account has a massive 7GB storage space like any normal Gmail account.
http://www.google.com/a
Jack xD
@Minh — probably because you have read the command `free` wrong 🙂 All your cache/buffer should probably be counted as “almost-free”.
@Raj — what Jack said. Google Apps is probably a much bettered hosted email option, unless you are providing IMAP/POP3 for clients.
@LEA
I have tried the script under my RackVM OpenVZ VPS, with Debian 5 Lenny 32bit, and the memory used is about 47Mb. I have a question, since I install the wordpress at http://www.noenoey.com, but when I open my website with http://noenoey.com, it only shows ‘Welcome to Nginx’.
How do I set the domain, so when I open it with or without www, it still the same?
And also, when I open the website using the IP, it shows the wordpress?
If you change wordpress to some other CMS and you get “no input file specified.” on firefox (yes, for some reason only on firefox!) go to /etc/nginx/sites-available and erase all default info and only leave your created config in /etc/nginx/sites-enabled
Probably true. From my knothole, I’ve got about 8 years of personal Maildir format mail and a handful of mail mailing lists that I’d like to be able to move from host to host should I find paritcular hosts’ service going downhill.
Moving that data around is easy postfix/dovecot, but I am not aware that Google Apps has a download all/upload all feature. Does it?
The other issue on low end boxes is spamassassin being a memory hog! I haven’t been able to get the mem usage down enough to coexist with my LAMP stack on other 128MB/256MB low end boxes.
I’ll fiddle around with it some more, maybe I”ll come up with a little blurb to add to this one. 🙂
@Raj,
If you stuck your email with Google you wouldn’t need to move it every time you moved hosts. You could just simply keep the email in one place at all times.
@Raj — I have run my own SMTP/IMAP server for many years (since ’99) until about 2 years ago I got really fed up with it and migrate all my mails to Google App. Way too much tinkering with spam/virus filters (and SpamAssassin/ClamAV eats memory *a lot*), and just can’t resist the conversation view that Gmail provides.
To move my years of mails in Maildir (I also used Postfix + Dovecot before) I wrote a script to scan through all files in Maildir, and use Gmail’s IMAP interface to copy the data over. Worked well. It is also possible to write something to use Gmail’s IMAP interface to continuously backup mails to your own server. I haven’t bothered though.
@Erawan — you need to put in a Nginx configuration to do the redirection. For example
server { server_name noenoey.com; rewrite ^(.*)$ $scheme://www.noenoey.com$1 permanent; }@Tom — in the end I think it is a good idea to pick up some Nginx configuration syntax 🙂 No input file probably means PHP cannot find the PHP script.
@LEA
Thank you, I will try it 🙂
Hm…
I wonder,are you the same owner of yang.id.au. LEA?
@LEA: Here is “free -m” resuld, is ram usage 492 😀
root@endor:~# free -m
total used free shared buffers cached
Mem: 531 492 38 0 24 360
-/+ buffers/cache: 108 422
Swap: 511 0 511
Sorry, please help me but my free -m result in code tag
@Minh:
I think you have mistaken about the result given from “free -m”
Your total free memory should be 422.
Though having 100+ used memory is still kinda of a bit too much?
any chance updating the script with lighttpd?
@Allen: thanks, it’s my mistake, i didnt know to read free -m result 😀