{"id":9153,"date":"2021-06-19T08:46:10","date_gmt":"2021-06-19T05:46:10","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9153"},"modified":"2024-03-18T20:55:10","modified_gmt":"2024-03-18T17:55:10","slug":"install-lemp-stack-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-lemp-stack-on-rocky-linux-8\/","title":{"rendered":"Install LEMP Stack on Rocky Linux 8"},"content":{"rendered":"\n<p>This guide describes a step by step tutorial on how to install LEMP stack on Rocky Linux 8.<\/p>\n\n\n\n<p>LEMP stack is a group of opensource web development softwares;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux OS,&nbsp;Rocky Linux 8, in this case.<\/li>\n\n\n\n<li>Nginx HTTP server,<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/mariadb.org\/\" target=\"_blank\">MariaDB<\/a>\/<a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL<\/a>&nbsp;relational database management systems<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.php.net\/\" target=\"_blank\">PHP<\/a>&nbsp;web scripting language<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing LEMP Stack on Rocky Linux 8<\/h2>\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 Rocky Linux 8 Linux System<\/h3>\n\n\n\n<p>In this case, the first component of the LEMP 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<p><a href=\"https:\/\/kifarunix.com\/install-rocky-linux-8-on-virtualbox\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Rocky Linux 8 on VirtualBox<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Nginx HTTP Server on Rocky Linux 8<\/h3>\n\n\n\n<p>Nginx http server can be installed on Rocky Linux 8 as easily as running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install nginx<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Running Nginx on Rocky Linux 8<\/h4>\n\n\n\n<p>Once the installation is done, you can start and enable Nginx to run on system reboot by executing;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now  nginx<\/code><\/pre>\n\n\n\n<p>To check the status;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status nginx<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf nginx.service - The nginx HTTP and reverse proxy server\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nginx.service; disabled; vendor preset: disabled)\n  Drop-In: \/usr\/lib\/systemd\/system\/nginx.service.d\n           \u2514\u2500php-fpm.conf\n   Active: active (running) since Sat 2021-06-19 00:13:03 EAT; 8s ago\n  Process: 51988 ExecStart=\/usr\/sbin\/nginx (code=exited, status=0\/SUCCESS)\n  Process: 51987 ExecStartPre=\/usr\/sbin\/nginx -t (code=exited, status=0\/SUCCESS)\n  Process: 51985 ExecStartPre=\/usr\/bin\/rm -f \/run\/nginx.pid (code=exited, status=0\/SUCCESS)\n Main PID: 51990 (nginx)\n    Tasks: 2 (limit: 11391)\n   Memory: 4.0M\n   CGroup: \/system.slice\/nginx.service\n           \u251c\u250051990 nginx: master process \/usr\/sbin\/nginx\n           \u2514\u250051991 nginx: worker process\n\nJun 19 00:13:03 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...\nJun 19 00:13:03 localhost.localdomain nginx[51987]: nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\nJun 19 00:13:03 localhost.localdomain nginx[51987]: nginx: configuration file \/etc\/nginx\/nginx.conf test is successful\nJun 19 00:13:03 localhost.localdomain systemd[1]: nginx.service: Failed to parse PID from file \/run\/nginx.pid: Invalid argument\nJun 19 00:13:03 localhost.localdomain systemd[1]: Started The nginx HTTP and reverse proxy server.\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&nbsp;<code><strong>enabled<\/strong><\/code>;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl is-enabled nginx<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Allow External Access to Nginx on Firewall<\/h4>\n\n\n\n<p>To enable external access to Nginx 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 Nginx on Rocky Linux 8<\/h4>\n\n\n\n<p>To confirm that Nginx is ready to server HTTP content, simply open your browser and enter the server IP address as&nbsp;<strong><code>http:\/\/Server.IP<\/code><\/strong>. You should land on Nginx HTTP server test page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1704\" height=\"602\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/rocky-linux-nginx.png\" alt=\"\" class=\"wp-image-9194\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/rocky-linux-nginx.png?v=1624079308 1704w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/rocky-linux-nginx-768x271.png?v=1624079308 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/rocky-linux-nginx-1536x543.png?v=1624079308 1536w\" sizes=\"(max-width: 1704px) 100vw, 1704px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Install MariaDB Database Server on Rocky Linux 8<\/h3>\n\n\n\n<p>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<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-x-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB 10.x on Rocky Linux 8<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysql -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql  Ver 15.1 Distrib 10.5.10-MariaDB, for Linux (x86_64) using readline 5.1<\/code><\/pre>\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, if not already done.<\/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 Rocky Linux 8<\/h3>\n\n\n\n<p>By default, the AppStream repos on Rocky Linux provides PHP 7.2, 7.3 and 7.4;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module list php<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Rocky 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\n<h4 class=\"wp-block-heading\">Install PHP 7.2 on Rocky Linux 8<\/h4>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"php-7.3-rock-linux\"><a href=\"#php-7.3-rock-linux\">To install PHP 7.3 Rocky Linux 8<\/a><\/h4>\n\n\n\n<p>Enable PHP 7.3 module on Rocky Linux 8<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module enable php:7.3<\/code><\/pre>\n\n\n\n<p>Install PHP 7.3 Rocky Linux 8<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"php-7.4-rocky\"><a href=\"#php-7.4-rocky\">To install PHP 7.4 Rocky Linux 8<\/a><\/h4>\n\n\n\n<pre id=\"block-fdbdba26-7245-4b30-bf47-2a58f64ca0e2\" class=\"wp-block-preformatted\">dnf module reset php<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module enable php:7.4<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"php-8.0-rocky\"><a href=\"#php-8.0-rocky\">Install PHP 8.0 on Rocky Linux 8<\/a><\/h4>\n\n\n\n<p>Install PHP Remi Repository on Rocky Linux 8.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install epel-release<\/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 module;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module reset php<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf module enable php:remi-8.0<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-mysqlnd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install PHP Extensions on Rocky Linux 8<\/h4>\n\n\n\n<p>If you need to install 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-<strong>EXTENSION<\/strong><\/code><\/pre>\n\n\n\n<p>Replacing <strong>EXTENSION<\/strong> with your respective PHP module.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Testing PHP on Rocky Linux 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-code\"><code>cat &gt; \/usr\/share\/nginx\/html\/test.php &lt;&lt; EOL\n&lt;?php \nphpinfo(); \n?&gt;\nEOL<\/code><\/pre>\n\n\n\n<p>Save the file and exit the file.<\/p>\n\n\n\n<p>Restart Nginx<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart nginx<\/code><\/pre>\n\n\n\n<p>Navigate to the browser and enter the address,&nbsp;<strong>http:\/\/&lt;server-IP&gt;\/test.php<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"938\" height=\"909\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/php-7.4-rocy-linux.png\" alt=\"\" class=\"wp-image-9195\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/php-7.4-rocy-linux.png?v=1624080593 938w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/php-7.4-rocy-linux-768x744.png?v=1624080593 768w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><\/figure><\/div>\n\n\n<p>There you go, your LEMP stack 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 \/usr\/share\/nginx\/html\/test.php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install LAMP Stack on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-vtiger-crm-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Vtiger CRM on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide describes a step by step tutorial on how to install LEMP stack on Rocky Linux 8. LEMP stack is a group of opensource<\/p>\n","protected":false},"author":1,"featured_media":9196,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[299,121,235,342],"tags":[3707,1011,3708,3710,3709],"class_list":["post-9153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-howtos","category-lemp-stack","category-php","tag-install-lemp-stack-rocky-linux-8","tag-lemp","tag-lemp-stack-on-rocky-linux","tag-nginx-rocky-linux","tag-rocky-linux-8-lemp","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9153"}],"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=9153"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9153\/revisions"}],"predecessor-version":[{"id":21785,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9153\/revisions\/21785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9196"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}