{"id":2604,"date":"2024-12-31T08:41:03","date_gmt":"2023-01-09T20:19:54","guid":{"rendered":""},"modified":"2025-02-02T00:46:18","modified_gmt":"2025-02-01T23:46:18","slug":"how-to-install-nginx-with-php-and-mariadb-lemp-stack-with-opcache-redis-and-let-039-s-encrypt-on-fedora-32","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-nginx-with-php-and-mariadb-lemp-stack-with-opcache-redis-and-let-039-s-encrypt-on-fedora-32\/","title":{"rendered":"How to Install Nginx with PHP and MariaDB (LEMP Stack) with Opcache, Redis and Let&#039;s Encrypt on Fedora 32"},"content":{"rendered":"<h1>\u00a0<\/h1>\n<p>LEMP stack is a popular set of open-source software that is used to serve dynamic websites and applications. LEMP stands for Linux, Nginx (pronounced &#8220;Engine-X&#8221;), MariaDB, and PHP. In this guide, we will walk you through how to install and configure the LEMP stack with PHP Opcache, Redis, and secure your server using Let&#8217;s Encrypt SSL on Fedora 32. Whether you&#8217;re hosting your server on a  or another cloud service, this guide will help you set up a powerful web server.<\/p>\n<h2>Prerequisites<\/h2>\n<p>Before starting, ensure you have the following:<\/p>\n<ul>\n<li>A Fedora 32 server, which could be hosted on a <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">UK Windows VPS<\/a>, <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPSVirtual Private Servers<\/a>, or another <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPS Hosting UK<\/a> solution.<\/li>\n<li>Root or sudo privileges on your server.<\/li>\n<li>A domain name pointed to your server\u2019s IP address.<\/li>\n<\/ul>\n<h2>Step 1: Update Your System<\/h2>\n<p>First, make sure your system is up to date. Run the following commands:<\/p>\n<pre><code>sudo dnf update -y<\/code><\/pre>\n<h2>Step 2: Install Nginx<\/h2>\n<p>Nginx will serve as the web server for your LEMP stack. Install Nginx with the following command:<\/p>\n<pre><code>sudo dnf install nginx -y<\/code><\/pre>\n<p>Once installed, start Nginx and enable it to start on boot:<\/p>\n<pre><code>sudo systemctl start nginx\r\nsudo systemctl enable nginx<\/code><\/pre>\n<h2>Step 3: Install PHP and PHP Extensions<\/h2>\n<p>Next, install PHP along with necessary extensions, including Opcache for improved performance:<\/p>\n<pre><code>sudo dnf install php php-fpm php-mysqlnd php-opcache php-xml php-mbstring php-zip php-json php-curl -y<\/code><\/pre>\n<p>Configure PHP-FPM by editing the following file:<\/p>\n<pre><code>sudo nano \/etc\/php-fpm.d\/www.conf<\/code><\/pre>\n<p>Find the line that starts with <code>user =<\/code> and <code>group =<\/code> and change it to:<\/p>\n<pre><code>user = nginx\r\ngroup = nginx<\/code><\/pre>\n<p>Save the file and restart PHP-FPM:<\/p>\n<pre><code>sudo systemctl restart php-fpm\r\nsudo systemctl enable php-fpm<\/code><\/pre>\n<h2>Step 4: Install MariaDB<\/h2>\n<p>MariaDB is a powerful open-source database management system that will store your website&#8217;s data. Install MariaDB by running:<\/p>\n<pre><code>sudo dnf install mariadb-server -y<\/code><\/pre>\n<p>Once installed, start and enable MariaDB:<\/p>\n<pre><code>sudo systemctl start mariadb\r\nsudo systemctl enable mariadb<\/code><\/pre>\n<p>Secure the MariaDB installation by running the security script:<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>Follow the on-screen instructions to set a root password and secure your database server.<\/p>\n<h2>Step 5: Install Redis<\/h2>\n<p>Redis is a powerful in-memory key-value store that can be used to speed up your web applications. Install Redis with the following command:<\/p>\n<pre><code>sudo dnf install redis -y<\/code><\/pre>\n<p>Start and enable Redis:<\/p>\n<pre><code>sudo systemctl start redis\r\nsudo systemctl enable redis<\/code><\/pre>\n<p>To integrate Redis with PHP, install the Redis PHP extension:<\/p>\n<pre><code>sudo dnf install php-redis -y<\/code><\/pre>\n<h2>Step 6: Configure Nginx for PHP<\/h2>\n<p>Create a new Nginx server block to host your website. For example, create a configuration file for your domain:<\/p>\n<pre><code>sudo nano \/etc\/nginx\/conf.d\/your-domain.conf<\/code><\/pre>\n<p>Add the following configuration:<\/p>\n<pre><code>server {\r\n    listen 80;\r\n    server_name your-domain.com www.your-domain.com;\r\n\r\n    root \/var\/www\/html;\r\n    index index.php index.html index.htm;\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ =404;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        include fastcgi_params;\r\n        fastcgi_pass unix:\/run\/php-fpm\/www.sock;\r\n        fastcgi_index index.php;\r\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n    }\r\n\r\n    location ~ \/\\.ht {\r\n        deny all;\r\n    }\r\n}<\/code><\/pre>\n<p>Save the file and restart Nginx to apply the changes:<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2>Step 7: Secure Your Website with Let&#8217;s Encrypt SSL<\/h2>\n<p>To secure your website, you can use Let&#8217;s Encrypt to obtain a free SSL certificate. First, install Certbot:<\/p>\n<pre><code>sudo dnf install certbot python3-certbot-nginx -y<\/code><\/pre>\n<p>Next, run the following command to obtain an SSL certificate for your domain:<\/p>\n<pre><code>sudo certbot --nginx -d your-domain.com -d www.your-domain.com<\/code><\/pre>\n<p>Follow the on-screen instructions to complete the process. Certbot will automatically configure Nginx to use SSL.<\/p>\n<h2>Step 8: Test Your LEMP Stack<\/h2>\n<p>To test if everything is working, create a simple PHP file in the <code>\/var\/www\/html<\/code> directory:<\/p>\n<pre><code>sudo nano \/var\/www\/html\/info.php<\/code><\/pre>\n<p>Add the following content to the file:<\/p>\n<pre><code>&lt;?php phpinfo(); ?&gt;<\/code><\/pre>\n<p>Save the file and navigate to <code>http:\/\/your-domain.com\/info.php<\/code> in your web browser. You should see the PHP information page, which indicates that PHP is working correctly with Nginx.<\/p>\n<h2>Conclusion<\/h2>\n<p>By following these steps, you have successfully installed the LEMP stack with PHP Opcache, Redis, and Let&#8217;s Encrypt SSL on Fedora 32. Whether you are hosting your website on a , <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Microsoft SQL VPS Windows<\/a>, or another <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPSVirtual Private Server Hosting<\/a>, this setup will help you create a fast and secure web application.<\/p>\n<footer>\n<p>For more VPS hosting options, visit . They offe<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 LEMP stack is a popular set of open-source software that is used to serve dynamic websites and applications. LEMP stands for Linux, Nginx (pronounced &#8220;Engine-X&#8221;), MariaDB, and\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-2604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=2604"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2604\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=2604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=2604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=2604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}