How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15.3

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

In this tutorial, we will explain to you how to install LAMP stack on the latest openSUSE release. Let me just refresh your mind that LAMP is a combination of the words Linux Apache MySQL and Php.

Step 1 : update your software

in this step we will update the repository and the packages of the system, the Command needed is

zypper up

Step 2: Install Apache Web Server

we do it with :

zypper in apache2

By default, Apache will not automatically start after installation. You can start it with:

systemctl start apache2


And enable auto-start at boot time with:

systemctl enable apache2

Check its status:

stemctl status apache

unixcop-opensuse:~ # systemctl status apache2
● apache2.service - The Apache Webserver
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-09-22 06:12:58 EDT; 7s ago
   Main PID: 17278 (httpd-prefork)
     Status: "Processing requests..."
      Tasks: 6
     CGroup: /system.slice/apache2.service
             ├─17278 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>
             ├─17287 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>
             ├─17288 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>
             ├─17290 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>
             ├─17291 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>
             └─17292 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/a>

Sep 22 06:12:58 unixcop-opensuse systemd[1]: Starting The Apache Webserver...
Sep 22 06:12:58 unixcop-opensuse start_apache2[17278]: AH00557: httpd-prefork: apr_sockaddr_info_get() failed for unixcop-opensuse
Sep 22 06:12:58 unixcop-opensuse start_apache2[17278]: AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 1>
Sep 22 06:12:58 unixcop-opensuse systemd[1]: Started The Apache Webserver.

Check the Apache version with :

apachectl -v

Output is :

unixcop-opensuse:~ # apachectl   -v
Server version: Apache/2.4.43 (Linux/SUSE)
Server built:   2021-08-13 07:09:48.000000000 +0000


Create your First Welcome Apache home page

vi /srv/www/htdocs/index.html

Also you can use nano editor instead if you are not familiar with vi and add

<html> 
<body> 
  <h1> It Unixcop home page at Opensuse !</h1> 
</body> 
</html>

Save and exit

Configure The Firewall to allow apache service

firewall-cmd  --permanent  --zone=public --add-service=http
firewall-cmd  --permanent  --zone=public --add-service=https
firewall-cmd  --reload

Now try to reach the home page with httpd://ip

2-Install MariaDB onOpensuse

To install MariaDB on OpenSUSE , Please follow the instructions below.

zypper install mariadb mariadb-client mariadb-tools
You have just installed MariaDB server for the first time.

You can start it via:
 systemctl start mariadb
or
 rcmysql start

During the first start, empty database will be created for you automatically.

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER!
To do so, start the server and run the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h <hostname> password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.


Set Mysql Root Password

Check first if MySQL/MariaDB is enabled and running, so run this command, then do this command

mysql_secure_installation

Login to Mariadb

unixcop-opensuse:~ # mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.5.12-MariaDB MariaDB package

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create  database   test;
Query OK, 1 row affected (0.001 sec)

Step4 : Install PHP

How to install php in Opensuse 15.3

Like this

 zypper install php7 php7-mysql apache2-mod_php7

Now Test PHP page info

Edit with vi or nano /srv/www/htdocs/info.php , and add

<?php phpinfo(); ?>

save and exit

Enable Php modules and restart Apache

a2enmod php7

systemctl restart apache2

Check now the http://ip/info.php

You add some extra PHP libraries if you like

php7-xmlreader php7-zip php7-pdo php7-gd php7-json php7-mysql php7-mbstring php7-openssl

Step5 :  Install phpMyAdmin

For this chapter, it’s not really part of LAMP, but still needed for the beginners to manage the databases via a GUI interface,

How to install phpMyAdmin on Opensuse 15.3

zypper install phpMyAdmin

Restart Apache

systemctl restart apache2

Join  phpMyAdmin console  http://IP/phpMyAdmin


Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook