Image
Prerequisites

Before you begin, make sure you have the following:

  • A machine running Ubuntu (preferably the latest stable version).
  • Access to a user account with superuser (sudo) privileges.
  • Internet connection.

Step 1: Update the System

It is important to start by updating the system to ensure that all packages are in their latest version.

sudo apt update
sudo apt upgrade

        
Step 2: Install Apache2

Ubuntu includes Apache2 in its default repositories, making it easy to install using the command apt.

sudo apt install apache2

        
Step 3: Verify Installation

Once the installation is complete, the Apache2 server should start automatically. You can check its status with the following command:

sudo systemctl status apache2

        

You should see output similar to this, indicating that Apache2 is running:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2024-07-18 10:00:00 UTC; 1min 23s ago
   ...


        
Step 4: Adjust the Firewall

If you have the UFW (Uncomplicated Firewall) enabled on your machine, you need to allow HTTP and HTTPS traffic. You can do it with the following commands:

sudo ufw allow 'Apache Full'

        

To check the status of the firewall and the rules that are applied, use:

sudo ufw status

        
Step 5: Test Apache2

To ensure that Apache2 is working correctly, open your web browser and navigate to your server's IP address. If you are running Apache on your local machine, you can use localhostand you can also use 127.0.0.1.

http://localhost

        

You should see the default Apache2 welcome page, confirming that the web server is installed correctly and working.

Step 6: Manage the Apache2 Service

It is useful to know how to handle the Apache2 service. Here are some essential commands:

  • Start Apache2:
    sudo systemctl start apache2
    
                    
  • Stop Apache2:
    sudo systemctl stop apache2
    
                    
  • Restart Apache2:
    sudo systemctl restart apache2
    
                    
  • Reload Apache2 (applies configuration changes without disconnecting current connections):
    sudo systemctl reload apache2
    
                    
  • Enable Apache2 to start automatically at system boot:
    sudo systemctl enable apache2
    
                    
  • Disable Apache2 from starting automatically:
    sudo systemctl disable apache2
    
                    
Step 7: Basic Apache2 Configuration

The Apache2 configuration files are located in the /etc/apache2. Some important files and directories include:

  • /etc/apache2/apache2.conf: Main configuration file.
  • /etc/apache2/sites-available/: Configuration files for available sites.
  • /etc/apache2/sites-enabled/: Symbolic links to files in sites-availablefor enabled sites.
  • /etc/apache2/conf-available/y /etc/apache2/conf-enabled/: For global configuration modules.
  • /var/www/html/: Default root directory for web documents.

To create a new website, you can copy the default configuration file and modify it according to your needs:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.conf

        

Edit the file mysite.confwith a text editor:

sudo nano /etc/apache2/sites-available/mysite.conf

        

Inside this file, you can define the root directory of the website, the server name, etc. Here's a basic example:

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.com
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/mysite

    <Directory /var/www/mysite>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

        

Enable the new site and reload Apache2:

sudo a2ensite mysite.conf
sudo systemctl reload apache2

        
Conclusion

Congratulations! You now have Apache2 installed and configured on your Ubuntu server. Apache2 is a robust and flexible web server that can handle everything from small personal websites to large enterprise applications. Feel free to explore more about its configuration and additional modules to expand its functionality.



Comentar:
captcha

Comentarios: Sin comentarios

Below you can find the necessary commands to carry out a correct installation of PyQt6...

Seguir leyendo...

Artificial intelligence (AI) has gone from being a futuristic concept to an omnipresent reality in our daily lives. From virtual assistants like Siri and Alexa to advanced medical diagnostic systems, AI is revolutionizing the way we interact with technology...

Seguir leyendo...

Would you like to know which are the most popular games of the year 2024?...

Seguir leyendo...

DDR4 RAM (Double Data Rate 4) is one of the most advanced technologies used in modern equipment. There are multiple varieties of DDR4 modules, segmented according to different properties such as physical size, capacity, speed, voltage and specific applications...

Seguir leyendo...

In this section you can join two images vertically or horizontally....

Seguir leyendo...

In this section you can search for synonyms of a certain word in multiple languages....

Seguir leyendo...

In the following form you can upload an image to obtain the characters it contains....

Seguir leyendo...

Through the following form you can upload a video to transform it into mp4 format....

Seguir leyendo...

You can then upload an audio file to trim the part of the audio you need....

Seguir leyendo...

Through the following form you can upload an audio file to transcribe it into text....

Seguir leyendo...

The commands necessary to make or not make a certain file executable are shown....

Seguir leyendo...

Explore the fundamental differences between USB 4.0 and USB 3.2....

Seguir leyendo...

Social engineering is an attack method that exploits human weaknesses rather than technological ones. Instead of trying to force their way into a system, cybercriminals manipulate people into voluntarily handing over the information they seek....

Seguir leyendo...

You can then upload a video file to trim the part of the video you need....

Seguir leyendo...

Through the following form you can upload a video to extract and download the audio....

Seguir leyendo...

Discover which partitions are essential to install and use Ubuntu without problems....

Seguir leyendo...



    Publicaciones recientes

    Natural remedies that will help you eliminate skin fungus effectively and safely....

    November 21, 2024

    Explore the world's longest-living animal and its amazing longevity secrets....

    November 21, 2024

    Discover which is the most played rock song and its impact on music....

    November 20, 2024

    Learn how to make carbon fiber tubes, step by step, and improve your creation skills....

    November 20, 2024

    Discover if osteoarthritis is curable, its treatments and advice for living with this disease....

    November 20, 2024

    Effective natural remedies to prevent hair loss caused by stress....

    November 17, 2024

    Discover the 3 best applications that will transform your streaming experience on social networks....

    November 17, 2024

    An in-depth analysis of the most threatening viruses for human health today....

    November 16, 2024

    Learn about the necessary care and life expectancy of our feline friends....

    November 16, 2024

    Discover the best food to keep your cat healthy and happy....

    November 16, 2024

    The causes of myopia and how it affects our quality of life....

    November 16, 2024

    Discover the main features that make the Xiaomi 14T Pro an exceptional smartphone....

    November 16, 2024


    Lo más visto

    In the times of digital technology and high definition (HD) flat screens, televisions continue to dominate the living room. Meanwhile, there is another possibility that, although less common, offers several interesting a...

    July 27, 2024

    Below you can find the necessary commands to carry out a correct installation of PyQt6...

    August 9, 2024

    Artificial intelligence (AI) has gone from being a futuristic concept to an omnipresent reality in our daily lives. From virtual assistants like Siri and Alexa to advanced medical diagnostic systems, AI is revolutionizin...

    July 24, 2024

    This article shows how to install Apache2 step by step on Ubuntu...

    July 24, 2024

    Would you like to know which are the most popular games of the year 2024?...

    July 26, 2024

    Proper indentation makes HTML code easier to read and understand. When HTML tags are well organized and nested correctly, it is easier for developers to identify the structure of the document, see which elements contain ...

    August 10, 2024

    The impact of heat on people is a topic of growing concern, especially in the context of climate change and increasingly frequent and severe heat waves.. . ...

    August 8, 2024

    Indenting JavaScript code not only improves the aesthetics of the code, but also offers significant practical benefits that make it easier to read, maintain, collaborate, and overall quality of the software. It's an esse...

    August 10, 2024

    Discover why vitamin B12 is vital for cellular and nervous system health....

    September 26, 2024

    New technologies have significantly altered our way of seeing the world, working and relating.. Meanwhile, its consequences on global warming are something of great relevance and complexity.. . ...

    July 25, 2024

    DDR4 RAM (Double Data Rate 4) is one of the most advanced technologies used in modern equipment. There are multiple varieties of DDR4 modules, segmented according to different properties such as physical size, capacity, ...

    July 27, 2024

    Discover how to guarantee a balanced diet for your pets and the best 'light' feeds on the market....

    September 26, 2024