{"id":5198,"date":"2021-03-18T10:22:21","date_gmt":"2021-03-18T10:22:21","guid":{"rendered":"https:\/\/linuxways.net\/?p=5198"},"modified":"2021-03-18T10:22:21","modified_gmt":"2021-03-18T10:22:21","slug":"install-lamp-stack-on-red-hat-enterprise-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/install-lamp-stack-on-red-hat-enterprise-linux-8\/","title":{"rendered":"Install LAMP Stack on Red Hat Enterprise Linux 8"},"content":{"rendered":"<p>The LAMP stack is a set of open-source tools used in web development. LAMP represents Linux, Apache HTTP Server, MySQL\/MariaDB, and PHP.<\/p>\n<p>This guide will show you how you can install the LAMP stack on Red Hat Enterprise Linux (RHEL) 8.<\/p>\n<h2>Prerequisite<\/h2>\n<p>In order to follow along, you would require a user with sudo privileges on RHEL 8. This takes care of the first component of the LAMP stack, i.e., Linux.<\/p>\n<h2>Install Apache HTTP Server<\/h2>\n<p>The <a href=\"https:\/\/www.apache.org\">Apache HTTP Server<\/a> is one of the oldest and most popular web servers. It is available as <strong>httpd<\/strong> on RHEL 8. Firstly, run the command below to check for package updates.<\/p>\n<pre>$ sudo dnf update<\/pre>\n<p>Next, install the Apache HTTP server on RHEL 8 as follows.<\/p>\n<pre>$ sudo dnf install httpd<\/pre>\n<p>You would be prompted to enter <strong>y<\/strong> to continue with the installation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"747\" height=\"451\" class=\"wp-image-5199\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-276.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-276.png 747w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-276-300x181.png 300w\" sizes=\"auto, (max-width: 747px) 100vw, 747px\" \/><\/p>\n<p>Once <strong>httpd<\/strong> is successfully installed, check the status with the command below.<\/p>\n<pre>$ sudo systemctl status httpd<\/pre>\n<p>Press <strong>q<\/strong> to return to the command prompt.<\/p>\n<p>If the status of httpd is inactive, then start the service with the next command.<\/p>\n<pre>$ sudo systemctl start httpd<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"307\" class=\"wp-image-5200\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-277.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-277.png 749w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-277-300x123.png 300w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/p>\n<p>Once you see that the <strong>Apache HTTP Server<\/strong> is active, you may open a web browser and enter the IP address of your RHEL 8 server. Or simply enter <strong>localhost<\/strong> if you are directly connected to the server.<\/p>\n<p>You should see the <strong>Red Hat Enterprise Linux Test Page <\/strong>as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"715\" height=\"531\" class=\"wp-image-5201\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-278.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-278.png 715w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-278-300x223.png 300w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<p>To configure the Apache HTTP Server to automatically start when the system boots, run the command below.<\/p>\n<pre>$ sudo systemctl enable httpd<\/pre>\n<p>This takes care of the second component of the LAMP stack, i.e., Apache.<\/p>\n<h2>Install MariaDB<\/h2>\n<p><a href=\"https:\/\/mariadb.org\">MariaDB<\/a> is a free and open-source relational database management system. MariaDB was derived from MySQL after MySQL was acquired by Oracle Inc.<\/p>\n<p>To install MariaDB on RHEL 8, run the command below.<\/p>\n<pre>$ sudo dnf install mariadb-server -y<\/pre>\n<p>After MariaDB is successfully installed, check the status of the service with:<\/p>\n<pre>$ sudo systemctl status mariadb<\/pre>\n<p>Press <strong>q<\/strong> to return to the command prompt.<\/p>\n<p>If MariaDB is not active, start the service with the next command.<\/p>\n<pre>$ sudo systemctl start mariadb<\/pre>\n<p>Check the status again to confirm that MariaDB is now active.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"277\" class=\"wp-image-5202\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-279.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-279.png 741w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-279-300x112.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/p>\n<p>Run the next command to configure MariaDB to automatically start when the system boots.<\/p>\n<pre>$ sudo systemctl enable mariadb<\/pre>\n<p>Next, run the following to execute a built-in script for securing MariaDB.<\/p>\n<pre>$ mysql_secure_installation<\/pre>\n<p>You would be prompted to take a series of actions. Please read the instructions carefully while you follow the prompts.<\/p>\n<p>In summary, you would be asked to:<\/p>\n<ol>\n<li>Enter current password for root. This is blank on a new installation of MariaDB. So just hit the enter key<\/li>\n<li>Set root password<\/li>\n<li>Remove anonymous users<\/li>\n<li>Disallow root login remotely<\/li>\n<li>Remove test database and access to it<\/li>\n<li>Reload privilege tables to save changes<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"625\" height=\"705\" class=\"wp-image-5203\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-280.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-280.png 625w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-280-266x300.png 266w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Once you are done securing MariaDB, login as follows.<\/p>\n<pre>$ sudo mysql -u root -p<\/pre>\n<p>You should see the<strong> MariaDB<\/strong> prompt which confirms that the third component of the LAMP stack is working okay.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"195\" class=\"wp-image-5204\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-281.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-281.png 667w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-281-300x88.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/p>\n<p>Enter <strong>quit<\/strong> to exit MariaDB.<\/p>\n<h2>Install PHP<\/h2>\n<p>PHP (i.e., Hypertext Preprocessor) is a server-side scripting language for creating dynamic web pages and apps. PHP interacts with databases and dynamically generates content based on client requests.<\/p>\n<p>Run the command below to install PHP and related modules on RHEL 8.<\/p>\n<pre>$ sudo dnf install php -y<\/pre>\n<p>After installation, check the version of PHP with:<\/p>\n<pre>$ php -v<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"83\" class=\"wp-image-5205\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-282.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-282.png 599w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-282-300x42.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/p>\n<p>To test PHP, create an index.php file in the default website root as follows.<\/p>\n<pre>$ sudo nano \/var\/www\/html\/index.php<\/pre>\n<p>Copy and paste the sample PHP code below.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>&lt;?php\r\n\r\nphpinfo();\r\n\r\n?&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Save and close the <strong>index.php<\/strong> file.<\/p>\n<p>Open a web browser and go to <strong>yourserverip\/index.php<\/strong> or <strong>localhost\/index.php<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"303\" class=\"wp-image-5206\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-283.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-283.png 717w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-283-300x127.png 300w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/p>\n<p>If you see something similar to what is shown in the image above, then PHP is working fine. That takes care of the fourth and final component of the LAMP stack.<\/p>\n<h2>Conclusion<\/h2>\n<p>This guide covered the installation of the LAMP stack (i.e., Linux, Apache, MariaDB, and PHP) on RHEL 8. Let us know if you have any comments or questions.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>The LAMP stack is a set of open-source tools used in web development. LAMP represents Linux, Apache HTTP Server, MySQL\/MariaDB, and PHP. This guide will show you how&hellip;<\/p>","protected":false},"author":1,"featured_media":5268,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[101,198],"class_list":["post-5198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-lamp-stack","tag-red-hat-enterprise-linux-8"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=5198"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5198\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/5268"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=5198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=5198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=5198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}