HomeLinuxTips on how to Set up LAMP Stack on RHEL, CentOS, Rocky...

Tips on how to Set up LAMP Stack on RHEL, CentOS, Rocky & AlmaLinux


A LAMP stack is a set of 4 totally different software program (Linux, Apache, MySQL, and PHP) that programmers or internet builders use to create and deploy web sites or purposes.

This tutorial will think about the way to set up and configure the well-known LAMP stack with PhpMyAdmin on the final launch of RHEL and RHEL-based distributions comparable to CentOS, Oracle Linux, Rocky, and AlmaLinux.

Necessities

Relying on the used distribution, use the next hyperlinks to carry out a minimal system set up, utilizing a static IP Deal with for community configuration.

Step 1: Set up Apache Internet Server

1. After performing a minimal system set up and configuring your server community interface with a Static IP Deal with, go forward and set up Apache (httpd) service binary package deal supplied from official repositories utilizing the next yum command.

# yum set up httpd
Install Apache in Linux
Set up Apache on Linux

2. After ending the Apache set up, use the next instructions to handle Apache daemon since RHEL and CentOS each migrated their init scripts from SysV to SystemdWhy was init Changed with Systemd in Linux?.

# systemctl begin httpd
# systemctl allow httpd
# systemctl standing httpd
Manage Apache in Linux
Handle Apache in Linux

3. On the subsequent step, make sure that to permit entry to Apache by opening ports 80 and 443 on Firewall utilizing firewall-cmd, which is the default command to handle Firewalld by daemon.

# firewall-cmd --add-service=http
# firewall-cmd --add-service=https
# systemctl restart firewalld

NOTE: Make discover that utilizing this rule will lose its impact after a system reboot or firewalld service restart as a result of it opens on-fly guidelines, which aren’t utilized completely.

To use consistency iptables guidelines on the firewall utilizing the --permanent possibility and restart the firewalld service to take impact.

# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# systemctl restart firewalld
Open Apache Ports in Firewalld
Open Apache Ports in Firewalld

Some necessary Firewalld instructions to handle the firewall as introduced beneath:

# firewall-cmd --state
# firewall-cmd --list-all
# firewall-cmd --list-interfaces
# firewall-cmd --get-service
# firewall-cmd --query-service service_name
# firewall-cmd --add-port=80/tcp

4. To confirm Apache performance open a distant browser and sort your server IP Deal with utilizing HTTP protocol on the URL, and a default web page ought to seem like within the screenshot beneath.

http://server_IP
Verify Apache in Linux
Confirm Apache in Linux

5. For now, the Apache DocumentRoot path it’s set to /var/www/html system path, which by default doesn’t present any index file. If you wish to see a listing listing of your DocumentRoot path.

Open the Apache welcome configuration file and set the Indexes assertion from to + on LocationMatch directive, utilizing the beneath screenshot for example.

# vi /and so forth/httpd/conf.d/welcome.conf
Configure Apache Welcome Page
Configure Apache Welcome Web page

6. After making adjustments, shut the file, restart the Apache service to replicate adjustments, and reload your browser web page to see the ultimate end result.

# systemctl restart httpd
Apache Directory Listing
Apache Listing Itemizing

Step 2: Set up PHP Help for Apache

7. Earlier than putting in PHP dynamic language help for Apache, get a full listing of obtainable PHP modules and extensions utilizing the next command.

# yum search php
List PHP Modules
Checklist PHP Modules

8. Relying on what sort of purposes you need to use, set up the required PHP modules from the above listing, however for a fundamental MySQL/MariaDB help in PHP and PhpMyAdmin it is advisable to set up the next modules.

# yum set up php php-mysql php-pdo php-gd php-mbstring
Install PHP Modules
Set up PHP Modules

9. To get a full data listing on PHP out of your browser, create an information.php file on Apache Doc Root utilizing the next command, restart the httpd service, and direct your browser to the http://server_IP/information.php handle.

# echo "<?php phpinfo(); ?>" > /var/www/html/information.php
# systemctl restart httpd
List PHP Information
Checklist PHP Data

10. In case you get an error on PHP Date and Timezone, open the php.ini configuration file, search, and uncomment date.timezone assertion, append your bodily location, and restart the Apache daemon.

# vi /and so forth/php.ini

Find and alter date.timezone line to appear like this, utilizing PHP Supported Timezones listing.

date.timezone = Continent/Metropolis
Set PHP Timezone
Set PHP Timezone

Step 3: Set up and Configure MariaDB Database

11. The RHEL distribution switched from MySQL to MariaDB for its default database administration system. To put in the MariaDB database use the next command.

# yum set up mariadb-server mariadb
Install MariaDB in Linux
Set up MariaDB on Linux

12. After the MariaDB package deal is put in, begin the database daemon and use the mysql_secure_installation script to safe the database (set a root password, disable distant login from the foundation, take away the take a look at database, and take away nameless customers).

# systemctl begin mariadb
# systemctl allow mariadb
# systemctl standing mariadb
# mysql_secure_installation
Manage MariaDB Service
Handle MariaDB Service
Secure MariaDB in Linux
Safe MariaDB in Linux

13. To check database performance login to MariaDB utilizing its root account and exit utilizing a stop assertion.

mysql -u root -p
MariaDB > present databases;
MariaDB > stop
Connect MariaDB in Linux
Join MariaDB to Linux

Step 4: Set up PhpMyAdmin to Handle MySQL

14. By default official repositories don’t present any binary package deal for PhpMyAdmin Internet Interface. In case you are uncomfortable utilizing the MySQL command line to handle your database you may set up the PhpMyAdmin package deal by enabling the remi repository utilizing the next command.

# yum set up -y https://rpms.remirepo.internet/enterprise/remi-release-9.rpm  [On CentOS/RHEL 8]
# yum set up -y https://rpms.remirepo.internet/enterprise/remi-release-8.rpm  [On CentOS/RHEL 8]
# yum set up -y https://rpms.remirepo.internet/enterprise/remi-release-7.rpm  [On CentOS/RHEL 7]

After enabling the remi repository, subsequent set up PhpMyAdmin.

# yum set up phpmyadmin
Install PhpMyAdmin in Linux
Set up PhpMyAdmin on Linux

15. Subsequent configure PhpMyAdmin to permit connections from distant hosts by enhancing phpmyadmin.conf file, situated on the Apache conf.d listing, commenting on the next strains.

# vi /and so forth/httpd/conf.d/phpMyAdmin.conf

Add the “Require all granted” line below the “Require native” line as proven.

<Listing /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8
   Require native
   Require all granted
</Listing>
Allow Remote PhpMyAdmin Access
Enable Distant PhpMyAdmin Entry

16. To have the ability to log in to the PhpMyAdmin Internet interface, restart the Apache Internet service and direct your browser to the URL handle.

# systemctl restart httpd

http://server_IP/phpmyadmin/
PhpMyAdmin Dashboard
PhpMyAdmin Dashboard

Step 5: Allow LAMP System-Broad in Linux

17. In case you want MariaDB and Apache companies to be mechanically began after reboot situation the next instructions to allow them system-wide.

# systemctl allow mariadb
# systemctl allow httpd

That’s all it takes for a fundamental LAMP set up on RHEL-based distributions. The following sequence of articles associated to the LAMP stack will talk about the way to create Digital Hosts, generate SSL Certificates and Keys, and add SSL transaction help for Apache HTTP Server.

If You Admire What We Do Right here On TecMint, You Ought to Contemplate:

TecMint is the quickest rising and most trusted group web site for any form of Linux Articles, Guides and Books on the internet. Thousands and thousands of individuals go to TecMint! to look or browse the hundreds of printed articles accessible FREELY to all.

In case you like what you’re studying, please take into account shopping for us a espresso ( or 2 ) as a token of appreciation.

Support Us

We’re grateful in your by no means ending help.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments