{"id":4374,"date":"2019-10-07T22:19:35","date_gmt":"2019-10-07T19:19:35","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4374"},"modified":"2024-03-12T22:25:53","modified_gmt":"2024-03-12T19:25:53","slug":"install-lamp-stack-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-lamp-stack-on-centos-8\/","title":{"rendered":"Install LAMP Stack on CentOS 8"},"content":{"rendered":"\n
This guide describes a step by step tutorial on how to install LAMP stack on CentOS 8.<\/p>\n\n\n\n
LAMP is a group of opensource web development softwares; Linux OS, Apache http server<\/a>, MariaDB<\/a>\/MySQL<\/a> relational database management systems and PHP<\/a> web scripting language.<\/p>\n\n\n\n Run system package update.<\/p>\n\n\n\n In this case, the first component of the LAMP stack is our CentOS 8 Linux system. To install CentOS 8, see our guide on how to install it on VirtualBox by following the link below;<\/p>\n\n\n\n Install CentOS 8 on VirtualBox<\/a><\/p>\n\n\n\n Apache http server can be installed on CentOS 8 as easily as running the command below;<\/p>\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 To check the status;<\/p>\n\n\n\n To verify if it is enabled to run on boot, run the command below. The output should 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 To confirm that Apache is ready to server HTTP content, simply open your browser and enter the server IP address as Install MariaDB on CentOS 8 with the command;<\/p>\n\n\n\n This installs MariaDB 10.3.<\/p>\n\n\n\n Want to use MariaDB 10.4 instead, follow the link below to install MariaDB 10.4 on CentOS 8.<\/p>\n\n\n\n Install MariaDB 10.4 on CentOS 8<\/a><\/p>\n\n\n\n You can also use MySQL 8 instead;<\/p>\n\n\n\n Install MySQL 8 on CentOS 8<\/a><\/p>\n\n\n\n Once you have installed MariaDB server, start and enable it to run on system boot.<\/p>\n\n\n\n Next, run the security script to disable remote root login, remove test databases, remove anonymous user accounts.<\/p>\n\n\n\n You can login to your MariaDB server and create your databases.<\/p>\n\n\n\n Install PHP and MySQL PHP module on CentOS 8 by running the command;<\/p>\n\n\n\n The command above installs PHP 7.2. To use PHP 7.3 instead, you need to install remi repos.<\/p>\n\n\n\n Reset PHP 7.2 module;<\/p>\n\n\n\n Enable PHP 7.3 remi repository.<\/p>\n\n\n\n Install PHP 7.3 on CentOS 8<\/p>\n\n\n\n Want to use PHP 7.4? See the link below on how to install PHP 7.4 on CentOS 8.<\/p>\n\n\n\n Install PHP 7.4 on CentOS 8<\/a><\/p>\n\n\n\n If you need other PHP extensions for your web applications, simply install by running;<\/p>\n\n\n\n Replacing EXTENSION with your respective PHP module.<\/p>\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 Save the file and exit the file.<\/p>\n\n\n\n Restart Apache<\/p>\n\n\n\n Navigate to the browser and enter the address, http:\/\/<server-IP>\/test.php<\/strong><\/p>\n\n\n\n There you go, Your LAMP stack is installed on CentOS 8 and is ready for your web development tasks.<\/p>\n\n\n\n Be sure to remove PHP test page.<\/p>\n\n\n\n Install LAMP Stack on Fedora 30<\/a><\/p>\n\n\n\n How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28\/29<\/a><\/p>\n\n\n\n Install LAMP Stack with MariaDB 10 on Debian 10 Buster<\/a><\/p>\n\n\n\ndnf update<\/code><\/pre>\n\n\n\n
Install CentOS 8 Linux System<\/h3>\n\n\n\n
Install Apache HTTP Server on CentOS 8<\/h3>\n\n\n\n
dnf install httpd<\/code><\/pre>\n\n\n\n
Running Apache<\/h4>\n\n\n\n
systemctl enable --now httpd<\/code><\/pre>\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; enabled; vendor preset: disabled)\n Active: active (running) since Mon 2019-10-07 13:59:33 EDT; 42s ago\n Docs: man:httpd.service(8)\n Main PID: 26699 (httpd)\n Status: \"Running, listening on: port 80\"\n Tasks: 213 (limit: 11512)\n Memory: 24.8M\n CGroup: \/system.slice\/httpd.service\n \u251c\u250026699 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u250026700 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u250026701 \/usr\/sbin\/httpd -DFOREGROUND\n \u251c\u250026702 \/usr\/sbin\/httpd -DFOREGROUND\n \u2514\u250026703 \/usr\/sbin\/httpd -DFOREGROUND\n...<\/code><\/pre>\n\n\n\n
enabled<\/code>;<\/p>\n\n\n\n
systemctl is-enabled httpd<\/code><\/pre>\n\n\n\n
Allow Apache Through the FirewallD<\/h4>\n\n\n\n
firewall-cmd --add-port=80\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n
Testing Apache<\/h4>\n\n\n\n
http:\/\/Server.IP<\/code><\/strong>. You should land on Apache HTTP server test page.<\/p>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Install MariaDB Database Server on CentOS 8<\/h3>\n\n\n\n
dnf install mariadb-server<\/code><\/pre>\n\n\n\n
mysql -V\nmysql Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1<\/code><\/pre>\n\n\n\n
systemctl enable --now mariadb<\/code><\/pre>\n\n\n\n
mysql_secure_installation<\/code><\/pre>\n\n\n\n
Install PHP on CentOS 8<\/h3>\n\n\n\n
dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n
dnf install https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-8.noarch.rpm<\/code><\/pre>\n\n\n\n
dnf install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/code><\/pre>\n\n\n\n
dnf module reset php:7.2<\/code><\/pre>\n\n\n\n
dnf module enable php:remi-7.3<\/code><\/pre>\n\n\n\n
dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n
=======================================================================================================================================================\n Package Arch Version Repository Size\n=======================================================================================================================================================\nInstalling:\n php<\/strong> x86_64 7.3.12-1.el8.remi<\/strong> remi-modular 3.0 M\n php-mysqlnd<\/strong> x86_64 7.3.12-1.el8.remi<\/strong> remi-modular 252 k\n...<\/code><\/pre>\n\n\n\n
dnf install php-EXTENSION<\/code><\/pre>\n\n\n\n
Testing PHP on CentOS 8<\/h4>\n\n\n\n
vim \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n
<?php \nphpinfo(); \n?><\/code><\/pre>\n\n\n\n
systemctl restart httpd<\/code><\/pre>\n\n\n\n
<\/a><\/figure>\n\n\n\n
rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n