The LAMP server is the foundation of Linux web hosting. If you're looking to set up a LAMP stack to host your website, this guide will provide you with the necessary information on how to get start with LAMP on RHEL 8 Linux server.

In this tutorial you will learn:
  • How to install all LAMP prerequisite packages on RHEL 8.
  • How to secure MariaDB database.
  • How to start httpd and MariaDB services.
  • How to open HTTP and HTTPS firewall ports.
LAMP stack server installation on Red Hat Enterprise Linux 8
LAMP stack server installation on Red Hat Enterprise Linux 8.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Red Hat Enterprise Linux 8
Software MariaDB Server 10.3.10, PHP 7.2.11-1, Apache/2.4.35 (Red Hat Enterprise Linux)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to install LAMP Server on RHEL 8 Linux step by step instructions


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  1. Install all prerequisites.

    The following command will install all prerequisites and tools required to perform the LAMP installation:
    # dnf install php-mysqlnd php-fpm mariadb-server httpd
    
  2. Open HTTP and optionally HTTPS port 80 and 443 on your firewall:
    # firewall-cmd --permanent --zone=public --add-service=http 
    # firewall-cmd --permanent --zone=public --add-service=https
    # firewall-cmd --reload
    
  3. Start both Apache webserver and MariaDB services:
    # systemctl start mariadb
    # systemctl start httpd
    
    Enable MariaDB and httpd to start after system reboot:
    # systemctl enable mariadb
    # systemctl enable httpd
    
  4. Secure your MariaDB installation and set root password:
    # mysql_secure_installation
    
  5. Confirm the LAMP server installation. Create a file called info.php within the /var/www/html/ directory with the following content:

    <?php phpinfo(); ?>
    
  6. change permissions and change file SELinux security context:
    # chown -R apache:apache /var/www/html/*
    # chcon -t httpd_sys_rw_content_t /var/www/html/ -R
    
  7. Navigate your browser to the http://localhost/info.php URL and confirm the LAMP installation.


  8. Install additional PHP modules. So far we have just installed a bare bones LAMP stack. Depending on the application you are going to use you might also need to install additional PHP modules. The following command might provide you with some hints:
    # dnf search php-
    
    php-gd.x86_64 : A module for PHP applications for using the gd graphics library
    php-fpm.x86_64 : PHP FastCGI Process Manager
    php-pdo.x86_64 : A database access abstraction module for PHP applications
    php-gmp.x86_64 : A module for PHP applications for using the GNU MP library
    php-dbg.x86_64 : The interactive PHP debugger
    php-pdo.x86_64 : A database access abstraction module for PHP applications
    php-xml.x86_64 : A module for PHP applications which use XML
    php-fpm.x86_64 : PHP FastCGI Process Manager
    php-cli.x86_64 : Command-line interface for PHP
    php-dba.x86_64 : A database abstraction layer module for PHP applications
    php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
    php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
    php-ldap.x86_64 : A module for PHP applications that use LDAP
    php-pear.noarch : PHP Extension and Application Repository framework
    php-intl.x86_64 : Internationalization extension for PHP applications
    php-json.x86_64 : JavaScript Object Notation extension for PHP
    php-odbc.x86_64 : A module for PHP applications that use ODBC databases
    php-devel.x86_64 : Files needed for building PHP extensions
    php-pgsql.x86_64 : A PostgreSQL database module for PHP
    php-common.x86_64 : Common files for PHP
    php-common.x86_64 : Common files for PHP
    php-recode.x86_64 : A module for PHP applications for using the recode library
    php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
    php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
    php-enchant.x86_64 : Enchant spelling extension for PHP applications
    php-process.x86_64 : Modules for PHP script using system process interfaces
    php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
    php-opcache.x86_64 : The Zend OPcache
    php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
    php-pecl-zip.x86_64 : A ZIP archive management extension
    php-embedded.x86_64 : PHP library for embedding in applications
    php-pecl-apcu.x86_64 : APC User Cache
    php-pecl-apcu-devel.x86_64 : APCu developer files (header)
    
    To install an additional package execute:
    # dnf install PACKAGENAME
    
    Once the package is installed reload the httpd service:
    # systemctl reload httpd
    
  9. All done.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.