Welcome to this step-by-step guide on setting up a server. In this session, we will cover various aspects of server configuration, including SSL certificate setup and database configuration.
First, let's start with the basic server setup. You'll need to have a clean operating system installed. For this guide, we will use Ubuntu 20.04 LTS. Ensure your system is updated by running the following commands:
sudo apt update
sudo apt upgrade
Once your system is updated, we will install essential packages. These include curl
, git
, and build-essential
. Run the following command to install these packages:
sudo apt install curl git build-essential
Next, we will install Nginx, a popular web server. Use the following command to install Nginx:
sudo apt install nginx
After installing Nginx, we need to start and enable the Nginx service. Run the following commands:
sudo systemctl start nginx
sudo systemctl enable nginx
To ensure Nginx is running correctly, open your web browser and navigate to your server's IP address. You should see the Nginx welcome page.
Now, let's set up a firewall to allow traffic on HTTP (port 80) and HTTPS (port 443). Use the following commands to adjust the firewall settings:
sudo ufw allow 'Nginx Full'
sudo ufw enable
With the firewall configured, we can now proceed to set up an SSL certificate. We will use Let's Encrypt, a free and open certificate authority. First, install Certbot and the Nginx plugin by running:
sudo apt install certbot python3-certbot-nginx
After the installation, obtain an SSL certificate using Certbot. Replace your_domain
with your actual domain name:
sudo certbot --nginx -d your_domain -d www.your_domain
Follow the prompts to complete the SSL certificate setup. Certbot will automatically configure Nginx to use the new certificate.
To test the SSL configuration, navigate to https://your_domain
in your web browser. You should see a secure connection indicated by a padlock icon.
Next, let's set up the database. We will use MySQL for this guide. Install MySQL by running the following command:
sudo apt install mysql-server
After the installation, secure your MySQL installation by running:
sudo mysql_secure_installation
Follow the prompts to set up a root password and remove unnecessary features.
Once MySQL is secured, log in to the MySQL shell as the root user:
sudo mysql -u root -p
Create a new database and a user with permissions to access it. Replace new_database
, new_user
, and password
with your desired values:
CREATE DATABASE new_database;
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON new_database.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Your server setup is now complete. You have successfully installed and configured Nginx, set up an SSL certificate, and created a MySQL database. For more detailed steps on each section, please refer to the dedicated pages: