Technology Encyclopedia Home >How to install and configure a server on Linux?

How to install and configure a server on Linux?

To install and configure a server on Linux, you typically follow these steps:

Installation

  1. Choose a Linux Distribution: Select a distribution based on your needs, such as Ubuntu, CentOS, or Debian.
  2. Download the ISO: Get the ISO file from the official website.
  3. Create a Bootable USB: Use tools like Rufus or Etcher to create a bootable USB drive.
  4. Boot from USB: Insert the USB into your server hardware and boot from it.
  5. Install Linux: Follow the on-screen instructions to install Linux on your server.

Configuration

  1. Update the System:
    sudo apt update && sudo apt upgrade -y  # For Debian/Ubuntu
    sudo yum update -y  # For CentOS
    
  2. Install Necessary Packages:
    sudo apt install apache2 mysql-server php libapache2-mod-php -y  # For a basic web server
    
  3. Configure Services:
    • Apache: Edit configuration files in /etc/apache2/sites-available/ to set up virtual hosts.
    • MySQL: Secure the MySQL installation by running sudo mysql_secure_installation.
  4. Set Up Firewall:
    sudo ufw allow 'Apache Full'  # For Ubuntu
    sudo firewall-cmd --permanent --add-service=http  # For CentOS
    sudo firewall-cmd --reload
    
  5. Enable Remote Access (if needed):
    • Edit SSH configuration in /etc/ssh/sshd_config to allow remote access.
    • Restart SSH service: sudo systemctl restart sshd.

Example

For a simple web server setup on Ubuntu:

  1. Install Apache and PHP:
    sudo apt install apache2 php libapache2-mod-php -y
    
  2. Create a simple PHP info file:
    echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
    
  3. Access the server via browser: http://<your-server-ip>/info.php.

Cloud Service Recommendation

For deploying and managing servers in the cloud, consider using Tencent Cloud. Tencent Cloud offers a variety of services like Cloud Virtual Machine (CVM) which simplifies the process of setting up and managing Linux servers. You can quickly deploy servers with pre-installed software and configurations through Tencent Cloud's console.

By following these steps and utilizing cloud services like Tencent Cloud, you can efficiently install and configure a server on Linux.