The LAMP Stack is a collection of open source software packages installed together on the Linux operating system to get your website and web application running on it. LAMP or - Linux, Apache, MySQL, and PHP - provides the foundation to host web applications based on PHP and MySQL (like Wordpress, Joomla, Drupal, Moodle etc.) run on it.

 

In this tutorial, I will guide you trough the steps to install the LAMP Stack with OpenSUSE Leap 42.x and 15.x as the Linux operating system. We will Install apache2 with MariaDB and PHP (By choice version 5 or 7) on the server.

 

Prerequisites: 

  • The user account that will be used to perform the installation has root/sudo rights

  • The Firewall ports 80 and 443 are open.

  • Some 'old' tools have to be installed, just to make sure that the 'ifconfig'-command is present when needed. If this has not been done yet then install these with: 'zypper install net-tools-deprecated'

  • The server only uses IPV4, please disable IPV6 support!

 

Step 1: Update Linux

Before installing ANY software please ensure that the installed version of OpenSUSE is up to date!

sudo zypper update

 

Step 2: Install Apache Web Server

Apache2 is available in the openSUSE repository, so we do not have to add any additional repository. We can continue this guide and install apache2 with the zypper command:

zypper install apache2

 

After the installation will have to be started AND enabled (this is to ensure that Apache will autostart at reboot of the server)

sudo systemctl start apache2

sudo systemctl enable apache2


Now check its status

sudo systemctl status apache2

This would show both that Apache is active (running) and enabled.

 

Now create - using nano or another text editor - an index.html file in /srvr/www/htdocs/ with the following content:

<html>
<body>
<h1>It Works!</h1>
</body>
</html>

Now open your web browser and access the opensuse server ip address from it (or if you are logged on to your server use 'localhost' as address/URL):

Your browser should now show a message stating: 'It Works!'

 

Step 3: Install MariaDB

MariaDB is a relational database management system forked from the MySQL. MariaDB is developed by the original developer of MySQL (Monty Widenius) and now has released the stable version 10.1. It has the same feature set then MySQL 5.6 and 5.7.

 

In this step, we will install MariaDB and mariadb-client with zypper and then configure the MariaDB password.

Install mariadb:

sudo zypper install mariadb mariadb-client mariadb-tools

 

Now start the mariadb service and add the service to run at boot time with systemctl:

sudo systemctl start mysql

sudo systemctl enable mysql


Now check its status:

sudo systemctl status mysql

This would show both that mysql is active (running) and enabled.


Since this is a clean install the database server is still unprotected and any user would be able to logon as root with the command: mysql -u root

To restrict access we need to set a password for the MariaDB root-user. Run the following command:

sudo mysql_secure_installation

Type in your desired password when requested:

Enter current password for root (enter for none): PRESS ENTER
Set root password? [Y/n] Y
New password: TYPE YOUR PASSWORD
Re-enter new password: REPEAT PASSWORD
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] N !!!
Reload privilege tables now? [Y/n] Y

As of now you can logon to the MariaDB server with the following command:

mysql -u root -p

 

Step 4: Install PHP5 or 7

PHP is one of most popular server-side scripting languages for web development and can be embedded into HTML pages. In this tutorial, I will guide you trough the installation of PHP 5.5 and configure it to work with the apache web server and the MySQL database.

Install php and the php extensions needed for this tutorial. We have to install the php-mysql extension to allow PHP scripts to connect to MySQL. Install them with the zypper command below:

For PHP5:

sudo zypper install php5 php5-mysql apache2-mod_php5

 

Enable the php5 module in apache:

sudo a2enmod php5

OR!

For PHP7:

sudo zypper install php7 php7-mysql apache2-mod_php7

 

Enable the php5 module in apache:

sudo a2enmod php7

Now restart Apache to activate PHP:
sudo systemctl restart apache2

 

Step 5: Test the LAMP-installation

Next, to ensure that php and apache are working properly, you can test them by creating a phpinfo file in the document root directory "/srv/www/htdocs/".

Go to the directory and create a file named: info.php.

The content of this file should be:

<?php phpinfo(); ?>

 

Now open your browser and type your server ip and the path to the php info file.

http://<your server IP address>/info.php

You should see a full listing of your servers PHP information.

 

Step 6: Additional PHP modules

The following, minimum required, PHP modules that guarantee correct operation of most PHP/MySQL based CMS systems should be installed:

bz2

ctype

curl

dom

fastcgi

fileinfo

fpm

gd

gettext

iconv

intl

json

mbstring

mysql

mcrypt

opcache

openssl

pdo

pear

pear-archive_tar

phar

soap

sqlite

tokenizer

xmlreader

xmlrpc

xmlwriter

xsl

zip

zlib