The Apache HTTP Server, colloquially known as Apache, is one of the most widely-used web server software. It is open-source and has been a favorite for many system administrators due to its robustness, customization capability, and active community.

Both openSUSE and SUSE Linux Enterprise Server (SLES) are among the top-tier distributions in the Linux world. They are preferred for their stability and enterprise-grade features. If you're looking to deploy a website or web application on these platforms, you'll likely consider using Apache.

While the process is straightforward, there are specific steps and commands tailored for these distributions. Let's dive in and guide you through the installation and basic configuration of Apache on openSUSE or SLES.

Steps to install and configure Apache on openSUSE or SLES:

  1. Open the terminal.
  2. Refresh zypper package list.

    > sudo zypper refresh
    [sudo] password for root: 
    Retrieving repository 'Update repository of openSUSE Backports' metadata ...........[done]
    Building repository 'Update repository of openSUSE Backports' cache ................[done]
    Retrieving repository 'Non-OSS Repository' metadata ................................[done]
    Building repository 'Non-OSS Repository' cache .....................................[done]
    Retrieving repository 'Open H.264 Codec (openSUSE Leap)' metadata ..................[done]
    Building repository 'Open H.264 Codec (openSUSE Leap)' cache .......................[done]
    Retrieving repository 'Main Repository' metadata ...................................[done]
    Building repository 'Main Repository' cache ........................................[done]
    Retrieving repository 'Update repository with updates from SUSE Linux Enterprise 15'[done]
    Building repository 'Update repository with updates from SUSE Linux Enterprise 15' c[done]
    Retrieving repository 'Main Update Repository' metadata ............................[done]
    Building repository 'Main Update Repository' cache .................................[done]
    Retrieving repository 'Update Repository (Non-Oss)' metadata .......................[done]
    Building repository 'Update Repository (Non-Oss)' cache ............................[done]
    All repositories have been refreshed.
  3. Install apache2 package using zypper.

    > sudo zypper install --no-confirm  apache2
    Loading repository data...
    Reading installed packages...
    Resolving package dependencies...
    
    The following recommended package was automatically selected:
      w3m
    
    The following 8 NEW packages are going to be installed:
      apache2 apache2-prefork apache2-utils libapr1 libapr-util1 libgc1 system-user-wwwrun w3m
    
    8 new packages to install.
    Overall download size: 2.8 MiB. Already cached: 0 B. After the operation, additional 14.3
    MiB will be used.
  4. Configure Apache options as necessary.

    > sudo vi /etc/apache2/httpd.conf
  5. Test configured Apache options for errors.

    > sudo apachectl configtest
    AH00557: httpd-prefork: apr_sockaddr_info_get() failed for host
    AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
    Syntax OK
  6. Restart apache2 service once you're done with yur configuration.

    > sudo systemctl restart apache2
  7. Configure apache2 service to automatically start during system boot.

    > sudo systemctl enable apache2
    Created symlink /etc/systemd/system/httpd.service → /usr/lib/systemd/system/apache2.service.
    Created symlink /etc/systemd/system/apache.service → /usr/lib/systemd/system/apache2.service.
    Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /usr/lib/systemd/system/apache2.service.
  8. Enable network access to port 80 (http) and 443 (https) if firewall is enabled.

    > sudo firewall-cmd --permanent --add-service=http --add-service=https
    success
  9. Reload firewall for rule changes to take effect.

    > sudo firewall-cmd --reload
    success
  10. Add DirectoryIndex file to DocumentRoot folder.

    > sudo vi /srv/www/htdocs/index.html
  11. Make sure DocumentRoot folder has correct ownership.

    > sudo chown --recursive wwwrun:wwwrun /srv/www/
  12. Access the website using browser or command line tools to test if your Apache web server is up and running.

    > curl 127.0.0.1
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Welcome to Apache on SUSE</title>
    ##### snipped

    There's no default DirectoryIndex file in the DocumentRoot folder. The output here depends on the content of the index.html file that you've created in the previous steps.