This article will take you through how to install LAMP Stack on OpenSUSE. LAMP is an acronym for Linux, Apache, MariaDB/MySQL, and PHP. The LAMP Stack is a set of open-source tools that are used to power websites and online applications. Each component can be used to serve a single application.
How to Install LAMP Stack on OpenSUSE
Use the table of contents below to navigate.
Install Apache on OpenSUSE
- Run the command below to install Apache.
sudo zypper install apache2
Sample output
Loading repository data... Reading installed packages... Resolving package dependencies... The following 2 recommended packages were automatically selected: apache2-utils w3m The following 10 NEW packages are going to be installed: apache2 apache2-mod_dnssd apache2-prefork apache2-utils libapr1-0 libapr-util1-0 libbrotlienc1 libgc1 system-user-wwwrun w3m 10 new packages to install. Overall download size: 3.5 MiB. Already cached: 0 B. After the operation, additional 9.5 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y Retrieving package libapr1-0-1.7.0-5.3.x86_64 (1/10), 116.5 KiB (263.3 KiB unpacked) Retrieving: libapr1-0-1.7.0-5.3.x86_64.rpm ...............[done (199.6 KiB/s)] Retrieving package libbrotlienc1-1.0.9-1.8.x86_64 (2/10), 237.4 KiB (578.0 KiB unpacked) Retrieving: libbrotlienc1-1.0.9-1.8.x86_64.rpm ............[done (95.9 KiB/s)] Retrieving package libgc1-8.2.0-1.4.x86_64 (3/10), 104.6 KiB (245.2 KiB unpacked) Retrieving: libgc1-8.2.0-1.4.x86_64.rpm ................................[done] Retrieving package system-user-wwwrun-20170617-24.8.noarch (4/10), 10.2 KiB ( 96 B unpacked) Retrieving: system-user-wwwrun-20170617-24.8.noarch.rpm ....[done (3.0 KiB/s)] Retrieving package libapr-util1-0-1.6.1-9.5.x86_64 (5/10), 101.6 KiB (257.9 KiB unpacked) Retrieving: libapr-util1-0-1.6.1-9.5.x86_64.rpm ........................[done] Retrieving package w3m-0.5.3+git20180125-1.17.x86_64 (6/10), 1.0 MiB ( 2.2 MiB unpacked) Retrieving: w3m-0.5.3+git20180125-1.17.x86_64.rpm ........[done (340.1 KiB/s)] Retrieving package apache2-prefork-2.4.54-1.1.x86_64 (7/10), 1.3 MiB ( 4.3 MiB unpacked) Retrieving: apache2-prefork-2.4.54-1.1.x86_64.rpm ........[done (430.3 KiB/s)] Retrieving package apache2-utils-2.4.54-1.1.x86_64 (8/10), 168.1 KiB (285.2 KiB unpacked) Retrieving: apache2-utils-2.4.54-1.1.x86_64.rpm ........................[done] Retrieving package apache2-2.4.54-1.1.x86_64 (9/10), 476.2 KiB ( 1.4 MiB unpacked) Retrieving: apache2-2.4.54-1.1.x86_64.rpm ................[done (264.9 KiB/s)] Retrieving package apache2-mod_dnssd-0.6-29.10.x86_64 (10/10), 23.3 KiB ( 45.9 KiB unpacked) Retrieving: apache2-mod_dnssd-0.6-29.10.x86_64.rpm ........[done (81.8 KiB/s)] Checking for file conflicts: ...........................................[done] ( 1/10) Installing: libapr1-0-1.7.0-5.3.x86_64 .........................[done] ( 2/10) Installing: libbrotlienc1-1.0.9-1.8.x86_64 .....................[done] ( 3/10) Installing: libgc1-8.2.0-1.4.x86_64 ............................[done] /usr/bin/systemd-sysusers --replace=/usr/lib/sysusers.d/system-user-wwwrun.conf - Creating group 'www' with GID 456. Creating group 'wwwrun' with GID 455. Creating user 'wwwrun' (WWW daemon apache) with UID 455 and GID 455. ( 4/10) Installing: system-user-wwwrun-20170617-24.8.noarch ............[done] ( 5/10) Installing: libapr-util1-0-1.6.1-9.5.x86_64 ....................[done] ( 6/10) Installing: w3m-0.5.3+git20180125-1.17.x86_64 ..................[done] ( 7/10) Installing: apache2-prefork-2.4.54-1.1.x86_64 ..................[done] ( 8/10) Installing: apache2-utils-2.4.54-1.1.x86_64 ....................[done] Please check /etc/permissions.local for settings of /usr/sbin/suexec . Updating /etc/sysconfig/apache2 ... ( 9/10) Installing: apache2-2.4.54-1.1.x86_64 ..........................[done] (10/10) Installing: apache2-mod_dnssd-0.6-29.10.x86_64 .................[done] Executing %posttrans scripts ...........................................[done]
- Enable Apache to start on boot.
sudo systemctl enable apache2
- Start Apache.
sudo systemctl start apache2
- Check Apache status.
sudo systemctl status apache2
Sample output
● apache2.service - The Apache Webserver Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2022-06-16 12:49:54 EAT; 10s ago Main PID: 7130 (httpd-prefork) Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec" Tasks: 6 CPU: 249ms CGroup: /system.slice/apache2.service ├─ 7130 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> ├─ 7146 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> ├─ 7147 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> ├─ 7148 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> ├─ 7149 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> └─ 7150 /usr/sbin/httpd-prefork -DSYSCONFIG -C "PidFile /run/httpd.pid" -C "Include /etc/apache2/sysconfig.d//loadmodule.conf" -C "Include /etc/apache2/sysconfig.d//global.conf" -f /etc/apache2/httpd.conf -c "Include /etc/ap> Jun 16 12:49:54 localhost.localdomain systemd[1]: Starting The Apache Webserver... Jun 16 12:49:54 localhost.localdomain start_apache2[7130]: AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress th> Jun 16 12:49:54 localhost.localdomain systemd[1]: Started The Apache Webserver. lines 1-18/18 (END)
Install MariaDB on OpenSUSE
- Run the command below to install MariaDB.
sudo zypper install mariadb mariadb-client mariadb-tools
Sample output
Loading repository data... Reading installed packages... Resolving package dependencies... The following recommended package was automatically selected: mariadb The following 9 NEW packages are going to be installed: libJudy1 libodbc2 mariadb mariadb-client mariadb-errormessages mariadb-tools perl-DBD-mysql perl-DBI python38-mysqlclient 9 new packages to install. Overall download size: 30.2 MiB. Already cached: 0 B. After the operation, additional 153.3 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y
- Enable MariaDB to start on boot and start it using the command below.
sudo systemctl enable --now mariadb
- Check MariaDB status.
sudo systemctl status mariadb
Sample output
● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2022-06-16 13:42:46 EAT; 7s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 10261 ExecStartPre=/usr/libexec/mysql/mysql-systemd-helper install (code=exited, status=0/SUCCESS) Process: 10310 ExecStartPre=/usr/libexec/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS) Main PID: 10316 (mysqld) Status: "Taking your SQL requests now..." Tasks: 12 (limit: 4588) CPU: 1.665s CGroup: /system.slice/mariadb.service └─ 10316 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: you need to be the system 'mysql' user to connect. Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: After connecting you can set the password, if you would need to be Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: able to connect as any of these users with a password and without sudo Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: See the MariaDB Knowledgebase at https://mariadb.com/kb Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: Please report any problems at https://mariadb.org/jira Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: The latest information about MariaDB is available at https://mariadb.org/. Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: Consider joining MariaDB's strong and vibrant community: Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10267]: https://mariadb.org/get-involved/ Jun 16 13:42:46 localhost.localdomain mysql-systemd-helper[10316]: 2022-06-16 13:42:46 0 [Note] /usr/sbin/mysqld (server 10.7.3-MariaDB) starting as process 10316 ... Jun 16 13:42:46 localhost.localdomain systemd[1]: Started MariaDB database server.
- Secure MariaDB
sudo mariadb-secure-installation
Sample output
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] n ... skipping. You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Install PHP on OpenSUSE
- Install PHP by running the following command.
sudo zypper install php php-mysql apache2-mod_php8
Sample output
Loading repository data... Reading installed packages... Resolving package dependencies... The following 8 recommended packages were automatically selected: php8-ctype php8-dom php8-iconv php8-openssl php8-sqlite php8-tokenizer php8-xmlreader php8-xmlwriter The following 4 packages are suggested, but will not be installed: php8-cli php8-gd php8-gettext php8-mbstring The following 12 NEW packages are going to be installed: apache2-mod_php8 php8 php8-ctype php8-dom php8-iconv php8-mysql php8-openssl php8-pdo php8-sqlite php8-tokenizer php8-xmlreader php8-xmlwriter 12 new packages to install. Overall download size: 2.5 MiB. Already cached: 0 B. After the operation, additional 6.5 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y
- Check the PHP version.
php -v
Sample output
PHP 8.1.7 (cli) (built: Jun 10 2022 00:00:00) (NTS)
Copyright (c) The PHP Group
- Next, enable the PHP module.
sudo a2enmod php8
- Restart the Apache server to apply changes.
sudo systemctl restart apache2
- Test PHP if it’s working by creating a test file.
sudo nano /srv/www/htdocs/test.php
Paste the following content.
<?php phpinfo(); ?>
- Navigate to your browser and enter your domain/server IP e.g.
localhost/test.php
or127.0.0.1/test.php
- You have made it to the end of our article, congratulations. We have gone through how to install LAMP Stack on OpenSUSE.
Read more on Apache Documentation
Read more on MariaDB Documentation
Read more on PHP Documentation
Other Tutorials
Install WordPress with LAMP Stack on Ubuntu 22.04