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.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

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.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.