{"id":8138,"date":"2021-07-10T12:36:06","date_gmt":"2021-07-10T12:36:06","guid":{"rendered":"https:\/\/linuxways.net\/?p=8138"},"modified":"2021-07-10T12:36:06","modified_gmt":"2021-07-10T12:36:06","slug":"how-to-install-lamp-stack-on-rocky-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-lamp-stack-on-rocky-linux\/","title":{"rendered":"How to Install LAMP Stack on Rocky Linux"},"content":{"rendered":"<p>LAMP is a popular hosting stack widely used by developers to test-run and host websites at every stage of website development. It comprises Apache Web Server, MySQL\/MariaDB database server and PHP scripting language. In this topic, we focus on installing LAMP on Rocky Linux 8.4.<\/p>\n<h2><strong>Step 1: Install Apache web server<\/strong><\/h2>\n<p>Firstly, we will begin with the installation of Apache web server as the first component of the LAMP stack. To achieve this, launch your browser and run the command.<\/p>\n<pre><strong>$ sudo dnf install httpd<\/strong><\/pre>\n<p>The command installs the Apache httpd package alongside other dependencies as provided in the screenshot below.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"342\" class=\"wp-image-8139\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-263.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-263.png 788w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-263-300x130.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-263-768x333.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/strong><\/p>\n<p>Next, be sure to enable Apache web server to start every time the system is started or booted.<\/p>\n<pre><strong>$ sudo systemctl enable httpd<\/strong><\/pre>\n<p>Once enabled, start the Apache systemd service.<\/p>\n<pre><strong>$ sudo systemctl start httpd<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"182\" class=\"wp-image-8140\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-264.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-264.png 787w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-264-300x69.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-264-768x178.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/strong><\/p>\n<p>To be cocksure that Apache is running on Rocky Linux 8, issue the command:<\/p>\n<pre><strong>$ sudo systemctl status httpd<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"278\" class=\"wp-image-8141\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-265.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-265.png 788w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-265-300x106.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-265-768x271.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/strong><\/p>\n<p>You can also verify on a web browser by browsing your server\u2019s IP address or domain name.<\/p>\n<pre><a href=\"http:\/\/server-ip\"><strong>http:\/\/server-IP<\/strong><\/a><\/pre>\n<p>This displays the Apache HTTP test page, and this indicates that the webserver has been successfully installed.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1166\" height=\"549\" class=\"wp-image-8142\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-266.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-266.png 1166w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-266-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-266-1024x482.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-266-768x362.png 768w\" sizes=\"auto, (max-width: 1166px) 100vw, 1166px\" \/><\/strong><\/p>\n<h2><strong>Step 2: Install MariaDB database engine<\/strong><\/h2>\n<p>Once the Apache web server is in place, the next course of action is to install a database engine, in this case MariaDB server. The AppStream repos for Rocky Linux provide MariaDB 10.3 by the time of writing the tutorial. To install MariaDB, run the command:<\/p>\n<pre><strong>$ sudo dnf install mariadb-server mariadb<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"388\" class=\"wp-image-8143\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-267.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-267.png 787w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-267-300x148.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-267-768x379.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/strong><\/p>\n<p>Once installed, enable MariaDB on boot time as shown.<\/p>\n<pre><strong>$ sudo systemctl enable --now mariadb<\/strong><\/pre>\n<p>Then start the service.<\/p>\n<pre><strong>$ sudo systemctl start mariadb<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"227\" class=\"wp-image-8144\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-268.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-268.png 788w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-268-300x86.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-268-768x221.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/strong><\/p>\n<p>To confirm MariaDB service is active and running, invoke the command:<\/p>\n<pre><strong>$ sudo systemctl status mariadb<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"285\" class=\"wp-image-8145\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-269.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-269.png 788w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-269-300x109.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-269-768x278.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/strong><\/p>\n<p>The default settings for MariaDB are weak and present security loopholes that can easily be exploited by hackers and unauthorized users. Therefore, additional steps must be taken to fortify the security of the database server.<\/p>\n<p>To achieve this, run the script shown.<\/p>\n<pre><strong>$ sudo mysql_secure_installation<\/strong><\/pre>\n<p>Since we haven\u2019t yet set the root password, we will hit ENTER upon where we will be required to set the root password. Setting the root password is recommended as it ensures that no one can log into the root user without authorization.<\/p>\n<p>Therefore, set the root account.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"440\" class=\"wp-image-8146\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-270.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-270.png 791w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-270-300x167.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-270-768x427.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/strong><\/p>\n<p>For the remaining prompts, type in \u2018<strong>Y<\/strong>\u2019 to secure MariaDB to the recommended standards. This purges the anonymous users , disallows remote root login and gets rid of the test database which is not required in a production database.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"789\" height=\"438\" class=\"wp-image-8147\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-271.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-271.png 789w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-271-300x167.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-271-768x426.png 768w\" sizes=\"auto, (max-width: 789px) 100vw, 789px\" \/><\/strong><\/p>\n<p>MariaDB database is now fully configured and secure.<\/p>\n<h2><strong>Step 3: Install PHP<\/strong><\/h2>\n<p>The last component of the LAMP stack that we are going to install is PHP. Rocky Linux AppStream provides multiple versions as shown.<\/p>\n<pre><strong>$ sudo dnf module list php<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"274\" class=\"wp-image-8148\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-272.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-272.png 791w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-272-300x104.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-272-768x266.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/strong><\/p>\n<p>From the output, we can see that the default module is PHP 7.2. To install the latest module from the repository, perform a reset first.<\/p>\n<pre><strong>$ sudo dnf module list reset php<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"329\" class=\"wp-image-8149\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-273.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-273.png 790w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-273-300x125.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-273-768x320.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/strong><\/p>\n<p>Now, you can install your preferred PHP version. For instance, to install PHP 7.4, run the command.<\/p>\n<pre><strong>$ sudo dnf module install php:7.4<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"409\" class=\"wp-image-8150\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-274.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-274.png 785w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-274-300x156.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-274-768x400.png 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/strong><\/p>\n<p>To confirm PHP is installed, run the command<\/p>\n<pre><strong>$ php -v<\/strong><\/pre>\n<p>Alternatively, you can verify the version installed by creating a test PHP file in the <strong>\/var\/www\/html<\/strong> path.<\/p>\n<pre><strong>$ sudo vim \/var\/www\/html\/info.php<\/strong><\/pre>\n<p>Add the configuration below<\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>phpinfo();<\/strong>\r\n\r\n<strong>?&gt;<\/strong><\/pre>\n<p>Finally, head over to your browser and browse the URL below<\/p>\n<pre><strong>http:\/\/server-ip\/info.php<\/strong><\/pre>\n<p>This displays the following PHP page indicating the version installed and other detailed information such as the system architecture, build date, and PHP extensions.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1287\" height=\"608\" class=\"wp-image-8151\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-275.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-275.png 1287w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-275-300x142.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-275-1024x484.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-275-768x363.png 768w\" sizes=\"auto, (max-width: 1287px) 100vw, 1287px\" \/><\/strong><\/p>\n<p>You can now remove the test PHP file.<\/p>\n<pre><strong>$ sudo rm -f \/var\/www\/html\/info.php<\/strong><\/pre>\n<p>And there you go! We have successfully installed LAMP stack on Rocky Linux 8.4. You can now proceed to test or host your website and applications.<\/p>","protected":false},"excerpt":{"rendered":"<p>LAMP is a popular hosting stack widely used by developers to test-run and host websites at every stage of website development. It comprises Apache Web Server, MySQL\/MariaDB database&hellip;<\/p>","protected":false},"author":1,"featured_media":8260,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[101,411],"class_list":["post-8138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-lamp-stack","tag-rocky-linux"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8138","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=8138"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8260"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}