Install LAMP – Apache, PHP, MariaDB and PhpMyAdmin in OpenSUSE

The LAMP stack comprises of Linux operating system, Apache web server software, MySQL database management system and PHP programming language. LAMP is a software combination used to serve dynamic PHP web applications and websites. Note that the P can also stand for Perl or Python instead of PHP.

In the LAMP stack, Linux is the foundation of the stack (it holds all the other components); Apache delivers web content (like web pages, etc.) to the end user over the internet upon request through a web browser, PHP is a server-side scripting language used to generate dynamic web pages that runs PHP code and retrieve/save data from/to a MySQL database.

Read Also: Install LEMP – Nginx, PHP, MariaDB and PhpMyAdmin in OpenSUSE

This tutorial will guide you on how to install a LAMP stack with Apache, MariaDB, PHP, and PhpMyAdmin on OpenSuse server/desktop editions.

Installing Apache HTTP Server

The Apache HTTP Server is a free and open source, widely-used and cross-platform web server software. It is designed to be secure, efficient and extensible for providing HTTP services in sync with the current HTTP standards.

On openSUSE, Apache2 comes installed by default. Otherwise, run the following zypper command to install it.

$ sudo zypper install apache2
Install Apache in OpenSuse
Install Apache in OpenSuse

Once the Apache2 installed, you can start the service for the meantime, then enable it to auto-start at boot time and verify the service using the following commands.

$ sudo systemctl start apache2
$ sudo systemctl enable apache2
$ sudo systemctl status apache2
Start Apache Service in OpenSuse
Start Apache Service in OpenSuse

Read Also: 5 Tips to Boost the Performance of Your Apache Web Server

At this stage, the Apache server should be up and running, you can also verify the status using the netstat command as shown.

$ sudo netstat -tlpn | grep httpd
Check Apache Listening Port
Check Apache Listening Port

Now that the web server is running, let’s test if it can serve web pages by creating a test web page (index.html document) in the web DocumentRoot at “/srv/www/htdocs” as follows.

$ echo "<h1>Apache2 is running fine on openSUSE Leap</h1>" | sudo tee /srv/www/htdocs/index.html
Create Apache Test Page
Create Apache Test Page

If you have a firewalld installed and enabled on your machine, remember to allow traffic to the Apache2 web server via the firewall before going to the next step.

$ sudo firewall-cmd --permanent --add-port=80/tcp
$ sudo firewall-cmd --permanent --add-port=443/tcp
$ sudo firewall-cmd --reload
Open Apache Port on OpenSuse
Open Apache Port on OpenSuse

Then open a web browser and navigate using the following address: http://localhost or http://SERVER_IP, the contents of the created web page should be displayed as shown in this screenshot.

Check Apache Test Page
Check Apache Test Page

Installing MariaDB Database Server

MariaDB is a free and open source, fast, scalable and robust and community-developed fork of the MySQL relational database management system. MariaDB comes with more features, new storage engines, plugins and a number of other tools for better performance.

Read Also: 15 Useful MySQL/MariaDB Performance Tuning and Optimization Tips

To install MariaDB on OpenSuse, run the following command.

$ sudo zypper install mariadb mariadb-client 
Install MariaDB in OpenSuse
Install MariaDB in OpenSuse

When the installation is complete, start the MariaDB service for the time being, then enable it to auto-start at system boot time and check if it is up and running as follows:

$ sudo systemctl start mariadb 
$ sudo systemctl enable mariadb 
$ sudo systemctl status mariadb 
Start MariaDB Service in OpenSuse
Start MariaDB Service in OpenSuse

After starting the MariaDB service, next, we need to secure the MariaDB server installation. This can be done by running the security script which comes with the MariaDB package, as shown.

$ sudo mysql_secure_installation 

Once the script is invoked, carefully read the description at each step. You should set a strong root user password, remove anonymous users, disable remote root access, remove the test database and access to it and finally reload privileges table.

Secure MariaDB Installation in OpenSuse
Secure MariaDB Installation in OpenSuse

Installing PHP and PHP Modules

PHP or Hypertext Preprocessor is a free and open source, popular, platform-independent and general-purpose scripting language that is especially suited to web development. PHP is compatible with almost all if not most web servers software out there and supports many database systems including MySQL/MariaDB.

To install PHP along with needed modules run the following command.

$ sudo zypper install php php-mysql php-gd php-mbstring apache2-mod_php7
Install PHP and PHP Modules in OpenSuse
Install PHP and PHP Modules in OpenSuse

Next, enable PHP module and restart Apache web server to effect the latest changes as shown.

$ sudo a2enmod php7
$ sudo systemctl restart apache2

Now verify PHP installation information by creating a PHP test file under the DocumentRoot directory, which should pick the PHP configuration details.

$ echo "<?php phpinfo(); ?>" | sudo tee  /srv/www/htdocs/info.php

Open a web browser and navigate to the address: http://localhost/info.php or http://SERVER_IP/info.php to verify the PHP configuration details as shown in the following screenshot.

Check PHP Installation Info
Check PHP Installation Info

Installing and Configuring PhpMyAdmin

phpMyAdmin is a free and popular web-based tool for MySQL administration. phpMyAdmin enables you to create, alter, drop, delete, import and export MySQL database tables. It is also used to run MySQL queries, optimize, repair and check tables, change collation and execute many other database management commands.

Read Also: 20 MySQL (Mysqladmin) Commands for Database Administration in Linux

To install phpMyAdmin on OpenSuse, run the following command.

$ sudo zypper install phpMyAdmin
Install PhpMyAdmin in OpenSuse
Install PhpMyAdmin in OpenSuse

Now go to your web browser and enter the address http://localhost/phpMyAdmin. A phpMyAdmin login page should display as shown in the following screenshot. Enter your database root user login credentials and click Go.

PhpMyAdmin Dashboard
PhpMyAdmin Dashboard

That’s all! In this tutorial, we’ve explained you how install a LAMP stack with Apache, MariaDB, PHP, and PhpMyAdmin on OpenSuse server/desktop editions. If you’re facing any issues during setup, do ask your questions via a comment form below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. I have followed the instructions to install php with apache2 on opensuse but am not able to execute any php code – there are no messages in the error log, the access log just shows a GET command with return code 200 for the the file containing the php code.

    Any suggestions of how i can find out the problem would be most welcome

    I’m only running web pages on my local server, i.e. i’m not enabling access from outside my system


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.