I am finally getting used to managing a small Ubuntu server VPS. However, I know that I there must be programs installed that I don't need. Even if it is just the overhead of the Ubuntu system on top of Debian.
For example, I don't use Apache since I discovered Nginx. I don't use (S)FTP since I discovered SSH. I can replace bash with dash or OpenSSH with dropbear.
So I am wondering if there is a guide I can study or script that I can run out there which will remove all non-core parts of the system so that I can learn more about what is actually needed and how these libs work. Though I must admit that I'm no where near ready to start messing with the linux core itself.
My goal is to fit a complete PHP webserver in about 50MB so that I can give the FS and memcache all the rest of the RAM. I'm mostly interested in Debian since I know it already - but I've heard good things about CentOS also.
It seems that your primary objective is to get the most of your RAM for performance and not for holding bloated or unneeded software, right? if so, just disabling Apache (for instance) is enough; you don't get any benefit by uninstalling it.
Therefore, the best is to check
ps fax
output. You'll see every package running and how many subprocesses it's spawning. quite likely you're not running FTP, so you don't have to worry about that either.Besides, most of the non-performance-critical services can run from
inetd
(or likelyxinetd
). In that case they're not holding any RAM until you access the right port.In my experience, Ubuntu server (without LAMP) is very close to barebones. I usually just add ssh, nginx and whatever backserver i'm using.
If, on the other hand, you want to reduce disk usage, then you'll be better served by a different distro or (the best option, IMHO) Linux From Scratch
When I worked for a VPS hosting company we saw some ingenious webserver implementations designed to live within a 64MB memory footprint (this assumes you're talking about RAM, not disk space) - the Debian+nginx HowTo at LowEndBox stands out as a strong example.
You're asking what you can delete to suit your needs for a smaller server. But the way you're working it sounds like you may have a misunderstanding of the distro; Ubuntu is based on Debian, but it isn't Debian with custom packages making it Ubuntu. You can't just cut things out like the way it sounds like you want.
Plus, even if there were a script or packager, you're saying things like you don't need FTP since having discovered SSH. Well, if you were stripping a server to the "core", you may not necessarily need SSH, so automated tools might just strip that out too.
Essentially you need to intervene and figure out what you need and don't need and remove packages you don't use.
I don't know what the conditions are for your VPS, but my first reaction when people are looking to strip out a server to a minimal footprint is to tell them to look for distros that are geared for minimal footprints. Distrowatch may help you there. Ubuntu server is a general purpose OS that is not aimed at being small. If you're looking for a specialized server distro you can find them, but you'll lose some functionality that you may really be used to like the apt-get system or some other tool you've come to rely on.
Not to mention that if you just go through stripping parts out, you may end up hitting a package that you think you don't need but actually do because of some thrice-removed dependency.
End answer, I know of no such easy-automated-stripping tool for a server configuration other than the minimal configuration at install time, and I'm wary of anything that does this because it may not know what I want in the server and may remove things I want. I instead would look for a specialized distro that is geared for the server role I want, or I would use the apt-get tools to see what's installed and remove things that I don't want (since the packager may minimize my whoops-moments).
I usually do the following when installing Debian or Ubuntu:
'APT::Install-Recommends "0";' > /etc/apt.conf.d/99local
In Ubuntu land, you can use an existing system to build JeOS images. They are rather normal ubuntu systems, but stripped down of nearly everything. There aren't even manual pages installed. Last time I build an Ubuntu 10.04 LTS x86_64 JeOS system it was 124MiB compressed, with some additional packages on it (ruby, puppet and its deps, something else).
Talking about your goal, if you aren't putting the entire system in a ramdisk for a diskless hardware, you're probably misunderstanding something.
If you want a lean Linux server you can install ArchLinux. It's somewhere between Slackware/Linux from Scratch and Debian. Check it out.
Keep in mind that Ubuntu JeOS images (as Luke404 points out) are stripped down versions prepared to be installed in Virtual Machines. They have just about the minimun hardware support for this environment and the kernel is patched with some optimizations specifically for virtual environments.