{"id":9139,"date":"2021-06-17T20:43:03","date_gmt":"2021-06-17T17:43:03","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9139"},"modified":"2024-03-18T20:58:28","modified_gmt":"2024-03-18T17:58:28","slug":"install-lamp-stack-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-lamp-stack-on-rocky-linux-8\/","title":{"rendered":"Install LAMP Stack on Rocky Linux 8"},"content":{"rendered":"\n
This guide describes a step by step tutorial on how to install LAMP stack on Rocky Linux 8.<\/p>\n\n\n\n
LAMP stack is a group of opensource web development softwares;<\/p>\n\n\n\n
Run system package update.<\/p>\n\n\n\n
dnf update<\/code><\/pre>\n\n\n\nInstall Rocky Linux 8 Linux System<\/h3>\n\n\n\n
In this case, the first component of the LAMP stack is our Rocky Linux 8 Linux system. To install Rocky Linux 8, see our guide on how to install it on VirtualBox by following the link below;<\/p>\n\n\n\n
Install Rocky Linux 8 on VirtualBox<\/a><\/p>\n\n\n\nInstall Apache HTTP Server on Rocky Linux 8<\/h3>\n\n\n\n
Apache http server can be installed on Rocky Linux 8 as easily as running the command below;<\/p>\n\n\n\n
dnf install httpd<\/code><\/pre>\n\n\n\nRunning Apache on Rocky Linux 8<\/h4>\n\n\n\n
Once the installation is done, you can start and enable Apache to run on system reboot by executing;<\/p>\n\n\n\n
systemctl enable --now httpd<\/code><\/pre>\n\n\n\nTo check the status;<\/p>\n\n\n\n
systemctl status httpd<\/code><\/pre>\n\n\n\n\u25cf httpd.service - The Apache HTTP Server\n Loaded: loaded (\/usr\/lib\/systemd\/system\/httpd.service; disabled; vendor preset: disabled)\n Active: active (running) since Thu 2021-06-17 19:27:04 EAT; 1s ago\n Docs: man:httpd.service(8)\n Main PID: 5969 (httpd)\n Status: \"Started, listening on: port 80\"\n Tasks: 213 (limit: 4938)\n Memory: 24.7M\n CGroup: \/system.slice\/httpd.service\n \u251c\u25005969 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u25005970 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u25005971 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u25005972 \/usr\/sbin\/httpd -DFOREGROUND\n \u2514\u25005973 \/usr\/sbin\/httpd -DFOREGROUND\n\nJun 17 19:27:04 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...\nJun 17 19:27:04 localhost.localdomain httpd[5969]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set >\nJun 17 19:27:04 localhost.localdomain systemd[1]: Started The Apache HTTP Server.\nJun 17 19:27:04 localhost.localdomain httpd[5969]: Server configured, listening on: port 80\n<\/code><\/pre>\n\n\n\nTo verify if it is enabled to run on boot, run the command below. The output should enabled<\/strong><\/code>;<\/p>\n\n\n\nsystemctl is-enabled httpd<\/code><\/pre>\n\n\n\nAllow External Access to Apache on Firewall<\/h4>\n\n\n\n
To enable external access to Apache web server, you need to allow web traffic on FirewallD. If you are serving just HTTP traffic, just open port 80\/tcp otherwise, open port 443\/tcp<\/p>\n\n\n\n
firewall-cmd --add-port=80\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\nTesting Apache on Rocky Linux 8<\/h4>\n\n\n\n
To confirm that Apache is ready to server HTTP content, simply open your browser and enter the server IP address as http:\/\/Server.IP<\/code><\/strong>. You should land on Apache HTTP server test page.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\nInstall MariaDB Database Server on Rocky Linux 8<\/h3>\n\n\n\n
The default Rocky Linux upstream repos provides MariaDB 10.3. To install the latest MariaDB on Rocky Linux, follow the link below;<\/p>\n\n\n\n
Install MariaDB 10.x on Rocky Linux 8<\/a><\/p>\n\n\n\nmysql -V<\/code><\/pre>\n\n\n\nmysql Ver 15.1 Distrib 10.5.10-MariaDB, for Linux (x86_64) using readline 5.1<\/code><\/pre>\n\n\n\nOnce you have installed MariaDB server, start and enable it to run on system boot.<\/p>\n\n\n\n
systemctl enable --now mariadb<\/code><\/pre>\n\n\n\nNext, run the security script to disable remote root login, remove test databases, remove anonymous user accounts, if not already done.<\/p>\n\n\n\n
mysql_secure_installation<\/code><\/pre>\n\n\n\nYou can login to your MariaDB server and create your databases.<\/p>\n\n\n\n
Install PHP on Rocky Linux 8<\/a><\/h3>\n\n\n\nBy default, the AppStream repos on Rocky Linux provides PHP 7.2, 7.3 and 7.4;<\/p>\n\n\n\n
dnf module list php<\/code><\/pre>\n\n\n\nRocky Linux 8 - AppStream\nName Stream Profiles Summary \nphp 7.2 [d] common [d], devel, minimal PHP scripting language \nphp 7.3 common [d], devel, minimal PHP scripting language \nphp 7.4 common [d], devel, minimal PHP scripting language\n<\/code><\/pre>\n\n\n\nInstall PHP 7.2 on Rocky Linux 8<\/h4>\n\n\n\n
The PHP 7.2 modules is enabled by default. Thus to install PHP 7.2 and MySQL PHP 7.2 module on Rocky Linux 8, run the command:<\/p>\n\n\n\n
dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\nTo install PHP 7.3 Rocky Linux 8<\/a><\/h4>\n\n\n\nEnable PHP 7.3 module on Rocky Linux 8<\/p>\n\n\n\n
dnf module enable php:7.3<\/code><\/pre>\n\n\n\nInstall PHP 7.3 Rocky Linux 8<\/p>\n\n\n\n
dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\nTo install PHP 7.4 Rocky Linux 8<\/a><\/h4>\n\n\n\ndnf module reset php<\/code><\/pre>\n\n\n\ndnf module enable php:7.4<\/code><\/pre>\n\n\n\ndnf install php php-mysqlnd<\/code><\/pre>\n\n\n\nInstall PHP 8.0 on Rocky Linux 8<\/a><\/h4>\n\n\n\nInstall PHP Remi Repository on Rocky Linux 8.<\/p>\n\n\n\n
dnf install epel-release<\/code><\/pre>\n\n\n\ndnf install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/code><\/pre>\n\n\n\nReset PHP module;<\/p>\n\n\n\n
dnf module reset php<\/code><\/pre>\n\n\n\ndnf module enable php:remi-8.0<\/code><\/pre>\n\n\n\ndnf install php php-mysqlnd<\/code><\/pre>\n\n\n\nInstall PHP Extensions on Rocky Linux 8<\/h4>\n\n\n\n
If you need to install other PHP extensions for your web applications, simply install by running;<\/p>\n\n\n\n
dnf install php-EXTENSION<\/strong><\/code><\/pre>\n\n\n\nReplacing EXTENSION<\/strong> with your respective PHP module.<\/p>\n\n\n\nTesting PHP on Rocky Linux 8<\/h4>\n\n\n\n
You can test PHP to confirm that is working as required as well check the version and installed modules using the simple PHP info script.<\/p>\n\n\n\n
cat > \/var\/www\/html\/test.php << EOL\n<?php \nphpinfo(); \n?>\nEOL<\/code><\/pre>\n\n\n\nSave the file and exit the file.<\/p>\n\n\n\n
Restart Apache<\/p>\n\n\n\n
systemctl restart httpd<\/code><\/pre>\n\n\n\nNavigate to the browser and enter the address, http:\/\/<server-IP>\/test.php<\/strong><\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\nThere you go, your LAMP stack is ready for your web development tasks.<\/p>\n\n\n\n
Be sure to remove PHP test page.<\/p>\n\n\n\n
rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\nRelated Tutorials<\/h3>\n\n\n\n
Install LAMP Stack on Ubuntu 20.04<\/a><\/p>\n\n\n\n