{"id":4390,"date":"2019-10-09T20:44:15","date_gmt":"2019-10-09T17:44:15","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4390"},"modified":"2024-03-12T22:25:34","modified_gmt":"2024-03-12T19:25:34","slug":"install-lemp-stack-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-lemp-stack-on-centos-8\/","title":{"rendered":"Install LEMP Stack on CentOS 8"},"content":{"rendered":"\n<p>Just like LAMP Stack, <a rel=\"noreferrer noopener\" aria-label=\"LEMP Stack (opens in a new tab)\" href=\"https:\/\/lemp.io\/\" target=\"_blank\">LEMP Stack<\/a> is a group opensource tools commonly used for developing and deploying&nbsp;web applications. It consists of the Linux Operating System (CentOS 8 in this case), lightweight and powerful Nginx (Engine-X) web server, MySQL\/MariaDB RDBMS and the server-side scripting language, PHP.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing LEMP Stack on CentOS 8<\/h2>\n\n\n\n<p>Run system 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 Nginx on CentOS 8<\/h3>\n\n\n\n<p>Nginx is available on the default AppStream repos for CentOS 8. It can simply be installed as;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install nginx<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n=======================================================================================================================================================\n Package                                    Arch                  Version                                               Repository                Size\n=======================================================================================================================================================\nInstalling:\n nginx                                      x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                569 k\nInstalling dependencies:\n nginx-all-modules                          noarch                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 23 k\n nginx-filesystem                           noarch                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 24 k\n nginx-mod-http-image-filter                x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 34 k\n nginx-mod-http-perl                        x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 45 k\n nginx-mod-http-xslt-filter                 x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 33 k\n nginx-mod-mail                             x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 64 k\n nginx-mod-stream                           x86_64                1:1.14.1-8.module_el8.0.0+5+258f653c                  AppStream                 85 k\nEnabling module streams:\n nginx                                                            1.14                                                                                \n\nTransaction Summary\n=======================================================================================================================================================\nInstall  8 Packages\n\nTotal download size: 877 k\nInstalled size: 2.0 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>Once the installation is done, start and enable Nginx to run on system boot.<\/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>\n\u25cf nginx.service - The nginx HTTP and reverse proxy server\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nginx.service; enabled; vendor preset: disabled)\n   Active: active (running) since Wed 2019-10-09 02:57:23 EDT; 10s ago\n  Process: 29029 ExecStart=\/usr\/sbin\/nginx (code=exited, status=0\/SUCCESS)\n  Process: 29027 ExecStartPre=\/usr\/sbin\/nginx -t (code=exited, status=0\/SUCCESS)\n  Process: 29026 ExecStartPre=\/usr\/bin\/rm -f \/run\/nginx.pid (code=exited, status=0\/SUCCESS)\n Main PID: 29031 (nginx)\n    Tasks: 2 (limit: 11512)\n   Memory: 9.6M\n   CGroup: \/system.slice\/nginx.service\n           \u251c\u250029031 nginx: master process \/usr\/sbin\/nginx\n           \u2514\u250029032 nginx: worker process\n...\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Allow Nginx on FirewallD<\/h4>\n\n\n\n<p>To allow external access to Nginx web server, you need to open port 80 (http) or 443 (https) depending on whether you are serving HTTP or HTTPS traffic.<\/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<\/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\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nginx-test-page.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1236\" height=\"390\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nginx-test-page.png\" alt=\"Install LEMP Stack on CentOS 8\" class=\"wp-image-4392\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nginx-test-page.png?v=1570615823 1236w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nginx-test-page-768x242.png?v=1570615823 768w\" sizes=\"(max-width: 1236px) 100vw, 1236px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Install MariaDB Database Server<\/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. If you 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 rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-mariadb-10-4-on-centos-8\/\" target=\"_blank\">Install MariaDB 10.4 on CentOS 8<\/a><\/p>\n\n\n\n<p>You can as well install MySQL 8 instead;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" 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 the required PHP module on CentOS 8 by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install php php-fpm php-mysqlnd<\/code><\/pre>\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<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 rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-php-7-4-on-centos-8\/\" target=\"_blank\">Install PHP 7.4 on CentOS 8<\/a><\/p>\n\n\n\n<p>Start and enable PHP-FPM to run on boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now php-fpm<\/code><\/pre>\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 \/usr\/share\/nginx\/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 navigate to the browser and enter the address,&nbsp;<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-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"941\" height=\"609\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info-1.png\" alt=\"Installing LEMP stack on CentOS 8\" class=\"wp-image-4395\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info-1.png?v=1570642276 941w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/php-info-1-768x497.png?v=1570642276 768w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/figure>\n\n\n\n<p>Remove PHP test page after testing.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n<p>The LEMP stack is now installed on CentOS 8 server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-lemp-stack-with-mysql-8-on-fedora-30-fedora-29\/\" target=\"_blank\">Install LEMP Stack with MySQL 8 on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-lemp-stack-on-debian-10-buster\/\" target=\"_blank\">Install LEMP Stack 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\/how-to-install-lemp-nginxmariadbphp7-2-stack-on-fedora-28-fedora-29\/\" target=\"_blank\">How to Install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 \/ Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-setup-lemp-stack-nginx-mariadb-php-7-2-on-ubuntu-18-04\/\" target=\"_blank\">How To Setup LEMP Stack (Nginx, MariaDB, PHP 7.2) on Ubuntu 18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just like LAMP Stack, LEMP Stack is a group opensource tools commonly used for developing and deploying&nbsp;web applications. It consists of the Linux Operating System<\/p>\n","protected":false},"author":1,"featured_media":12497,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,235],"tags":[1142,5000,1010,4999,136,229],"class_list":["post-4390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-lemp-stack","tag-centos-8","tag-centos-8-lemp-stack","tag-lemp-stack","tag-lemp-stack-centos-8","tag-mariadb","tag-nginx","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\/4390"}],"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=4390"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4390\/revisions"}],"predecessor-version":[{"id":21231,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4390\/revisions\/21231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/12497"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}