How to Install Web Server on Debian?

//

Heather Bennett

Are you looking to install a web server on your Debian system? Look no further!

In this tutorial, we will guide you through the step-by-step process of installing a web server on Debian. Whether you’re a beginner or an experienced user, this guide will help you set up a web server in no time.

Step 1: Update your system

Before we begin, let’s make sure our system is up to date. Open the terminal and run the following command:

sudo apt update && sudo apt upgrade -y

Step 2: Install Apache

Apache is one of the most popular web servers available. To install Apache, run this command:

sudo apt install apache2 -y

Note: The -y flag automatically confirms any prompts during the installation process.

Step 3: Configure Firewall

To allow incoming traffic on port 80 (HTTP) and port 443 (HTTPS), we need to configure the firewall. Run these commands:

sudo ufw allow 'Apache'

If you have other services running on these ports, make sure to adjust the rules accordingly.

Step 4: Test Apache Installation

To verify if Apache is installed correctly, open your web browser and enter your server’s IP address or localhost in the address bar. You should see the default Apache page.

Congratulations!

You have successfully installed Apache on your Debian system. Now let’s move on to installing PHP.

Step 5: Install PHP

To install PHP and its necessary modules, run the following command:

sudo apt install php libapache2-mod-php -y

Once the installation is complete, we need to restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 6: Test PHP Installation

To test if PHP is working correctly, create a new file called info.php in the Apache web root directory:

sudo nano /var/www/html/info.php

Add the following code to the file:

<?php
phpinfo();
?>

Save and close the file. Now, open your web browser and enter http://your_server_ip/info.php. You should see a page displaying detailed information about your PHP installation.

You’re almost there!

We have successfully installed Apache and PHP on your Debian system. Now let’s move on to installing MySQL for database support.

Step 7: Install MySQL

To install MySQL, run this command:

sudo apt install mysql-server -y

During the installation, you will be prompted to set a root password. Choose a strong password and remember it.

Step 8: Secure MySQL Installation

To improve security, run the following command:

sudo mysql_secure_installation

This command will guide you through some recommended security settings for your MySQL installation.

Congratulations!

You have successfully installed Apache, PHP, and MySQL on your Debian system. You now have a fully functional web server ready to host your websites.

Conclusion

In this tutorial, we covered the step-by-step process of installing a web server on Debian. We installed Apache, PHP, and MySQL, which are the core components for hosting websites. Now you can start developing and hosting your own websites on your Debian server.

Remember to regularly update your system and keep an eye on security best practices for a secure and reliable web server.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy