- SDB:Apache installation
- General Machine Setup
- Installation of Apache Packages
- Firewall Adjustments
- Starting Server
- Apache Modules
- Virtual Hosts
- Custom Configuration
- Trouble Shooting
- See also
- Related articles
- External links
- How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15.1
- Step 1: Update Software
- Step 2: Install Apache Web Server
- Step 3: Install MariaDB
- Step 4: Install PHP7
- Step 5: Test PHP
- Step 6: Install phpMyAdmin (optional)
SDB:Apache installation
This document provides a quick step by step guide to get Apache running on your openSUSE box.
Warning: It does not cover the concepts of web servers in detail. Please do not use the steps given below for production machines as the security considerations needed to successfully run a web server have not been taken care of. The below steps are mainly for users wanting or desiring to deploy the Apache software either for further tweaking or web development purposes.
General Machine Setup
The first thing which must be taken care of is the network. The network must be properly configured before proceeding further.
The second thing is to ensure that the system is uptodate. This can be done by opening the YaST Control Center. In the Software section click the Online update icon to check for software update and install them.
Installation of Apache Packages
The Apache web server can be installed by using zypper. Open a terminal and become root. Type the below command:
Firewall Adjustments
By default the firewall configuration blocks all traffic coming on port 80 to your machine. So if you need to allow access so that the web server can be accessed from within a LAN we need to fine tune the firewall configuration. The below step needs to be performed as root user. The supplied configurations are called apache2 and apache2-ssl. They can be enabled via YaST, by adding them to FW_CONFIGURATIONS_EXT in /etc/sysconfig/SuSEfirewall2
Starting Server
Start the server and configure it to automatically start at boot time.
Apache Modules
To enable required Apache Modules we can edit APACHE_MODULES in /etc/sysconfig/apache2. Modules can also be enabled/disabled/listed with the commands below. Any such operation requires a restart of the service and of course needs root privileges.
Virtual Hosts
The directory for virtual host configurations is /etc/apache2/vhosts.d/. As you can see there are two sample configuration files — one with ssl; one without ssl. We use the template without ssl. Only files ending with «.conf» are automatically included to the apache configuration.
- Plan your website infrastructure. It’s helpful to use a directory (/srv/www/vhosts) including one subdirectory for each virtual host.
- Name Based
- Port Based
- Port based
- Copy the sample configuration file vhost.template to .conf and create the subdirectory for this virtual host.
- Now edit the copied configuration file and adjust the following as needed:
- Change the document root for your virtual host: DocumentRoot /srv/www/vhosts/
- You also need to change corresponding directory directive: «>
- It is possible to replace the «*» with an IP addess and «80» with a non standard http port. See Apache Documentation.
- Restart Apache
Custom Configuration
Add/edit configuration for all virtual hosts to /etc/apache2/default-server.conf. Edit APACHE_CONF_INCLUDE_FILES in /etc/sysconfig/apache2 to include configurations from external files. To understand the hierarchy and layout of all include files, read the comments at the top of httpd.conf The old, single, 40K, monolithic configuration file is available in /usr/share/doc/packages/apache2/httpd-std.conf-prefork.
Trouble Shooting
Read any error messages when you start the service. Reproduce what is not working and see how it is reflected in the logs. The log files can be monitored in a root shell with the following command:
If you suspect a bug, please report it
See also
Related articles
External links
How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15.1
In this tutorial, we’re going to look at how to install Apache, MariaDB, PHP7 (LAMP stack) with phpMyAdmin on openSUSE Leap 15.1.
Step 1: Update Software
Before installing any software, it’s always a good idea to update repository and software packages.
Step 2: Install Apache Web Server
Install Apache on openSUSE using the following command.
sudo zypper install apache2
By default, Apache will not automatically start after installation. You can start it with:
sudo systemctl start apache2
And enable auto start at boot time with:
sudo systemctl enable apache2
We can see from the screenshot that Apache is running and auto start enabled.
Server version: Apache/2.4.33 (Linux/SUSE) Server built: 2020-02-25 09:51:10.000000000 +0000
Now create index.html file under the document root.
sudo nano /srv/www/htdocs/index.html
Put the following text into the file.
Save and close the file. Then in your browser’s address bar, type the IP address of openSUSE Leap 15.1. You should see the “It works!” Web page which means Apache Web server is running correctly.
If you are installing LAMP on your local openSUSE Leap 15.1 machine, just type 127.0.0.1 or localhost in the browser address bar.
By default the SuSE firewall prohibit public access to port 80. To allow public access, you need to edit the firewall configuration file. (If you don’t have the following file, it’s probably your OpenSUSE system doesn’t have SuSEfirewall installed. You can install it with: sudo zypper install SuSEfirewall2 .)
sudo nano /etc/sysconfig/SuSEfirewall2
Change it to the following to allow public access to port 80.
Save and close the file. Then restart SuSE firewall.
sudo systemctl restart SuSEfirewall2
Finally, we need to make wwwrun (Apache user) as the owner of Document root.
sudo chown wwwrun /srv/www/htdocs/ -R
Step 3: Install MariaDB
Install MariaDB server and client on openSUSE Leap using the following command.
sudo zypper install mariadb mariadb-client mariadb-tools
By default, MariaDB won’t start automatically after installed. We can start it with:
sudo systemctl start mysql
And enable auto start at boot time with:
sudo systemctl enable mysql
We can see from the screenshot that MariaDB is running and auto start enabled.
mysql Ver 15.1 Distrib 10.2.31-MariaDB, for Linux (x86_64) using EditLine wrapper
Now any user on the system can log into MariaDB as root with the following command:
To restrict access, we need to set a password for the MariaDB root user. Run the following command:
sudo mysql_secure_installation
When it asks you to enter MariaDB root password, press Enter because you have not set the root password yet. Then enter y to set the root password for MariaDB server.
Next you can just press Enter to answer all the remaining questions. This will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security.
Now you can log into MariaDB with the following command
Step 4: Install PHP7
Enter the following command to install PHP7 and PHP7 extensions.
sudo zypper install php7 php7-mysql apache2-mod_php7
Then enable PHP module and restart Apache web server.
sudo a2enmod php7 sudo systemctl restart apache2
Step 5: Test PHP
Create a test.php file in document root.
sudo nano /srv/www/htdocs/test.php
Paste the following PHP code into the file.
Save and close the file. Now in the browser address bar, enter server-ip-address/test.php . Replace sever-ip-address with your actual IP. If you follow this tutorial on your local computer, then type 127.0.0.1/test.php or localhost/test.php .
You should see your server’s PHP information. This means PHP processing is fine.
For your server’s security, you should delete test.php file now.
Step 6: Install phpMyAdmin (optional)
phpMyAdmin is a web-based MySQL/MariaDB administration tool. If you don’t want to administrate MariaDB from command line, then you can install phpMyAdmin with the command below.
sudo zypper install phpMyAdmin
Zypper package manager will automatically install required PHP7 extensions for you. Once it’s installed, restart Apache to enable these PHP7 extensions.
sudo systemctl restart apache2
Then you can visit phpMyAdmin web interface via
And login with MariaDB root password.
Congrats! You have successfully installed Apache, MariaDB and PHP7 on openSUSE Leap 15.1. Subscribe to our free newsletter to get latest Linux tutorials. You can also follow us on Google+, Twitter or like our Facebook page.