Creating lightweight Linux servers

Source: Internet
Author: User
Author: iStef hasn't written a Blog for a long time. I won't talk about anything when I'm busy. lazy is the biggest reason. Recently, I was busy creating a website for the lab. in addition to my familiar WebDesign & amp; Development, I also set up a Linux server. On the one hand, it is used to place our site, and on the other hand, it is used to place a server in the lab.

Author:IStef

I haven't written a Blog for a long time. I don't want to talk about anything when I'm busy. lazy is the biggest reason. Recently, I was busy creating a website for the lab. in addition to my familiar Web Design & Development, I also set up a Linux server. On the one hand, it is used to place our sites, on the other hand, a server in the lab, and some additional services for the lab members to facilitate scientific research and learning.

Although I am familiar with Web, I am definitely a beginner in Linux server. Although it has never been used for development, it is basically a matter of calling Apache or PHP. Therefore, the content below is just a record. you are afraid to give an axe to the class, and the methods are also Google. if you have any suggestions, please submit them.

This article only describes how to build a basic server. I chose Ubuntu as the release version. although I know that CentOS or RHEL may have better performance, it is easy to get familiar with Ubuntu after all. Ubuntu has a Server version and can install a LAMP Server without any intervention. However, the pleasure of Linux is that, I also want to know that everything is running on the server, so I decided to build a clean basic system. After some Googles, I found a nearly "perfect" Tutorial: Minimal Ubuntu 8.04 Server Install. the following installation process is basically based on this tutorial, A slight improvement satisfies the actual needs.

To get started, start installation. First, use Ubuntu 8.04 Desktop Live CD to boot the server and start a Terminal.

Step 1: Start the partitioning tool to partition hard disks. Here I am also using cfdisk (GPart is not needed because this server has no mouse at all-_-B), and the hard disk of 500 GB is partitioned. The command is as follows:

Sudo su
Cfdisk/dev/sda

The 60 MB primary partition is used as/boot, 50 GB logical partition is used as root partition, 4 GB logical partition is used as swap partition, and the remaining one partition is used as/home. Do not forget to write data to the partition table after dividing.

After the partition is complete, start formatting each partition. for convenience, I only use the ext3 format:

Mkfs. ext3/dev/sda1
Mkfs. ext3/dev/sda5
Mkfs. ext3/dev/sda6
Mkswap/dev/sda7

After partitioning, you can install the basic system. here you need to use debootstrap. the specific command is:

Mkdir/min
Mount/dev/sda5/min
Mkdir/min/boot
Mount/dev/sda1/min/boot
Mkdir/min/home
Mount/dev/sda6/min/home
Apt-get install debootstrap

Before executing debootstrap, we recommend that you first set the source. Because this step requires a large number of software downloads, it is necessary to select the fastest source. Here I use the cn99 Source:

Nano/usr/share/debootstrap/scripts/hard

Find a paragraph similar to the following section (default_mirror) and change it to the source you need:

Case $ ARCH in amd64 | i386 | iSCSI)
Default_mirror http://ubuntu.cn99.com/ubuntu

Then start installing the minimum system

Debootstrap hard/min

After that, we need to set the system to make it available. First, we can copy some settings directly to the target system:

Cp/etc/hosts/min/etc/
Cp/etc/network/interfaces/min/etc/network/
Cp/etc/bash_completion/min/etc/
Cp/etc/bash. bashrc/min/etc/

In addition, we also need to make some settings for the optical drive:

Mkdir-p/min/media/cdrom0
Ln-s cdrom0/min/media/cdrom

Create fstab:

Nano/etc/fstab

The content of the fstab file is roughly as follows:

proc            /proc           proc    defaults                   0       0/dev/sda5 /               ext3    relatime                   0       1/dev/sda1 /boot           ext3    relatime                   0       1/dev/sda6 /home           ext3    relatime                   0       1/dev/sda7 none            swap    sw                         0       0/dev/cdrom      /media/cdrom0   udf,iso9660 user,noauto,exec,utf8  0       0

After completing this step, my system is basically installed. now we can go to chroot for further configuration:

Mount? Bind/dev/min/dev
Mount-t proc/min/proc
Mount-t sysfs/min/sys
Chroot/min

Set the time zone:

Cp/usr/share/zoneinfo/Asia/Shanghai/etc/localtime

Install a text editor. I personally prefer nano. of course, you can also install vim:

Apt-get install nano

Set the source list as follows:

Nano/etc/apt/sources. list

The content is as follows. the cn99 source is used (I can reach 1 Mbit/s on CERNET)

deb http://ubuntu.cn99.com/ubuntu hardy main restricted universe multiversedeb http://ubuntu.cn99.com/ubuntu hardy-updates main restricted universe multiversedeb http://ubuntu.cn99.com/ubuntu hardy-security main restricted universe multiverse

Update source and upgrade existing software:

Apt-get update
Apt-get dist-upgrade

Set the root user password, create a new user, and Grant sudo permissions to it:

Passwd
Adduser liuyang
Addgroup admin
Adduser liuyang admin
Echo "% admin ALL = (ALL) ALL">/etc/sudoers

Install grub so that the target system can boot:

Apt-get install linux-image-server grub
Mkdir/boot/grub
Update-grub
Update-initramfs-u

The target system has been set up. now chroot is available to complete the final operation-install grub on the MBR of/dev/sda:

Exit
Grub-install? Root-directory =/min? No-floppy? Recheck/dev/sda

Restart the system and exit the Live CD. if everything is normal, you should be able to boot your server with a "clean" Ubuntu.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.