• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SMASHING LAB

GUIDES | LINUX | GEEKY STUFF

  • Nginx
  • Linux
  • Guide
  • Ubuntu
  • WordPress
  • Drones, My Hobby

How to Install LAMP on openSUSE Leap 15.1

By Imran Yousaf

In this article, we are going to see how to install a LAMP stack in openSUSE Leap 15.1 step by step, a fundamental pillar of many of the web applications that you can run on your server or openSUSE VPS.

Before installing the LAMP stack on openSUSE Leap 15.1

A LAMP stack is made up of Linux (openSUSE Leap 15.1 in this case), the Apache web server, the PHP programming language and a MariaDB / MySQL database service. In this tutorial, we opted for MariaDB, since to use MySQL we should add new repositories to the system.

How to install LAMP on openSUSE Leap 15.1

To install the LAMP stack in openSUSE Leap 15.1 we will build on the existing packages in the repositories of the distribution, so the first step will be to update the information in these repositories:

1
sudo zypper refresh

We can now install the necessary packages:

1
sudo zypper install -y apache2 mariadb php-mysql

Once these packages and all their dependencies are downloaded and installed, two new services are created in openSUSE Leap 15.1, the apache2.service and mariadb.service services , or apache2 and mariadb if you prefer short names.

Although the PHP module for Apache has been installed, you have to activate it manually:

1
sudo a2enmod php7

Since the LAMP stack services are not running nor are they enabled to start automatically alongside openSUSE Leap 15.1, we have to do it manually:

1
sudo systemctl enable --now apache2 mariadb

We can check the status of services at any time with the command systemctl status apache2 mariadb :

Configure openSUSE Leap 15.1 firewall for LAMP stack

Since the openSUSE Leap 15.1 firewall is enabled by default, it will block any incoming connection for which no exception has been configured. If you want to access your LAMP server from the network you will have to add an exception like this:

1
sudo firewall-cmd --permanent --add-service = {http, https}

The above rule allows access to standard HTTP web traffic and HTTPS encryption. If you are only interested in one of the protocols, modify the command eliminating the one that does not interest you.

The changes are applied by reloading the firewall settings:

1
sudo firewall-cmd --reload

How to configure LAMP in openSUSE Leap 15.1

Once the Apache web server is able to connect to PHP and it in turn can connect to the database service, configuring the LAMP stack in openSUSE Leap 15.1 comes down to making a few adjustments.

PHP settings

We will edit the PHP configuration file, php.ini :

1
sudo nano /etc/php7/apache2/php.ini

An adjustment that should always be made is to configure the time zone for web applications, through the date.timezone directive :

1
2
3
4
5
6
...
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = 'UTC'
...

We change the value to suit the time zone that interests us:

1
2
3
...
date.timezone = Asia /Karachi
...

If you don’t know the value that corresponds to your zone, you can check all the possible values of PHP time zones.

If the LAMP server you are configuring is for production, there are no changes to be made regarding the handling of PHP error messages, but if it is a development environment, locate the following directives and change their values ​​accordingly:

1
2
3
4
5
6
7
...
error_reporting = E_ALL
...
display_errors = On
...
display_startup_errors = On
...

With these values, ​​if errors occur in applications, PHP will display error messages in the browser.

Saving the changes in php.ini it will be necessary to reload the Apache configuration:

1
sudo systemctl reload apache2

MariaDB settings

The MariaDB installation creates anonymous users, test database, and rootless password access . To solve all this we will use the interactive script mysql_secure_installation :

1
2
3
sudo mysql_secure_installation
...
Enter current password for root (enter for none):

We are asked for the current password of the root user of MariaDB, so since at this moment it does not have any, we will press enter.

We will be asked if we want to create the password for root :

1
2
...
Set root password? [Y / n] Y

The usual thing is to answer yes, so we will be asked for the new password and confirmation:

1
2
3
...
New password:
Re-enter new password:

We are asked if we want to delete anonymous accounts:

1
2
...
Remove anonymous users? [Y / n] Y

We should answer yes.

Next we are asked if remote access for root is disabled :

1
2
...
Disallow root login remotely? [Y / n] Y

To avoid attacks and intrusion attempts, it is important to answer yes.

We are also asked if we want to delete the test database:

1
2
...
Remove test database and access to it? [Y / n] Y

It is useless, so it is safe to answer yes.

Finally, we are asked if the privilege table is reloaded now:

1
2
...
Reload privilege tables now? [Y / n] Y

Whenever access credentials are changed, users are created or deleted, etc. It is interesting to refresh the system permissions, so it is safe to answer yes.

The script ends and MariaDB is more secure than the one established by the default installation.

How to test LAMP stack in openSUSE Leap 15.1

To test the LAMP stack in openSUSE Leap 15.1 we will create a simple PHP script easily accessible via the web:

1
sudo nano /srv/www/htdocs/info.php

The content will be a call to the phpinfo () function :

1
<!--?php phpinfo (); ?-->

Once the changes have been saved, we can access this script from the browser. As URL we will add the route /info.php to the IP address or domain of the openSUSE Leap 15.1 server:

In addition to checking that the environment works, we can examine a multitude of data on the current configuration.

Conclusion

You already know how to install and configure a LAMP stack in openSUSE Leap 15.1, so you can start developing complex web applications, or establish the support on which popular applications, CMS, etc. are installed.

In case of doubts, questions, suggestions, etc. you can leave a comment.

Some more articles you might also be interested in …

  • How to install Zabbix on openSUSE Leap 15.1
  • How to install LAMP on CentOS 8
  • How to Install LAMP Stack (Linux, Apache, MySQL,…
  • Install Docker in CentOS 7
  • How to install Nextcloud on CentOS 8
  • How to Install Brackets on Debian / Ubuntu
  • Guide How to Install Apache in Ubuntu 18.04
  • Install and Configure Apache on Ubuntu Server
  • How to Install and Secure phpMyAdmin with Apache on…
  • How to Install and Use Multiple Versions of PHP on…
Tweet
Pin
Share
0 Shares

Filed Under: Guide

Primary Sidebar

  • Twitter
  • Facebook
  • Google+

Recent Posts

  • How to install Nextcloud on CentOS 8
  • How to install Zabbix on openSUSE Leap 15.1
  • How to Easily Configure Your Domain’s Email Account with Gmail?
  • Tails 4.4 OS Released with Tor Browser 9.0.6
  • How to Convert JPG to PDF in Linux

Subscribe to our Newsletter

Useful articles, tips and videos about creating and promoting websites to your mail



* required field


  • Contact Us
  • Privacy Policy
  • About Us

Copyright © 2021. Smashing Lab