Article Title: DIY miniLAPP server (x86 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Prerequisites
Readers of this article should install LFS at least once. If you have not done LFS, this article may not be suitable for you. Please follow the Linux thoroughly customized guide to perform LFS first. In addition, if you are interested in compilation optimization, the GCC compilation optimization guide is also worth reading.
Target
Youbest's masterpiece "5 MB Apache server" and its continued article "K Apache server" Bring LFS to the extreme, amazing! However, many practical people (including me) can only be amazed, because such a server is too small for practical purposes and cannot be used for production purposes in practice.
In view of the above reasons, this article intends to create a practical and small Linux + Apache + PHP + PostgreSQL + OpenSSH + Iptables server, and the practical use is preferred over the small. Although it is more practical than small, however, compared with the LAPP server built based on the general release version, it is still quite Mini (the core part of the final system produced in this article is about 15 MB [the large files include: bzImage is about 1 MB, postgres is about 3.5 MB, libphp5.so is about 4.6 MB, and libc. so about 1.3 MB, libcrypto. so about 1.1 MB], the total volume is about 150 MB), so I call it a "miniLAPP" server. Of course, in addition to being small, flexible, and efficient, this article is mainly reflected in: (I) to customize the maximum number of software packages, (ii) Compile and optimize the database while ensuring stability.
This article will create a virtual machine on VMware Workstation 5.5.5 to avoid being entangled in a variety of complex hardware environments. The details are as follows: Intel platinum BX motherboard, athlon-xp processor (If your CPU is different from mine, you only need to replace all "athlon-xp" in this article with your CPU model, for details, refer to Gentoo Safe Cflags), 384 M memory (minimum MB), m NIC (PCnet32), 4G hard drive (BusLogic SCSI 0: 0), CDROM (IDE 1:0 lfslivecd-x86-6.3-r2160-min.iso for installation only ).
Network Environment: ip: 192.168.10.33/24, broadcast: 192.168.10.255, gateway: 192.168.10.250, no DNS. If your environment is different from this, adjust the corresponding ip commands.
Ideas
Basically, there is a conflict between small and practical, because the more practical it is required, the more required various functions, the more small it cannot be guaranteed. To solve this problem, this article adopts the "core + expansion" idea. The so-called "core" refers to the resources necessary to ensure the normal operation of the server, such as libc, init, httpd, S, libphp, sshd... And various device files and configuration files. The so-called "extension" refers to resources not required during runtime, such as top, cat, gcc... And so on. It is mainly used for server maintenance.
The solution is to install the "core" part in the "/" directory so that it can be used when the server is active together, the "extension" part is installed in the "/usr" directory, and "/usr" is located in an independent partition. it is manually mounted only when necessary, after use, uninstall it manually.
In fact, for the vast majority of software packages, only a small part is needed. Therefore, the majority of Software Package subjects are located in the "/usr" directory, install only some required parts under.
Another question is whether to use static connections or dynamic shared libraries? From a small perspective, it seems that static connections should be used, but considering:
The pursuit of small size is not the first importance. Here, the definition of "Mini" is not about disk space, but to minimize unnecessary programs and components.
Programs with dynamic connections can share library files in the memory, while those with static Connections cannot. Considering that this server may be extended to provide DNS, FTP, Mail, Proxy and other services, static connections will occupy more memory during running.
Therefore, this article decided to use regular dynamic connections.