Linux Tutorials

How To Set up Linux, Apache, MySQL, PHP (LAMP) stack On RHEL eight

SEOClerks

How do I arrange a LAMP stack on RHEL eight cloud server or VPS or naked steel server? How can I set up Linux, Apache, MySQL/MariaDB, PHP (LAMP) stack On RHEL (Pink Hat Enterprise Linux) eight?

Introduction – A LAMP stack is nothing however a bunch of in style software program put in to construct and run dynamic web sites and apps. Typical examples of LAMP contains WordPress primarily based weblog, Wiki coded in Mediawiki, or customized made e-commerce web site. LAMP is an acronym for the: Linux OSApache net serverMySQL or MariaDB server to retailer dataPHP for a server-side dynamic net era programming language

This web page exhibits methods to set up and arrange a LAMP stack on RHEL eight utilizing the CLI.

You should utilize both yum command or dnf command to put in packages on RHEL eight. The yum is nothing however a delicate hyperlink to dnf for backward compatibility causes.

The way to arrange and set up Linux, Apache, MySQL, PHP (LAMP) stack On RHEL eight

The process to arrange a LAMP stack on a Pink Hat Enterprise Linux:

Replace your system by working sudo dnf replaceSet up Apache HTTPD in RHEL eight: sudo dnf set up httpdArrange MariaDB (MySQL clone) on RHEL eight sudo dnf set up mariadb-serverLastly set up PHP 7.x to finish a LAMP arrange on RHEL eight, run sudo dnf set up @phpTake a look at your LAMP setup

Allow us to see all instructions in particulars.

Step 1 – Replace RHEL eight field

Merely run the next dnf command:
$ sudo dnf replace

Step 2 – Set up Apache (HTTPD) on RHEL eight

Once more use the dnf command:
$ sudo dnf set up httpd
How to install HTTPD on RHEL 8Putting in httpd on RHEL eight

The way to allow httpd service

he httpd.service disabled by default. To begin the httpd service at boot time, run the next systemctl command:
sudo systemctl allow httpd.service
Within the default configuration, the httpd daemon will settle for connections on port 80 (and, if mod_ssl is put in, TLS connections on port 443) for any configured IPv4 or IPv6 tackle.

Command to begin/cease/restart httpd

sudo systemctl begin httpd.service ## <- Begin Apache ##
sudo systemctl cease httpd.service ## <- Cease Apache ##
sudo systemctl restart httpd.service ## <- Restart Apache ##
sudo systemctl reload httpd.service ## <- Reload Apache ##
sudo systemctl standing httpd.service ## <- Get standing of Apache ##
Confirm that port 80 open by working the ss command together with grep command:
$ sudo ss -tulpn
$ sudo ss -tulpn | grep :80
How to enable and start HTTPD service on RHEL 8httpd.service is systemd unit recordsdata that controls Apache on RHEL eight

The way to open port 80 utilizing firewalld

By default firewalld on RHEL eight would block entry to HTTP TCP port # 80.To open HTTP port 80 on a RHEL eight, run:
$ sudo firewall-cmd –permanent –add-service=http –zone=public
$ sudo firewall-cmd –reload
$ sudo firewall-cmd –list-services –zone=public
How to open Apache port 80 using firewalld command on RHEL 8Open Apache TCP port # 80 utilizing the firewalld command

Take a look at it

Use the ip command to search out out your public IP tackle on a RHEL eight:
ip a
ip a s ens3
ip a s eth0
ip a s ens3 | grep -w inet | awk ”
Hearth an online browser and sort url:
http://your-server-ip-here/
OR use FQDN:
http://rhel8.cyberciti.biz/
The default RHEL 8 Apache web pageThe default RHEL eight Apache net web page signifies that our Apache set up accomplished

Our Apache is working. It’s time to set up MariaDB which acts as a drop alternative for Oracle MySQL server. Kind the next dnf command:
$ sudo dnf set up mariadb-server
Installing MariaDB on RHEL 8 using the dnf/yum commandPutting in MariaDB on RHEL eight utilizing the dnf/yum command

Allow and begin/cease/restart MariaDB service

Activate MariDB server at boot time, run:
$ sudo systemctl allow mariadb.service
To cease/cease/restart MariDB service use the next systemctl command:
sudo systemctl begin mariadb.service ## <- Begin MariaDB server ##
sudo systemctl cease mariadb.service ## <- STOP MariaDB server ##
sudo systemctl restart mariadb.service ## <- RESTART MariaDB server ##
sudo systemctl standing mariadb.service ## <- Get standing of MariaDB server ##
Lastly safe you MariaDB server, run:
$ sudo mysql_secure_installation
Securing MariaDB server on RHEL 8Securing MariaDB server on RHEL eight

Step four – Set up PHP 7.x on RHEL eight

Now your Apache server and database methods are up and working. It’s time to set up the ultimate piece of the puzzle. Kind the next dnf command to put in PHP 7.2 together with in style PHP modules to entry MySQL from PHP, graphics and extra:
$ sudo dnf set up php php-mysqlnd php-mbstring php-opcache php-gd
How to install PHP 7.2 on RHEL 8Putting in PHP 7.2 and modules on RHEL eight
You need to restart httpd service to entry PHP:
$ sudo systemctl restart httpd.service

A observe about looking and putting in further PHP modules

PHP comes with many modules. You might want to set up them as per your wants. You may seek for modules utilizing the next syntax:
$ sudo dnf search php-
$ sudo dnf search php- | grep -i mysql
Discover information about php-mbstring, run
$ dnf information
$ sudo dnf information php-mbstring
Set up php-mbstring, run:
$ sudo dnf set up php-mbstring

Take a look at your PHP set up

Create a file named check.php in /var/www/html/ listing:
$ sudo vi /var/www/html/check.php
Append the next php code:

Save and shut the file. Take a look at your PHP. Hearth an online browser and sort url:
The tackle you need to go to will probably be:
http://your-server-ip-here/check.php
OR
http://rhel8.cyberciti.biz/check.php
Testing PHP 7.2 on RHEL 8 LAMP setup
If you happen to see the output as above, then your PHP is put in and dealing accurately. You may delete the file utilizing rm command:
$ sudo rm /var/www/html/check.php

How do I safe PHP?

See my “Linux: 25 PHP Safety Greatest Practices For Sys Admins” for more information.

The way to see log recordsdata for my Apache server

Use the cat command/tail command as follows to Apache/httpd logs on RHEL eight:
ls -l /var/log/httpd/
sudo tail -f /var/log/httpd/access_log
sudo grep ‘foo’ /var/log/httpd/error_log

How do I configure HTTPD additional?

All Apache configuration recordsdata are as follows:

/and so on/httpd/ – Foremost Apache config listing/and so on/httpd/conf/httpd.conf – Foremost Aapache config file. You may edit this file working sudo vi /and so on/httpd/conf/httpd.conf command/var/log/httpd/ – Apache error and entry log recordsdata/and so on/httpd/conf.modules.d – Apache modules (resembling proxy, php and extra) config listing

Conclusion

That’s all for now. You efficiently arrange a LAMP server on RHEL eight. Subsequent time you’ll study securing Apache server utilizing TLS/SSL. For Apache config see this web page.

Posted by: Vivek Gite

The writer is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a coach for the Linux working system/Unix shell scripting. Get the newest tutorials on SysAdmin, Linux/Unix and open supply matters by way of RSS/XML feed or weekly e-mail publication.

Source link

Related Articles

Back to top button