How to install and configure Apache on openSUSE or SLES
SUSE Linux Enterprise Server or SLES is the recommended version of SUSE for server deployment though the installation and related documentation are not as polished as other major Linux distributions.
Apache webserver can be installed on both openSUSE and SLES using zypper from the command line. It requires further configuration before being usable as the installer package does not automatically configure some of the options like other major Linux distributions.
Steps to install and configure Apache on openSuSe or SLES:
Launch terminal application.
Refresh zypper package list.
> sudo zypper refresh [sudo] password for root: Repository 'Main Repository (NON-OSS)' is up to date. Repository 'Main Repository (OSS)' is up to date. Repository 'Main Update Repository' is up to date. Repository 'openSUSE-20191225-0' is up to date. All repositories have been refreshed.
Install apache2 package using zypper.
> sudo zypper install --no-confirm apache2 Loading repository data... Reading installed packages... Resolving package dependencies... The following 6 NEW packages are going to be installed: apache2 apache2-prefork apache2-utils libgc1 system-user-wwwrun w3m The following recommended package was automatically selected: w3m 6 new packages to install. Overall download size: 2.5 MiB. Already cached: 0 B. After the operation, additional 7.7 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y
Test configured Apache options for errors.
> sudo apachectl configtest AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message Syntax OK
Related: How to check Apache configuration
Restart apache2 service once you're done with yur configuration.
> sudo systemctl restart apache2
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.
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
Reload firewall for rule changes to take effect.
> sudo firewall-cmd --reload success
Add DirectoryIndex file to DocumentRoot folder.
> sudo vi /srv/www/htdocs/index.html
Make sure DocumentRoot folder has correct ownership.
> sudo chown --recursive wwwrun:wwwrun /srv/www/
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 <h1>Your Apache service is up and running</h1> Congratulation.