Data Centers

How to install a LAMP server on openSUSE

If you want to deploy an openSUSE-based LAMP server, follow these steps to add the AMP to the L.

lamphero.jpg
Image: Jack Wallen

Your data center has most likely reached the point where Linux is a necessity, whether it's for internal systems, external services, or any number of possibilities.

One platform you might be considering is openSUSE. Not only is the operating system a solid solution for many of your data center needs, it's as flexible as any variation of Linux. Along with testing out openSUSE, you get the added bonus of becoming familiar with SUSE, should you eventually migrate to a more enterprise-ready platform.

If you want to add a LAMP server to your openSUSE installation, you're in luck—the process is not that difficult. Let's walk through setting up a LAMP server on the openSUSE Leap platform. It will take you about 20 minutes to have this incredibly powerful web server up and running.

SEE: Open source is not to blame for a lack of industry standards

What you'll need

  • A running openSUSE installation: You need to make sure everything is up to date before starting the installation process.
  • An admin account: You'll use sudo to aid in the installation.

Install Apache

Unlike some other platforms, you cannot install the LAMP server with a single command. To that end, we'll install LAMP one piece at a time. First up...Apache.

Open a terminal window and issue the command sudo zypper in apache2, which will install the Apache server. Once installed, we want to ensure the service starts and starts upon every reboot. Do this with the following two commands:

  • sudo systemctl start apache2
  • sudo systemctl enable apache2

Out of the box, Apache will be accessible from the local machine. If you want to allow other machines to access the web server, you'll need to do the following:

  1. Open the file /etc/sysconfig/SuSEfirewall2 with your favorite text editor.
  2. Add the line FW_CONFIGURATIONS_EXT="apache2"
  3. Save and close the file.
  4. Restart the firewall with the command sudo systemctl restart SuSEfirewall2

Let's test our installation. We'll create a test html file called /srv/www/htdocs/index.html with the contents:

<html>
body>

<h1>Welcome to Apache2 on openSUSE</h1>

</body>

</html>

Save that file and then point your browser to http://IP_ADDRESS_OF_SERVER (IP_ADDRESS_OF_SERVER is the actual IP address of the openSUSE server). You should see the message "Welcome to Apache2 on openSUSE" in your browser.

Install the database

We're going with MariaDB. To install that, do the following:

  1. Open your terminal window.
  2. Issue the command sudo zypper in mariadb.
  3. Once installed, start the database with the command sudo systemctl start mysql.
  4. Set the database to run at boot with the command sudo systemctl enable mysql.
  5. Set the root database password with the command sudo mysqladmin -u root password PASSWORD (where PASSWORD is the actual password you want to use).

Your database is ready.

SEE: Photo gallery: These data centers are insanely gorgeous

Install PHP

It's time to install the final piece to the puzzle...PHP. To do this, issue the following commands:

  • sudo zypper in php5 php5-mysql apache2-mod_php5
  • sudo a2enmod php5

Let's test the PHP installation. Create the file /srv/www/htdocs/testphp.php, with the content:

<?
phpphpinfo();
?>

Restart Apache with the command sudo systemctl restart apache2 and then point your browser to http://IP_OF_SERVER/testphp.php and you should see a listing of information about your PHP installation.

That's it...you're ready to use your openSUSE web server.

Make something of it

Although installing the LAMP server on openSUSE isn't quite as easy as it is on Ubuntu and its derivatives, it's not that much of a challenge. Now that you have the openSUSE LAMP server up and running, it's time for you to make something of it.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox