{"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<p>This guide describes a step by step tutorial on how to install LAMP stack on CentOS 8.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing LAMP Stack on CentOS 8<\/h2>\n\n\n\n<p>LAMP is a group of opensource web development softwares; Linux OS, <a rel=\"noreferrer noopener\" aria-label=\"Apache web server (opens in a new tab)\" href=\"https:\/\/httpd.apache.org\/\" target=\"_blank\">Apache http server<\/a>, <a rel=\"noreferrer noopener\" aria-label=\"MariaDB (opens in a new tab)\" href=\"https:\/\/mariadb.org\/\" target=\"_blank\">MariaDB<\/a>\/<a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> relational database management systems and <a rel=\"noreferrer noopener\" aria-label=\"PHP (opens in a new tab)\" href=\"https:\/\/www.php.net\/\" target=\"_blank\">PHP<\/a> web scripting language.<\/p>\n\n\n\n<p>Run system package update.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install CentOS 8 Linux System<\/h3>\n\n\n\n<p>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<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-centos-8-on-virtualbox\/\" target=\"_blank\">Install CentOS 8 on VirtualBox<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Apache HTTP Server on CentOS 8<\/h3>\n\n\n\n<p>Apache http server can be installed on CentOS 8 as easily as running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install httpd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Running Apache<\/h4>\n\n\n\n<p>Once the installation is done, you can start and enable Apache to run on system reboot by executing;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now  httpd<\/code><\/pre>\n\n\n\n<p>To check the status;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status httpd<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\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<p>To verify if it is enabled to run on boot, run the command below. The output should <code>enabled<\/code>;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl is-enabled httpd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Allow Apache Through the FirewallD<\/h4>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>firewall-cmd --add-port=80\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Testing Apache<\/h4>\n\n\n\n<p>To confirm that Apache is ready to server HTTP content, simply open your browser and enter the server IP address as <strong><code>http:\/\/Server.IP<\/code><\/strong>. You should land on Apache HTTP server test page.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/Apache-test-page.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1177\" height=\"608\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/Apache-test-page.png\" alt=\"Install LAMP Stack on CentOS 8\" class=\"wp-image-4384\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/Apache-test-page.png?v=1570472136 1177w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/Apache-test-page-768x397.png?v=1570472136 768w\" sizes=\"(max-width: 1177px) 100vw, 1177px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Install MariaDB Database Server on CentOS 8<\/h3>\n\n\n\n<p>Install MariaDB on CentOS 8 with the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install mariadb-server<\/code><\/pre>\n\n\n\n<p>This installs MariaDB 10.3.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>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<p>Want to use MariaDB 10.4 instead, follow the link below to install MariaDB 10.4 on CentOS 8.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-4-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install MariaDB 10.4 on CentOS 8<\/a><\/p>\n\n\n\n<p>You can also use MySQL 8 instead;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-mysql-8-on-centos-8\/\" target=\"_blank\">Install MySQL 8 on CentOS 8<\/a><\/p>\n\n\n\n<p>Once you have installed MariaDB server, start and enable it to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now  mariadb<\/code><\/pre>\n\n\n\n<p>Next, run the security script to disable remote root login, remove test databases, remove anonymous user accounts.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql_secure_installation<\/code><\/pre>\n\n\n\n<p>You can login to your MariaDB server and create your databases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install PHP on CentOS 8<\/h3>\n\n\n\n<p>Install PHP and MySQL PHP module on CentOS 8 by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<p>The command above installs PHP 7.2. To use PHP 7.3 instead, you need to install remi repos.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-8.noarch.rpm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/code><\/pre>\n\n\n\n<p>Reset PHP 7.2 module;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module reset php:7.2<\/code><\/pre>\n\n\n\n<p>Enable PHP 7.3 remi repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module enable php:remi-7.3<\/code><\/pre>\n\n\n\n<p>Install PHP 7.3 on CentOS 8<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>=======================================================================================================================================================\n Package                           Arch                    Version                                                 Repository                     Size\n=======================================================================================================================================================\nInstalling:\n <strong>php<\/strong>                               x86_64                  <strong>7.3.12-1.el8.remi<\/strong>                                       remi-modular                  3.0 M\n <strong>php-mysqlnd<\/strong>                       x86_64                  <strong>7.3.12-1.el8.remi<\/strong>                                       remi-modular                  252 k\n...<\/code><\/pre>\n\n\n\n<p>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<p><a href=\"https:\/\/kifarunix.com\/install-php-7-4-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install PHP 7.4 on CentOS 8<\/a><\/p>\n\n\n\n<p>If you need other PHP extensions for your web applications, simply install by running;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php-EXTENSION<\/code><\/pre>\n\n\n\n<p>Replacing EXTENSION with your respective PHP module.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Testing PHP on CentOS 8<\/h4>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>vim \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php \nphpinfo(); \n?&gt;<\/code><\/pre>\n\n\n\n<p>Save the file and exit the file.<\/p>\n\n\n\n<p>Restart Apache<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart httpd<\/code><\/pre>\n\n\n\n<p>Navigate to the browser and enter the address, <strong>http:\/\/&lt;server-IP&gt;\/test.php<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info.png\"><img loading=\"lazy\" decoding=\"async\" width=\"941\" height=\"609\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info.png\" alt=\"PHP on CentOS 8\" class=\"wp-image-4387\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info.png?v=1570475362 941w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info-768x497.png?v=1570475362 768w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/figure>\n\n\n\n<p>There you go, Your LAMP stack is installed on CentOS 8 and is ready for your web development tasks.<\/p>\n\n\n\n<p>Be sure to remove PHP test page.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-fedora-30\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install LAMP Stack on Fedora 30<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-lamp-linux-apache-mysql-php-stack-on-fedora-28-29\/\" target=\"_blank\">How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28\/29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-lamp-stack-with-mariadb-10-on-debian-10-buster\/\" target=\"_blank\">Install LAMP Stack with MariaDB 10 on Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-debian-9\/\" target=\"_blank\">Install LAMP Stack on Debian 9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide describes a step by step tutorial on how to install LAMP stack on CentOS 8. Installing LAMP Stack on CentOS 8 LAMP is<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,254,201,342],"tags":[202,1142,204,136,203,1237],"class_list":["post-4374","post","type-post","status-publish","format-standard","hentry","category-howtos","category-apache","category-lamp-stack","category-php","tag-apache","tag-centos-8","tag-lamp-stack","tag-mariadb","tag-php","tag-php-7-3-centos-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4374"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=4374"}],"version-history":[{"count":8,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4374\/revisions"}],"predecessor-version":[{"id":21232,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4374\/revisions\/21232"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}