Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to set up a LAMP stack quickly on Red Hat Enterprise Linux 8 Beta

March 14, 2019
Maxim Burgerhout
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

    Have you tried the Red Hat Enterprise Linux 8 (RHEL8) Beta yet? Read on to learn how to stand up a LAMP stack on top of RHEL8 Beta quickly, and play around with new features built into the operating system.

    A LAMP stack is made up out of four main components, and some glue. The first main component in a LAMP stack is Linux. In my example, I’m using Red Hat Enterprise Linux 8 Beta for that, which gives me a secure operating system, a modern programming environment, and user-friendly set of tools to control it.

    As for the web server, traditionally the “A” in LAMP stood for Apache, but in RHEL8 Beta we actually have options here. We ship Apache httpd with RHEL8 Beta, but we also ship NGINX. Because I’m a little bit traditional here, I’ll opt for Apache.

    In RHEL8 Beta, Apache ships as an AppStream, which, among other things, allow us to provide content with varying life cycles. With AppStreams, we can, for example, ship multiple versions of Python, and add new versions of programming environments outside of the normal RHEL release cadence.

    Installing Apache on RHEL8 as easy as it was on earlier versions of RHEL. Run:

    $ sudo yum -y install httpd

    (You are using sudo, right? If you didn't set your user ID to be an Administrator during installation, see How to enable sudo on Red Hat Enterprise Linux.)

    This command will enable the Apache 2.4 AppStream and install the httpd package, including its default dependencies.

    To start this newly installed web server and make sure it will automatically be started after a reboot, I’ll need to run:

    $ sudo systemctl enable --now httpd

    And, as I’ll want my server to be reachable over the network, I’ll need to open up ports 80 and 443 on my system. We can do that from the Web Console in RHEL8 (see the DevNation video at the end of this article for a demo), but for now, let’s just use the command-line tools provided with RHEL8 Beta. They are quite easy:

    $ sudo firewall-cmd --add-service=http --add-service=https
    $ sudo firewall-cmd --add-service=http --add-service=https --permanent

    That’s it. The first command opened up ports 80 and 443 right now, and the second command made sure that after a reboot or firewall restart, the ports will still be open.

    Now for the database part. Again, traditionally, the “M” in LAMP stood for MySQL; however, nowadays, it can also mean MariaDB, MongoDB, or even PostgreSQL. You can see what databases RHEL8 Beta ships with by running:

    sudo yum module list

    (I’ve stripped the non-database AppStreams from the output for brevity.)

    As you can see, MongoDB is not an option for RHEL8 Beta. You can read the RHEL8 Beta release notes for a little background on why that is. What we do have, though, is MySQL 8, MariaDB 10.3, PostgreSQL 9.6 and 10, and Redis 4 and 5. That’s a lot to choose from! (Do not assume the final product will ship with all of these versions, however. After all, we are looking at beta software.)

    I want to build a fairly traditional LAMP stack here, so I’ll opt for MariaDB, which is a drop-in replacement for MySQL. I want to install a database server, so the default profile (‘server’, indicated by the [d] in the output above) will work for me. If I have only wanted the client bits, I could have installed the client profile, saving me a bit of disk space.

    For now, however, I’ll run:

    $ sudo yum -y module install mariadb

    By the way, a standard yum -y install mariadb-server will work just as well.

    A database that’s not running is of little use, so let’s start it with:

    $ sudo systemctl enable --now mariadb

    I don’t need to open firewall ports, because my web server and database server run on the same machine. If you have separate machines for Apache and MariaDB, though, you’ll need to add the MySQL service to the firewall, using the firewall-cmd command I showed above. You’ll also need to tune the SELinux policy to allow Apache to make network connections to a database (safety first!), by running:

    $ sudo setsebool -P httpd_can_network_connect_db on

    Finally, because I have taken my lessons around security to heart, I’ll run the mysql_secure_installation script:

    $ sudo mysql_secure_installation

    We are almost there. I have a proper Linux machine, I have my web server, and I have my database server. What’s still missing is a programming environment, and some glue. Let’s see, what programming environments do I have available?

    $ sudo yum module list

    I’ll not show the whole output again here, but we have PHP, we have Python in two major versions, we have Ruby, and a plethora of other options. Traditional LAMP means PHP for me though, so that’s what I’ll be installing today. One simple command should that care of it:

    $ sudo yum -y module install php

    Two final steps remain. First of all, some glue. In order to enable connecting to the MariaDB database from my PHP pages, I need to install a tiny library:

    $ sudo yum -y install php-mysqlnd

    Now, as the final step, I’ll restart Apache to pick up my newly installed PHP and the PHP MySQL library:

    $ sudo systemctl restart httpd

    That’s it, we are done. We can go into /var/www/html and drop a PHP application in it and everything should work.

    A few weeks back, Burr Sutter hosted me on DevNation Live, and we recorded an overview of RHEL8 Beta from a developer point of view. We covered installing and using programming environments, managing your development systems, and much more. Interested? Watch the video:

     

    https://www.youtube.com/watch?v=4DiLdgtcavo

    I hope this is helpful. Let me know what you think in the comments or on Twitter: @MaximBurgerhout

     

    Last updated: May 30, 2022

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.