<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Narendra Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Narendra Chauhan on Medium]]></description>
        <link>https://medium.com/@narendra_74670?source=rss-6570a6dc54d8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rZrcrOuBbGiRqwiK24nENw.jpeg</url>
            <title>Stories by Narendra Chauhan on Medium</title>
            <link>https://medium.com/@narendra_74670?source=rss-6570a6dc54d8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:51:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@narendra_74670/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Nginx as Reverse Proxy: A Beginner’s Complete Guide to Securing and Load Balancing Your Web…]]></title>
            <link>https://medium.com/addweb-engineering/nginx-as-reverse-proxy-a-beginners-complete-guide-to-securing-and-load-balancing-your-web-df1b600ba09b?source=rss-6570a6dc54d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/df1b600ba09b</guid>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[reverse-proxy]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Narendra Chauhan]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 06:25:13 GMT</pubDate>
            <atom:updated>2025-06-25T06:25:13.875Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Nginx as Reverse Proxy: A Beginner’s Complete Guide to Securing and Load Balancing Your Web Services</strong></h3><figure><img alt="Visual of Nginx as a reverse proxy balancing traffic across multiple servers." src="https://cdn-images-1.medium.com/max/1024/1*qGSSTvlKzCuJfOgxAsjaKQ.png" /><figcaption>Visual of Nginx as a reverse proxy balancing traffic across multiple servers.</figcaption></figure><blockquote><strong>“Establish yourself in action, and let go of the outcome.”</strong><br> — <em>Inspired by Gita 2.47</em></blockquote><h3>Table of Contents</h3><ol><li>Why This Guide Matters (And Why You Should Care)</li><li>What Exactly is a Reverse Proxy?</li><li>Before We Start: What You’ll Need</li><li>Setting Up Your First Nginx Reverse Proxy</li><li>Adding Free SSL Security</li><li>Load Balancing</li><li>When Things Go Wrong: Troubleshooting Guide</li><li>FAQs</li><li>Key Stats &amp; Interesting Facts</li><li>Conclusion</li></ol><h3>1. Why This Guide Matters (And Why You Should Care)</h3><p>You’ve built an awesome web application. It works great on your laptop, but now you need to deploy it to the real world. Suddenly, you’re faced with questions like:</p><ul><li>How do I handle HTTPS securely?</li><li>What happens when my single server can’t handle all the traffic?</li><li>How do I hide my backend servers from potential attackers?</li></ul><p>This is where Nginx as a reverse proxy becomes your best friend. By the end of this guide, you’ll understand how to:</p><ul><li>Set up a professional-grade reverse proxy</li><li>Secure your traffic with free SSL certificates</li><li>Distribute load across multiple servers</li><li>Troubleshoot common issues like a pro</li></ul><p><strong>Who is this for?</strong> Developers, DevOps beginners, system administrators, or anyone curious about how modern web infrastructure works.</p><h3>2. What Exactly is a Reverse Proxy?</h3><h4>The Restaurant Analogy</h4><p>Imagine you’re at a busy restaurant. You don’t walk directly into the kitchen and demand food from the chef. Instead, you talk to a waiter who:</p><ul><li>Takes your order</li><li>Decides which chef should prepare your meal</li><li>Brings the food back to you</li><li>Handles payment and complaints</li></ul><p>A reverse proxy is like that waiter for your web services:</p><p>Internet → Nginx (Waiter) → Your Backend Servers (Chefs)</p><h3>Why Use a Reverse Proxy?</h3><p><strong>Security First</strong></p><ul><li>Your backend servers stay hidden from direct internet access</li><li>Nginx handles all the “dangerous” internet traffic first</li><li>Like having a bouncer at your club</li></ul><p><strong>SSL Termination</strong></p><ul><li>Handle all HTTPS encryption/decryption in one place</li><li>Your backend servers can focus on their job, not security</li></ul><p><strong>Load Balancing</strong></p><ul><li>Spread traffic across multiple servers</li><li>If one server dies, others keep working</li></ul><p><strong>Performance Boost</strong></p><ul><li>Cache frequently requested content</li><li>Compress responses</li><li>Serve static files directly</li></ul><h3>3. Before We Start: What You’ll Need</h3><p><strong>Server Requirements:</strong></p><ul><li>Ubuntu/Debian server (this guide uses Ubuntu)</li><li>Root or sudo access</li><li>At least 1GB RAM (2GB recommended)</li><li>A domain name pointing to your server (for SSL setup)</li></ul><p><strong>Basic Knowledge:</strong></p><ul><li>Comfort with terminal/command line</li><li>Basic understanding of web servers</li><li>Know what IP addresses and ports are</li></ul><p><strong>Important Note:</strong> Always test these configurations on a development server first!</p><blockquote><strong>“Simplicity is the ultimate sophistication — in code, in configuration, and in architecture.”</strong><br> — <em>Inspired by Leonardo da Vinci</em></blockquote><h3>4. Setting Up Your First Nginx Reverse Proxy</h3><h4>Step 1: Install Nginx (The Easy Part)</h4><p>Let’s start with the basics. On Ubuntu/Debian:<br>1. Update your system first (always a good practice)</p><p>sudo apt update</p><p>2. Install Nginx<br>sudo apt install nginx -y</p><p>3. Start Nginx and make it start automatically on boot</p><p>sudo systemctl start nginx<br>sudo systemctl enable nginx</p><p><strong>Quick Check:</strong> Open your browser and visit <a href="http://your-server-ip./">http://your-server-ip.</a> You should see the Nginx welcome page. If you don’t, check if your firewall is blocking port 80.</p><h4>Step 2: Understanding Nginx Configuration</h4><p>Nginx configuration might seem scary at first, but it’s actually quite logical:</p><p>/etc/nginx/</p><p>├── nginx.conf # Main configuration file</p><p>├── sites-available/ # Configuration files for sites</p><p>├── sites-enabled/ # Symbolic links to active sites</p><p>└── conf.d/ # Additional configuration files</p><h4>Step 3: Create Your First Reverse Proxy</h4><p>Let’s say you have a Node.js application running on port 3000. Here’s how to proxy it:</p><ul><li>Create a new configuration file</li></ul><p>sudo nano /etc/nginx/sites-available/my-app</p><p><strong>Add this configuration:</strong></p><p>server {</p><p>listen 80;</p><p>server_name yourdomain.com <a href="http://www.yourdomain.com;/">www.yourdomain.com;</a></p><p># This is where the magic happens</p><p>location / {</p><p># Forward requests to your backend application</p><p>proxy_pass <a href="http://localhost:3000;">http://localhost:3000;</a></p><p># These headers are crucial — they tell your backend about the original request</p><p>proxy_set_header Host $host;</p><p>proxy_set_header X-Real-IP $remote_addr;</p><p>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</p><p>proxy_set_header X-Forwarded-Proto $scheme;</p><p># Optional: Set timeout values</p><p>proxy_connect_timeout 60s;</p><p>proxy_send_timeout 60s;</p><p>proxy_read_timeout 60s;</p><p>}</p><p># Optional: Serve static files directly (performance boost)</p><p>location /static/ {</p><p>alias /path/to/your/static/files/;</p><p>expires 1y;</p><p>add_header Cache-Control “public, immutable”;</p><p>}</p><p>}</p><p><strong>What do those headers do?</strong></p><ul><li>Host: Tells your backend what domain was requested</li><li>X-Real-IP: The actual IP of the client (not Nginx’s IP)</li><li>X-Forwarded-For: Chain of proxies the request went through</li><li>X-Forwarded-Proto: Whether the original request was HTTP or HTTPS</li></ul><h4>Step 4: Activate Your Configuration</h4><p><strong>1. Enable the site</strong></p><p>sudo ln -s /etc/nginx/sites-available/my-app /etc/nginx/sites-enabled/</p><p><strong>2. Test the configuration (ALWAYS do this!)</strong></p><p>sudo nginx -t</p><p><strong>3. If the test passes, reload Nginx</strong></p><p>sudo systemctl reload nginx</p><p>If nginx -t fails, don’t reload! Fix the errors first, or you might break your entire web server.</p><h4>Step 5: Test Your Setup</h4><ol><li>Make sure your backend application is running on port 3000</li><li>Visit <a href="http://yourdomain.com/">http://yourdomain.com</a> in your browser</li></ol><p><strong>Troubleshooting Quick Check:</strong></p><p>1. <strong>Nginx running?</strong></p><p>sudo systemctl status nginx</p><p>2. <strong>Check Nginx logs if something’s wrong</strong></p><p>sudo tail -f /var/log/nginx/error.log</p><h3>5. Adding Free SSL Security</h3><h3>Why SSL is Non-Negotiable in 2025<br>Remember when websites with HTTPS were special? Those days are over. Today:</h3><ul><li>Browsers mark HTTP sites as “Not Secure”</li><li>Search engines rank HTTPS sites higher</li><li>Users don’t trust sites without the green lock</li></ul><h3>Step 1: Install Certbot</h3><p>sudo apt install certbot python3-certbot-nginx -y</p><p>Certbot is like having a personal assistant for SSL certificates. It talks to Let’s Encrypt (a free certificate authority) and configures everything for you.</p><h3>Step 2: Get Your Free SSL Certificate</h3><p>sudo certbot — nginx -d yourdomain.com -d <a href="http://www.yourdomain.com/">www.yourdomain.com</a></p><p>Certbot will:</p><ol><li>Verify you own the domain</li><li>Get a certificate from Let’s Encrypt</li><li>Automatically modify your Nginx configuration</li><li>Set up HTTP to HTTPS redirects</li></ol><h3>Step 3: Verify Your SSL Setup</h3><p>Visit <a href="https://yourdomain.com/"><strong>https://yourdomain.com</strong></a><strong> </strong>— you should see:</p><ul><li>A green lock icon in your browser</li><li>Your site loads over HTTPS</li><li>HTTP requests automatically redirect to HTTPS</li></ul><p><strong>Test SSL quality:</strong> Use<a href="https://www.ssllabs.com/ssltest/"> SSL Labs’ SSL Test</a> to check your SSL configuration. Aim for an A+ rating!</p><h3>Step 4: Set Up Automatic Renewal (Critical!)</h3><p>Let’s Encrypt certificates expire every 90 days. Here’s how to auto-renew:</p><p>1. <strong>Test the renewal process</strong></p><p>sudo certbot renew — dry-run</p><p>2. <strong>If that works, add a cron job for automatic renewal</strong></p><p>sudo crontab -e</p><p><strong>Add this line to run renewal check twice daily:</strong></p><p>0 12 * * * /usr/bin/certbot renew — quiet</p><p><strong>Your updated Nginx config now looks like this:</strong></p><p>server {</p><p>listen 443 ssl http2;</p><p>server_name yourdomain.com <a href="http://www.yourdomain.com;/">www.yourdomain.com;</a></p><p>ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;</p><p>ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;</p><p>location / {</p><p>proxy_pass <a href="http://localhost:3000;">http://localhost:3000;</a></p><p>proxy_set_header Host $host;</p><p>proxy_set_header X-Real-IP $remote_addr;</p><p>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</p><p>proxy_set_header X-Forwarded-Proto $scheme;</p><p>}</p><p>}</p><p>server {</p><p>listen 80;</p><p>server_name yourdomain.com <a href="http://www.yourdomain.com;/">www.yourdomain.com;</a></p><p>return 301 <a href="https://$server_name$request_uri;/">https://$server_name$request_uri;</a></p><p>}</p><blockquote><strong>“A well-configured server is like a calm mind — secure, balanced, and ready to handle any load.”</strong></blockquote><h3>6. Load Balancing</h3><h4>When Do You Need Load Balancing?</h4><p>You need load balancing when:</p><ul><li>Your single server can’t handle all the traffic</li><li>You want redundancy (if one server fails, others continue)</li><li>You’re scaling horizontally (adding more servers instead of bigger servers)</li></ul><h4>The Upstream Block: Your Server Pool</h4><p>Think of upstream as your team of backend servers:</p><p>upstream my_backend {</p><p># Default method: round-robin (requests distributed evenly)</p><p>server 192.168.1.10:3000;</p><p>server 192.168.1.11:3000;</p><p>server 192.168.1.12:3000;</p><p># Optional: Add server weights (server1 gets 3x more traffic)</p><p># server 192.168.1.10:3000 weight=3;</p><p># server 192.168.1.11:3000 weight=1;</p><p># server 192.168.1.12:3000 weight=1;</p><p>}</p><h4>Load Balancing Methods</h4><p><strong>Round Robin (Default):</strong></p><ul><li>Request 1 → Server 1</li><li>Request 2 → Server 2</li><li>Request 3 → Server 3</li><li>Request 4 → Server 1 (cycle repeats)</li></ul><p><strong>Least Connections:</strong></p><p>upstream my_backend {</p><p>least_conn;</p><p>server 192.168.1.10:3000;</p><p>server 192.168.1.11:3000;</p><p>server 192.168.1.12:3000;</p><p>}</p><p><strong>IP Hash (Sticky Sessions):</strong></p><p>upstream my_backend {</p><p>ip_hash; # Same client always goes to same server</p><p>server 192.168.1.10:3000;</p><p>server 192.168.1.11:3000;</p><p>server 192.168.1.12:3000;</p><p>}</p><h4>Complete Load Balancing Configuration</h4><p>upstream my_backend {</p><p>server 192.168.1.10:3000 max_fails=3 fail_timeout=30s;</p><p>server 192.168.1.11:3000 max_fails=3 fail_timeout=30s;</p><p>server 192.168.1.12:3000 max_fails=3 fail_timeout=30s;</p><p># Optional: Backup server (only used when all others fail)</p><p>server 192.168.1.13:3000 backup;</p><p>}</p><p>server {</p><p>listen 443 ssl http2;</p><p>server_name yourdomain.com <a href="http://www.yourdomain.com;/">www.yourdomain.com;</a></p><p>ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;</p><p>ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;</p><p>location / {</p><p>proxy_pass <a href="http://my_backend;/">http://my_backend;</a> # Note: uses upstream name</p><p>proxy_set_header Host $host;</p><p>proxy_set_header X-Real-IP $remote_addr;</p><p>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</p><p>proxy_set_header X-Forwarded-Proto $scheme;</p><p>}</p><p>}</p><p><strong>Health Check Parameters:</strong></p><ul><li>max_fails=3: Mark server as unavailable after 3 failed attempts</li><li>fail_timeout=30s: Wait 30 seconds before trying failed server again</li><li>backup: Only use this server when all others are down</li></ul><h4>Test Your Load Balancing</h4><ol><li>Start multiple instances of your application on different servers</li><li>Reload Nginx configuration</li><li>Make multiple requests and check server logs to verify distribution</li></ol><h3>7. When Things Go Wrong: Troubleshooting Guide</h3><h4>The Big Three Errors (And How to Fix Them)</h4><p><strong>1. 502 Bad Gateway — “The Classic”</strong></p><p>What it means: Nginx can’t reach your backend server.</p><p><strong>Debugging steps:</strong></p><ol><li><strong>Is your backend actually running?</strong></li></ol><p>sudo netstat -tlnp | grep :3000</p><ol><li><strong>Check if the backend is responding locally</strong></li></ol><p>curl <a href="http://localhost:3000/">http://localhost:3000</a></p><ol><li><strong>Look at Nginx error logs</strong></li></ol><p>sudo tail -f /var/log/nginx/error.log</p><ol><li><strong>Check firewall settings</strong></li></ol><p>sudo ufw status</p><p><strong>Common causes:</strong></p><ul><li>Backend server is down</li><li>Wrong port in proxy_pass</li><li>Firewall blocking internal communication</li><li>Backend server listening on 127.0.0.1 instead of 0.0.0.0</li></ul><p><strong>2. SSL Certificate Errors</strong></p><p>What it means: Something’s wrong with your HTTPS setup.</p><p><strong>Debugging steps:</strong></p><ol><li><strong>Check certificate status</strong></li></ol><p>sudo certbot certificates</p><ol><li><strong>Test SSL configuration</strong></li></ol><p>sudo nginx -t</p><ol><li><strong>Check if port 80 is accessible (needed for Let’s Encrypt)</strong></li></ol><p>curl -I <a href="http://yourdomain.com/.well-known/acme-challenge/test">http://yourdomain.com/.well-known/acme-challenge/test</a></p><ol><li><strong>Manual certificate renewal</strong></li></ol><p>sudo certbot renew — force-renewal</p><p><strong>Common causes:</strong></p><ul><li>DNS not pointing to your server</li><li>Port 80 blocked by firewall</li><li>Certificate expired</li><li>Wrong domain in certificate</li></ul><p><strong>3. Configuration Syntax Errors</strong></p><p>What it means: Typo in your Nginx config.</p><p><strong>Debugging:</strong></p><p># Always test before reloading!</p><p>sudo nginx -t</p><p># Check specific configuration file</p><p>sudo nginx -t -c /etc/nginx/sites-available/my-app</p><p><strong>Common syntax errors:</strong></p><ul><li>Missing semicolons</li><li>Mismatched braces { }</li><li>Wrong directive names</li><li>Invalid parameter values</li></ul><h4>Monitoring and Logging</h4><h4>Enable detailed logging:-</h4><p>server {</p><p>access_log /var/log/nginx/my-app-access.log;</p><p>error_log /var/log/nginx/my-app-error.log;</p><p>location / {</p><p>proxy_pass <a href="http://my_backend;/">http://my_backend;</a></p><p># Log proxy details</p><p>proxy_set_header X-Request-ID $request_id;</p><p>add_header X-Request-ID $request_id;</p><p>}</p><p>}</p><p><strong>Real-time monitoring:</strong></p><p>1. Watch access logs</p><p><strong>sudo tail -f /var/log/nginx/access.log</strong></p><p>2. Watch error logs</p><p><strong>sudo tail -f /var/log/nginx/error.log</strong></p><p>3. Monitor specific site</p><p><strong>sudo tail -f /var/log/nginx/my-app-*.log</strong></p><blockquote><strong>“You don’t rise to the level of your expectations. You fall to the level of your preparation.”</strong><br> — <em>Archilochus (Greek poet)</em></blockquote><h3>8. FAQs</h3><p><strong>Q: Can I use Nginx to balance non-HTTP traffic (like databases)?</strong> A: The open-source version of Nginx only supports HTTP/HTTPS load balancing. For TCP/UDP load balancing, you need Nginx Plus (commercial) or alternatives like HAProxy.</p><p><strong>Q: How do I handle WebSocket connections through Nginx?</strong> A: Add these directives to your location block:</p><p>location /websocket/ {</p><p>proxy_pass <a href="http://backend;/">http://backend;</a></p><p>proxy_http_version 1.1;</p><p>proxy_set_header Upgrade $http_upgrade;</p><p>proxy_set_header Connection “upgrade”;</p><p>proxy_set_header Host $host;</p><p>}</p><p><strong>Q: What happens if all my backend servers go down?</strong> A: Nginx will return a 502 Bad Gateway error. Consider setting up a backup server or a maintenance page:</p><p>upstream backend {</p><p>server 192.168.1.10:3000;</p><p>server 192.168.1.11:3000;</p><p>server 192.168.1.12:3000 backup;</p><p>}</p><p>error_page 502 503 504 /maintenance.html;</p><p>location = /maintenance.html {</p><p>root /var/www/html;</p><p>}</p><h3>9. Key Stats &amp; Interesting Facts</h3><ul><li><strong>Nginx vs Apache:</strong> Nginx handles static content and concurrent connections much more efficiently than Apache. That’s why it powers over <strong>35% of the top 1 million websites</strong>.<br>Source: <a href="https://www.dreamhost.com/blog/nginx-vs-apache">Nginx vs Apache</a></li><li><strong>Used by the Giants:</strong> Nginx is used by <strong>Netflix</strong>, <strong>GitHub</strong>, <strong>WordPress.com</strong>, and <strong>Dropbox</strong> for its speed and reliability.<br>Source: <a href="https://www.globenewswire.com/news-release/2012/06/18/952322/0/en/Nginx-Inc-Consulted-for-Netflix-Open-Connect-Initiative.html">Giants</a></li><li><strong>Nginx is Event-Driven:</strong> Unlike thread-per-request servers, it uses asynchronous, non-blocking I/O — which is why it excels at handling high traffic loads.<br>Source: <a href="https://gurzu.com/blog/handling-concurrent-connections-at-scale-with-nginx-event-driven-architecture/">Event Driven</a></li></ul><h3>10. Conclusion</h3><p>By now, you’ve taken a big leap from just running a web app locally to deploying and securing it like a pro. Using Nginx as a reverse proxy not only strengthens your web infrastructure but also prepares your system for real-world challenges like traffic spikes, SSL management, and scalability. Whether you’re a solo developer or part of a growing DevOps team, mastering Nginx is an essential skill that pays off in performance, security, and reliability.</p><p>#Nginx #ReverseProxy #LoadBalancing #LetsEncrypt #SSL #WebSecurity #DevOps #CloudComputing #Kubernetes #OpenSource #SysAdmin #Linux</p><p><strong>About the Author: </strong><em>Narendra is a DevOps Engineer at </em><a href="https://www.addwebsolution.com/"><strong>AddWebSolution</strong></a><em>, helping businesses in Europe and the US automate infrastructure and build scalable cloud environments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df1b600ba09b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/addweb-engineering/nginx-as-reverse-proxy-a-beginners-complete-guide-to-securing-and-load-balancing-your-web-df1b600ba09b">Nginx as Reverse Proxy: A Beginner’s Complete Guide to Securing and Load Balancing Your Web…</a> was originally published in <a href="https://medium.com/addweb-engineering">AddWeb Digital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Enable Disabled PHP Functions]]></title>
            <link>https://medium.com/addweb-engineering/how-to-enable-disabled-php-functions-740e4a2fbbd8?source=rss-6570a6dc54d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/740e4a2fbbd8</guid>
            <category><![CDATA[wordpress-plugins]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[function-php]]></category>
            <category><![CDATA[wordpress-hosting]]></category>
            <category><![CDATA[wordpress-cloud-hosting]]></category>
            <dc:creator><![CDATA[Narendra Chauhan]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 10:48:46 GMT</pubDate>
            <atom:updated>2025-04-04T11:18:54.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Guide on enabling disabled PHP functions for web applications." src="https://cdn-images-1.medium.com/max/1024/1*w57arsxZHhXxd3AHSv4skQ.png" /><figcaption>Guide on enabling disabled PHP functions for web applications.</figcaption></figure><blockquote>“Security is not a product, but a process.” — Bruce Schneier, Security Expert</blockquote><h3>Table of Contents</h3><p>1. Introduction</p><p>2. Why Are PHP Functions Disabled?</p><p>3. Step-by-Step Guide to Enabling PHP Functions</p><ul><li>Step 1: Locate the PHP Configuration File</li><li>Step 2: Edit the php.ini File</li><li>Step 3: Save and Restart PHP-FPM</li><li>Step 4: Verify the Changes</li></ul><p>4. Interesting Facts &amp; Statistics</p><p>5. FAQs</p><p>6. Key Takeaways</p><p>7. Conclusion</p><h3>Introduction</h3><p>PHP provides a robust set of built-in functions that simplify tasks like file handling, executing system commands, and database interactions. However, for security reasons, some PHP functions may be disabled by default. In certain scenarios, developers might need to enable these functions to run specific applications or scripts. This guide will walk you through the process of enabling disabled PHP functions safely and effectively.</p><h3>Why Are PHP Functions Disabled?</h3><p>PHP functions such as exec(), shell_exec(), and system() are often disabled in production environments due to their potential security risks. These functions allow users to execute system commands, which, if exploited, can lead to malicious attacks such as code injection or unauthorized access. Therefore, disabling them is a common practice in order to minimize vulnerabilities.</p><h3>Step-by-Step Guide to Enabling PHP Functions</h3><p>Follow these simple steps to enable disabled PHP functions on your server:</p><h4>Step 1: Locate the PHP Configuration File</h4><p>The first step is to find the PHP configuration file (php.ini), which governs the settings for PHP. To find its location, run the following command:</p><p>php — ini</p><p>Alternatively, you can create a simple PHP script with the following content to check the location:</p><p><em>&lt;?php</em></p><p><em>phpinfo();</em></p><p><em>?&gt;</em></p><p>Look for the “Loaded Configuration File” entry in the output to find the path to the php.ini file.</p><h4>Step 2: Edit the php.ini File</h4><p>After locating the php.ini file, open it in a text editor (such as nano, vim, or any other editor):</p><p><strong>sudo nano /etc/php/{php-version}/fpm/php.ini</strong></p><p>Search for the disable_functions directive, which may look something like this:</p><p><strong>disable_functions = exec, shell_exec, system, passthru, phpinfo</strong></p><p>To enable a specific function, remove it from the list. For example, to enable exec(), modify the line as follows:</p><p><strong>disable_functions = shell_exec, system, passthru, phpinfo</strong></p><p>If you wish to enable all disabled functions, you can either remove the disable_functions line or set it as follows:</p><p><strong>disable_functions =</strong></p><h4>Step 3: Save and Restart PHP-FPM</h4><p>Once you’ve made your changes, save the php.ini file and restart the PHP-FPM service for the changes to take effect. Use one of the following commands, depending on your server configuration:</p><p>sudo systemctl restart php{php-version}-fpm</p><h4>Step 4: Verify the Changes</h4><p>To verify that the function has been enabled, create a test PHP script:</p><p><em>&lt;?php</em></p><p><em>if (function_exists(‘exec’)) {</em></p><p><em>echo “exec() is enabled.”;</em></p><p><em>} else {</em></p><p><em>echo “exec() is disabled.”;</em></p><p><em>}</em></p><p><em>?&gt;</em></p><p>You can then run this script either through a browser or via the command line:</p><p>php test.php</p><p>If the function is enabled, you should see the message: exec() is enabled.</p><blockquote>“The best way to predict the future is to invent it.” — Alan Kay, Computer Scientist</blockquote><h3>Interesting Facts &amp; Statistics</h3><ul><li><strong>PHP Usage:</strong> PHP powers over 70% of websites today, including popular platforms like WordPress, Facebook, and Wikipedia. <a href="https://specbitsskills.com/blog/is-php-still-relevant-for-web-development-in-2025">https://specbitsskills.com/blog/is-php-still-relevant-for-web-development-in-2025</a></li><li><strong>Security Implications:</strong> According to a 2020 study, misconfigured PHP servers account for more than 15% of all web vulnerabilities.<br><a href="https://www.zend.com/blog/php-vulnerabilities">https://www.zend.com/blog/php-vulnerabilities</a></li><li><strong>Disable Functions List:</strong> Commonly disabled PHP functions include exec(), shell_exec(), system(), and passthru(), primarily due to security concerns. <a href="https://serverok.in/php-disable-functions">https://serverok.in/php-disable-functions</a></li></ul><h3>FAQs</h3><h4>Q1: Is it safe to enable PHP functions like exec() or shell_exec()?</h4><p>While these functions are often disabled for security reasons, enabling them can be safe if used cautiously. Always ensure proper input validation and use secure coding practices to prevent malicious exploitation.</p><h4>Q2: Can I enable all disabled functions by removing the disable_functions line completely?</h4><p>Yes, removing the disable_functions directive will allow all functions to be used. However, this may introduce security risks, so it’s best to only enable the specific functions you need.</p><h4>Q3: Will restarting PHP-FPM always apply the changes?</h4><p>Yes, restarting the PHP-FPM service ensures that changes to the php.ini file are applied correctly. It’s important to restart the service after modifying the PHP configuration.</p><h3>Key Takeaways</h3><ul><li><strong>Security Concerns:</strong> Disabling PHP functions like exec() is a precaution against malicious attacks.</li><li><strong>Safe Enabling:</strong> Only enable the functions you need and always validate input to minimize security risks.</li><li><strong>Server Restart:</strong> Changes to php.ini require a restart of the PHP-FPM service to take effect.</li></ul><h3>Conclusion</h3><p>Enabling disabled PHP functions is a straightforward process, but it must be done with caution. By following the steps outlined above, you can enable the necessary functions while maintaining a secure environment. Always assess the risks and take appropriate measures to safeguard your server, especially in shared hosting environments. If you’re unsure, consult with your hosting provider before making changes to the PHP configuration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740e4a2fbbd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/addweb-engineering/how-to-enable-disabled-php-functions-740e4a2fbbd8">How to Enable Disabled PHP Functions</a> was originally published in <a href="https://medium.com/addweb-engineering">AddWeb Digital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>