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.
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
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
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
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
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
Then open a web browser and navigate using the following address:
http://SERVER_IP, the contents of the created web page should be displayed as shown in this screenshot.
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.
To install MariaDB on OpenSuse, run the following command.
$ sudo zypper install mariadb mariadb-client
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
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.
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
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://SERVER_IP/info.php to verify the PHP configuration details as shown in the following screenshot.
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.
To install phpMyAdmin on OpenSuse, run the following command.
$ sudo zypper install phpMyAdmin
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.
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.