Creating a Lightweight Server with CentOS

By StealthNo Comments

When using Linux, staying current with the times is hard to do without your own Linux system to work with. It is also very difficult to learn Linux without actually running Linux. When it comes to installing Linux there are many tutorials and lots of different methods of doing so, all claimed to be the “right way.” In this blog I’ll go over the way I install Linux. I do not believe there is a “right way” or “wrong way,” as long as the resulting system functions as required.

Note: I expect that when doing these steps you have basic Linux knowledge and know your way around the system using a command line interface. If you don’t know the basics of Linux I suggest reading online tutorials or beginner Linux books to get general system usage down.

The method I use utilizes CentOS and starts off with a minimal installation using the minimal install CD. From that basic installation, I install the packages I desire and build up the system from there. To get started, download the CentOS minimal installation CD, burn it to disc, and install it to a spare computer. Alternatively for learning purposes, you might want to consider using a virtual machine such as VirtualBox. When installing CentOS using the minimal install disc there aren’t too many options. The options you are presented with will pertain primarily to your specific system, and have the option for hard drive partitioning. If you don’t know what partitions are needed, just select the automatic mode.

Once the system comes up for the first time you will have a system with only the software needed for the computer to function properly installed. The next step from here would be to configure a network interface and begin installing packages. Of course the simplest way to get a system on the network is to just type dhclient eth0 after logging in. You will then be able to use the command to install any desired packages. Remember this system won’t have anything you may need, such as HTTP (web), FTP, MySQL, etc.. You will need to install those by hand using yum.

Before starting with package installations it might be desirable to update the system by running (running yum update may install a new kernel, a reboot afterwards is recommended). I also recommend disabling SELinux if you are just beginning with Linux, which could be done by changing SELINUX=enabled to SELINUX=disabled in /etc/selinux/config and restarting the system.

If you would like to have something to make all this easier when/if the system is going to be reinstalled (good if it is a test system), then I recommend making a script to do it all for you as I have done, then store it either on a web server that can be accessed by the system you are installing, or have it on a flash drive.

If you have never made a script before, it is simply a group of commands the system will read in order. There are some advanced techniques that can add functions which are called repeatedly, which are useful for doing repeated commands. Some basiscs to know is most scripts have a first line that looks like #!/bin/bash which tells the system which shell should process the file. Anywhere else in the script a line starting with a is a comment.

The script I have written is downloadable HERE, and here’s some basic instructions for usage:

  1. Install the minimal installation CD.
  2. Log in as root.
  3. Use DHCP to bring up the network adapter with dhclient eth0
  4. Download my script using curl http://www.ircsystems.net/utils/postinstall.sh -o postinstall.sh
  5. Run the script with bash postinstall.sh
  6. It is recommended to restart the system when completed.

This script will:

  • Disable SELinux.
  • Disable the firewall.
  • Install the nginx webserver with PHP and MySQL.
  • Install common command line utilities (such as wget, vim, telnet, ntp, host, mecurial, etc).
  • Install Perl, ruby, and packages needed to compile programs.
  • Install webmin (remote system management).
  • Install TMux, which allows you to start a shell session and access it later from a different session.
  • Start needed services automatically when the system boots (web server, SQL server, PHP processor, and the network settings).

Once it is done:

  • The webroot will be /home/web/html and the webserver may be accessed using a browser to connect to your system’s IP address. It should display information about the PHP installation.
  • You can access webmin to do further system configuration by using a web browser to connect to your IP address using SSL on port 10000 (example, https://192.168.1.101:10000).
  • I recommend creating a user account to use on your server. Continuing to use root for non-administration is not recommended.
  • You may also want to set a password for the web user to get access to the webroot on the system remotely.
  • Use SSH to access a shell remotely using the usernames and passwords you set up.

Further steps:

  • Consider setting up SSH to use keyfiles instead of passwords. This is much more secure, and the SSH server may be set to not allow password login from remote systems.
  • Manage files on your website using a remote computer connected through SCP rather than FTP (WinSCP can do this on a Windows computer).

Lastly, enjoy your system!

Operating Systems, Programming

Leave your Comment

Your email address will not be published. Required fields are marked *


− two = 6

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blue Taste Theme created by Jabox