How to Install Apache (HTTPD) on openSUSE Leap 15

Apache, also known as Apache HTTP server, has been one of the most widely used web server applications globally for the past few decades. It is a free and open-source web application software maintained by the Apache Software Foundation. Apache provides some powerful features with dynamically loadable modules, easy integration with other software, and handling of static files, among other popular features.

In the tutorial, you will learn how to install and configure Apache (HTTPD) on openSUSE Leap 15 with a free TLS/SSL certificate from Let’s Encrypt.


  • Recommended OS: openSUSE Leap – 15.x.
  • User account: A user account with sudo or root access.
  • Required Packages: wget

Update Operating System

Update your openSUSE operating system to make sure all existing packages are up to date:

sudo zypper refresh

Once refreshed, run the update command.

sudo zypper update

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@opensuse ~]$ sudo whoami

To set up an existing or new sudo account, visit our tutorial on adding a User to Sudoers on openSUSE.

To use the root account, use the following command with the root password to log in.


The tutorial will use the terminal for installation found in  Activities> Show Applications > Terminal.


How to Install Apache (HTTPD) on openSUSE Leap 15

Install Apache (HTTPD)

Apache, by default, is in the default openSUSE Leap repositories. This is more practical for most users as it is very stable and secure. To install Apache, open your terminal and execute the following command:

sudo zypper install apache2

Example output:

How to Install Apache (HTTPD) on openSUSE Leap 15

Type “Y,” then press “ENTER KEY” to proceed.

Next, by default Apache (HTTPD) comes disabled and not activated. First, start the service.

sudo systemctl enable apache2 --now

Example output if successful:

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/ → /usr/lib/systemd/system/apache2.service.

Check to see if Apache is running without any errors using the following systemctl command:

systemctl status apache2

Example output if everything is ok:

How to Install Apache (HTTPD) on openSUSE Leap 15

Configure Firewall Rules

When installing Apache, it does not automatically add firewall rules to the standard port 80 or 443 ports. Before you continue, you should set the following rules, this will depend on what ports you will use, but all options are listed.

Open port 80 or HTTP:

sudo firewall-cmd --permanent --zone=public --add-service=http

Open port 443 or HTTPS:

sudo firewall-cmd --permanent --zone=public --add-service=https

Reload firewall to make changes into effect

sudo firewall-cmd --reload

Configure Apache Web Server

You will need to have the server’s IP address ready for set up. The easiest way to do this is with the following.

Find Server IP Address

You will need to have the server’s IP address prepared for set up. The easiest way to do this is with the following.

curl -4

Example output:


If the commands are not working, you do not have the curl package installed more than likely. Run the following command:

sudo zypper install curl

Alternatively, to find the server’s internal IP address, you could use the following command.

hostname -I

You should get back the internal IP address the server is on as an example:


You may get 2 to 3 results back. Try each one until you find the correct IP address.

Create and or Configure Virtual Hosts for Apache

Using the Apache web server, you can create virtual hosts to manage configurations for more than one domain running on a single server. If you have used Nginx before, it is the equivalent of server blocks. In the example below, the tutorial will create a domain which you will replace with your domain name.

Create and or Configure Directories

Firstly, leave /srv/www/html directory intact as the default directory, then create a new directory, for, as below:

sudo mkdir -p /srv/www/your_domain/html

The next step is to fix the directory permissions, which can be changed later on for specific requirements for running CMS, or other permission requirements.

sudo chown -R $USER /srv/www/your_domain/

Usually, the web roots permissions should be set correctly, and you can verify using the -ls l command:

ls -l /srv/www/

Example output:

How to Install Apache (HTTPD) on openSUSE Leap 15

As you can see, we have the permission of drwxr-xr-x, which is the equivalent of chmod 755. If you do not have this permission set, run the following command:

sudo chmod -R 755 /srv/www/your_domain/

Now create a sample page index.html using your favorite text editor. The tutorial will use nano as below:

sudo nano /srv/www/your_domain/html/index.html

In the file, copy and paste the following code:

        <title>Welcome to Website!</title>
        <h1>Success! The virtual host is working! You did not mess it up thanks to</h1>

Save the file (CTRL+O), then exit (CTRL+X).

Create Virtual Host

Now that you have created a landing page and set correct ownership and permissions. The required directories will need to be made and set up by default.

First, make the directories needed for sites-available and sites-enabled. Nginx users would be familiar with this setup as well.

sudo mkdir /etc/apache2/sites-available
sudo mkdir /etc/apache2/sites-enabled

The next step you must do is instruct Apache to look for virtual host files that will need to be located at /etc/httpd/sites-available directory.

Open up the configuration file.

sudo nano /etc/apache2/httpd.conf

Add the following to the end of the file.

IncludeOptional sites-enabled/*.conf

Optionally, you can disable the default folder that Apache looks for virtual hosts files which maybe wanted to avoid confusion.

Just place a comment next to IncludeOptional conf.d/*.conf.


#IncludeOptional /etc/apache2/vhosts.d/conf.d/*.conf
IncludeOptional /etc/apache2/sites-enabled/*.conf

Example in the environment:

How to Install Apache (HTTPD) on openSUSE Leap 15

Save the file (CTRL+O), then exit (CTRL+X).

Next, use your favorite text editor to create a virtual host configuration file located at /etc/httpd/sites-available/example_domain.conf as below:

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

Now, copy and paste the following into the configuration block file, note to replace your ServerName, ServerAlias, and Document root with your own:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example_domain
    ServerAlias www.example_domain
    DocumentRoot /srv/www/your_domain/html

Do not forget to change the required Server directives to your own.

Save the configuration file using (CTRL+O) and exit with (CTRL+X).

Next, you need to enable permissions for the Apache service to allow access publically to your server in the /etc/apache2/httpd.conf configuration file. Failure to do this may result in HTTP 403 errors when trying to access your website, as, by default, the configuration is set to deny access.

Open the configuration file using nano or any text editor of your choice.

sudo nano /etc/apache2/httpd.conf

Now, add the following and make sure to change the root directory to your own.


<Directory /srv/www/your_domain/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

This can be added towards the end of the configuration file, below is an example of it in a live environment.

How to Install Apache (HTTPD) on openSUSE Leap 15

Enable Virtual Host

The next step is to enable the virtual host. Initially, you created two directories, sites-available and sites-enabled. You will need to create a symlink to sites-enabled to activate the virtual host.

To create a symlink, use the following example in your terminal.

sudo ln -s /etc/apache2/sites-available/your_domain.conf /etc/apache2/sites-enabled/

Once done, restart the Apache service.

sudo systemctl restart apache2

Open your Internet Browser and type in your domain name HTTP://example_domain where you should get the following landing page you created in the index.html file:

How to Install Apache (HTTPD) on openSUSE Leap 15

Congratulations, you have successfully created your virtual host and made it work successfully on your domain.

Secure Apache with Let’s Encrypt SSL Free Certificate

Ideally, you would want to run your Apache web server on HTTPS using an SSL certificate. The best way to do this is to use Let’s Encrypt, a free, automated, and open certificate authority run by the nonprofit Internet Security Research Group (ISRG).

Install the certbot package as follows:

sudo zypper install python3-certbot-apache

Once installed, run the following command to start the creation of your certificate:

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email -d

This ideal setup includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Just make sure to adjust the e-mail and domain name to your requirements.

Now your URL will be HTTPS:// instead of HTTP://

If you use the old HTTP URL, it will automatically redirect to HTTPS.

Optionally, you can set a cron job to renew the certificates automatically. Certbot offers a script that does this automatically, and you can first test to make sure everything is working by performing a dry run.

sudo certbot renew --dry-run

If everything is working, open your crontab window using the following terminal command.

sudo crontab -e

Next, specify the time when it should auto-renew. This should be checked daily at a minimum, and if the certificate needs to be renewed, the script will not update the certificate. If you need help finding a good time to set, use the free tool.

00 00 */1 * * /usr/sbin/certbot-auto renew

To save, press the ESCAPE KEY and then type :wq! to save the file. Alternatively, to exit without saving, type :qa!

Managing Apache Service

Now that Apache is running on your server successfully, some management keynotes are as follows.

Apache Server Logs

Apache server logs can be found in the directory /srv/www/your_domain/html with custom.log and error.log, respectfully being the default access and error names given. This can be changed to other names in your virtual host configuration file in the future.

Apache Commands

The following commands that you will undoubtedly use in your day-to-day management when working with Apache. Some of the most common are:

To stop Apache webserver:

sudo systemctl stop apache2

To start Apache webserver:

sudo systemctl start apache2

To restart Apache webserver:

sudo systemctl restart apache2

To reload Apache webserver (For more minor changes not requiring a restart):

sudo systemctl reload apache2

To disable Apache on server boot:

sudo systemctl disable apache2

To start Apache on server boot (Automatically enabled on installation):

sudo systemctl enable apache2

How to Update Apache (HTTPD)

To update Apache in the future, this is done with the command you used to check if your system is up to date. Note, always create backups or images if you have an Apache service running critical services. Usually, it’s pretty safe to upgrade, but sometimes bugs can occur like any software upgrade.

To update Apache, use the following command:

sudo zypper refresh

If an upgrade is available, run the upgrade.

sudo zypper update

How to Remove (Uninstall) Apache (HTTPD)

To remove Apache if you no longer use it, this can be done using the following command:

sudo zypper remove apache2

This command will also remove any unused dependencies that came with the installation.

Comments and Conclusion

In the tutorial, you have learned how to install Apache (HTTPD) on openSUSE Leap 15. Overall, Apache has been the most used web application server for decades. However, Nginx has finally overtaken the lead just slightly.

Apache is still one of the most deployed and recognized web applications, especially with combing LAMP stack, which is often used for back-end web servers. You will find more friendly options for Apache than Nginx, leading newer users to get into hosting their web server, perhaps to try Apache over Nginx as the first step.

Not what you were looking for? Try searching for additional tutorials.

Leave a Comment