DEV Community

Cover image for How to Set Up a Linux Server
Mary J Derosa
Mary J Derosa

Posted on

How to Set Up a Linux Server

Linux is one of the most popular operating systems used by approximately 3.5 billion users. Many individuals and companies use web servers that run on the Linux operating system as it’s an excellent choice for daily use. Linux is also open-source, meaning that it is free to use and customize.

If you intend to build your own Linux server, there are some conditions you’ll need to meet. For instance, a Linux server can only run on specific minimum system requirements. You also need to select a Linux distribution that suits your needs.

A Linux server doesn't come with a graphical user interface like other desktop environments. It uses Terminal, which is a text-based interface. Therefore, we strongly recommend learning the basic Linux commands first to help you operate and manage a Linux server.

In this article, we will go over a step-by-step tutorial on how to install Linux and set up a Linux server. Let’s get started.

1. Choose and Download a Linux Distribution

Picking the right Linux distribution can be challenging as there are around 600 distros available. That said, not all Linux distributions are available for web servers. Popular Linux distributions commonly used as servers are Ubuntu, Fedora, Arch Linux, and Debian.

For example, this article will use Ubuntu Server to build a Linux server. As one of the most famous Linux distributions, Ubuntu provides regular security updates and long-term support, making it a secure and reliable operating system.

Ubuntu Server’s system requirements are also pretty straightforward. According to the Ubuntu official documentation, the minimum system requirements are one gigahertz (GHz) of CPU, one gigabyte (GB) of RAM, and a minimum of 2.5 gigabytes (GB) of storage space. Therefore, most computers are capable of running Ubuntu Server.

The next step is to download the Ubuntu Server’s installation file. Follow the steps below:

  1. Go to the Ubuntu official website. Then, click the Download dropdown menu and navigate to Ubuntu Server -> Get Ubuntu Server.
  2. Choose Option 2 - Manual server installation on the Ubuntu Server download page. After that, click Download Ubuntu Server 22.04 LTS. Note that the 22.04 LTS is the current long-term support version.
  3. The download process will begin automatically. The downloaded file name should look like the following: ubuntu-22.04-live-server-amd64.iso.

2. Create a Bootable USB

Creating a bootable USB will be your next step after choosing a Linux distro. You will need at least a 4GB or larger USB stick or flash drive, a Ubuntu ISO file, and a bootable USB creator tool – for example, Rufus, Etcher, or Ventoy.

As for the bootable USB creator tool, we used Rufus as an example. Here are the steps on how to create an installation media using this application:

  1. Download Rufus via the official download page and install it. Then, run the application on your local computer.
  2. Click Select to locate the Ubuntu ISO file in the local folder.
  3. Set the partition scheme to MBR and target system to BIOS or UEFI. You can then name the volume label, such as “Ubuntu Installation Media.”
  4. For the format options, make sure that the file system is set to FAT32 (Default).
  5. Click Start to begin the process. Once finished, close the application.

3. Install Your Linux Server Operating System

Now that you have a bootable USB, we can begin installing the Linux operating system. First, plug the bootable USB into your computer’s USB port. Most computers will automatically boot from external media, such as USB drives or DVDs.

If the boot message doesn’t show up, you need to select the install media manually. Press the Escape or Esc, F2, F10, or F12 key so that the boot menu shows up when you restart the computer.

Once the boot menu appears, select the bootable USB containing the Linux installation media. Note that it might take some time for the installation window to show up.

Then, it’s time to install your Linux server operating system. We used Ubuntu Server as an example. Follow the steps below:

  1. Choose your preferred language.
  2. Next, choose the keyboard layout. If you are unsure, go with the default option, which is English (US).
  3. After that, the installer will show three installation options – Install Ubuntu, Install MAAS Region Controller, and Install MAAS Rack Controller. Select the Install Ubuntu option.
  4. Then, you need to set up a network configuration. The installer will automatically discover any network connection via DHCP, so there is no need to enter anything in this section.
  5. For the storage configuration, we recommend using the first option to use an entire disk.
  6. On the next screen, select a disk to be formatted. The installer will show information regarding the partitions to create.
  7. The installer will show another confirmation step. Make sure that you have chosen the correct disk to be formatted.
  8. The next step is creating a profile. Type your name, a server name, a username, and a password into the designated fields.
  9. After that, install the OpenSSH server package by checking the box next to Install OpenSSH server.
  10. Next, you can download and install a selection of Linux packages for your server environment, providing you enabled a network connection. Select Done to proceed with the installation process.
  11. The installer will then show the installation log. Once finished, select Reboot. When the reboot process begins, unplug the bootable USB stick.

4. Run and Test Your Linux Server

When you boot the Linux server OS, you will see Terminal or command lines with information like the following:

Ubuntu 22.04 LTS ubuntu tty1

ubuntu login:

This means that you have successfully installed a Linux server. Enter your username and password to log in to your server. Terminal will generate additional messages once you are logged in.

To test your Linux server, you can type in several commands on Terminal. Here is a list of useful commands:

  • uptime – shows information about the server uptime.
  • pwd – locates the path of the current working directory.
  • ls – shows the content of the current directory you are in.
  • top or htop – displays a list of running processes and the CPU usage.
  • whoami – prints the user name of the user ID.

5. Update and Upgrade Your Linux Server

Updating and upgrading the system is crucial to ensure that your Linux server gets the latest security and kernel updates. It is important to check for updates every time you log in to the server, as most Linux distributions frequently release new updates and upgrades.

To perform an update and upgrade on your Linux server, enter the following command:

sudo apt-get update or sudo apt update

Wait until the process is finished. Then, proceed with the command below:

sudo apt-get upgrade or sudo apt upgrade

Alternatively, you can also combine the above commands with the following:

sudo apt-get update && sudo apt-get upgrade or sudo apt update && sudo apt upgrade

6. Install Web Server Applications – Apache, MySQL, and PHP

If you’re configuring a Linux server for a website development project, consider installing web server applications such as Apache, MySQL, and PHP. Apache helps deploy your website on the internet through your own server, while MySQL works as a database management system for your website.

Here are the steps to install Apache, MySQL, and PHP via Terminal:

  1. To install Apache, type the command below:

sudo apt-get update && sudo apt-get install apache2

  1. Next, enter the following command to install MySQL:

sudo apt-get install mysql-server php5-mysql

  1. Lastly, install PHP by typing in the command below:

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Conclusion

Running a Linux server can be a good investment for an organization that needs stability, flexibility, and security.

Once your server is up and running, we recommend learning how to operate and manage it properly to get the full use out of the operating system.

The following is a recap of the steps to building a Linux server:

  1. Choose and download a Linux distribution.
  2. Create a bootable USB.
  3. Install the Linux server operating system.
  4. Run and test the Linux server.
  5. Update and upgrade the Linux server.
  6. Install web server applications.

We hope this guide has helped you understand how to set up a Linux server.

Top comments (1)

Collapse
 
andrewbaisden profile image
Andrew Baisden

Great guide I want to try a Linux distro at some point.