<?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"><channel><title><![CDATA[Devops with Muaz]]></title><description><![CDATA[Embarking on a learning journey through Linux, DevOps, and Cloud. Sharing my discoveries and insights, one post at a time.]]></description><link>https://muhammadmuazarif.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 04:11:45 GMT</lastBuildDate><atom:link href="https://muhammadmuazarif.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Setting Up a WordPress Site with Nginx, MySQL, and PHP on Ubuntu]]></title><description><![CDATA[In this comprehensive guide, I'll walk you through the process of setting up a WordPress website using Nginx as the web server, MySQL as the database, and PHP for processing. This blog will guide you on how to deploy a full LEMP (Linux, Nginx, MySQL,...]]></description><link>https://muhammadmuazarif.hashnode.dev/setting-up-a-wordpress-site-with-nginx-mysql-and-php-on-ubuntu</link><guid isPermaLink="true">https://muhammadmuazarif.hashnode.dev/setting-up-a-wordpress-site-with-nginx-mysql-and-php-on-ubuntu</guid><category><![CDATA[WordPress]]></category><category><![CDATA[Linux]]></category><category><![CDATA[nginx]]></category><category><![CDATA[MySQL]]></category><category><![CDATA[PHP]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Ubuntu 22.04]]></category><dc:creator><![CDATA[Muhammad Muaz Arif]]></dc:creator><pubDate>Sun, 07 Sep 2025 13:45:02 GMT</pubDate><content:encoded><![CDATA[<p>In this comprehensive guide, I'll walk you through the process of setting up a WordPress website using Nginx as the web server, MySQL as the database, and PHP for processing. This blog will guide you on how to deploy a full LEMP (Linux, Nginx, MySQL, PHP) stack environment from scratch.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>Ubuntu server (20.04 or later)</p>
</li>
<li><p>SSH access with sudo privileges</p>
</li>
<li><p>Basic command line knowledge</p>
</li>
</ul>
<h2 id="heading-step-1-installing-the-necessary-components">Step 1: Installing the Necessary Components</h2>
<p>First, we need to install the core components of our LEMP stack:</p>
<pre><code class="lang-bash">sudo apt update
sudo apt install nginx mysql-server php8.1-fpm php-mysql
</code></pre>
<p>This command installs:</p>
<ul>
<li><p>Nginx: High-performance web server</p>
</li>
<li><p>MySQL: Database management system</p>
</li>
<li><p>PHP 8.1 FPM: PHP FastCGI Process Manager with MySQL extension</p>
</li>
</ul>
<h2 id="heading-step-2-installing-additional-php-extensions">Step 2: Installing Additional PHP Extensions</h2>
<p>WordPress requires several PHP extensions to function properly:</p>
<pre><code class="lang-bash">sudo apt install php-curl php-xml php-mbstring php-zip php-gd
</code></pre>
<p>These extensions provide additional functionality for handling images, XML processing, multibyte strings, and more.</p>
<h2 id="heading-step-3-downloading-and-extracting-wordpress">Step 3: Downloading and Extracting WordPress</h2>
<p>We'll download the latest version of WordPress and extract it to our web directory:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo cp -R /tmp/wordpress/* /var/www/html/
</code></pre>
<p>This downloads the WordPress package, extracts it, and copies all files to the default Nginx web directory.</p>
<h2 id="heading-step-4-configuring-nginx-for-wordpress">Step 4: Configuring Nginx for WordPress</h2>
<p>Next, we create a custom Nginx configuration file for our WordPress site:</p>
<pre><code class="lang-bash">sudo nano /etc/nginx/sites-available/wordpress
</code></pre>
<p>Here's the configuration I used:</p>
<pre><code class="lang-nginx"><span class="hljs-section">server</span> {
    <span class="hljs-attribute">listen</span> <span class="hljs-number">80</span>;
    <span class="hljs-attribute">server_name</span> server_ip;

    <span class="hljs-attribute">root</span> /var/www/html;
    <span class="hljs-attribute">index</span> index.php index.html index.htm;

    <span class="hljs-attribute">location</span> / {
        <span class="hljs-attribute">try_files</span> <span class="hljs-variable">$uri</span> <span class="hljs-variable">$uri</span>/ /index.php?<span class="hljs-variable">$args</span>;
    }
    <span class="hljs-attribute">location</span> <span class="hljs-regexp">~ \.php$</span> {
        <span class="hljs-attribute">include</span> snippets/fastcgi-php.conf;
        <span class="hljs-attribute">fastcgi_pass</span> unix:/var/run/php/php8.1-fpm.sock;
        <span class="hljs-attribute">fastcgi_param</span> SCRIPT_FILENAME <span class="hljs-variable">$document_root</span><span class="hljs-variable">$fastcgi_script_name</span>;
        <span class="hljs-attribute">include</span> fastcgi_params;
    }

    <span class="hljs-attribute">location</span> <span class="hljs-regexp">~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$</span> {
        <span class="hljs-attribute">expires</span> <span class="hljs-number">30d</span>;
        <span class="hljs-attribute">add_header</span> Cache-Control <span class="hljs-string">"public, no-transform"</span>;
    }
}
</code></pre>
<p>This configuration:</p>
<ul>
<li><p>Sets the server to listen on port 80</p>
</li>
<li><p>Defines the document root where WordPress is installed</p>
</li>
<li><p>Configures PHP processing through PHP-FPM</p>
</li>
<li><p>Sets caching rules for static assets</p>
</li>
</ul>
<h2 id="heading-step-5-enabling-the-site-and-reloading-nginx">Step 5: Enabling the Site and Reloading Nginx</h2>
<p>We enable the site by creating a symbolic link and then reload Nginx:</p>
<pre><code class="lang-bash">sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo systemctl reload nginx
</code></pre>
<h2 id="heading-step-6-ensuring-php-fpm-is-running">Step 6: Ensuring PHP-FPM is Running</h2>
<p>To make sure we have the correct PHP version, I added the Ondrej PHP repository and ensured PHP-FPM was running:</p>
<pre><code class="lang-bash">sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1-fpm
sudo systemctl start php8.1-fpm
</code></pre>
<h2 id="heading-expected-outcome">Expected Outcome</h2>
<p>After completing these steps, you should have:</p>
<ol>
<li><p>A fully installed LEMP stack (Linux, Nginx, MySQL, PHP)</p>
</li>
<li><p>WordPress files properly placed in the web directory</p>
</li>
<li><p>Nginx configured to serve WordPress with PHP processing</p>
</li>
<li><p>All necessary PHP extensions installed</p>
</li>
<li><p>A running WordPress installation accessible via your server's IP address</p>
</li>
</ol>
<p>When you navigate to your server's IP address in a web browser, you should see the WordPress installation wizard, which will guide you through the final steps of setting up your database connection and configuring your site.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1757252167648/45d44426-316f-4567-bba5-d815871b6523.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-troubleshooting-tips">Troubleshooting Tips</h2>
<p>If you encounter issues:</p>
<p>Check that all services are running</p>
<pre><code class="lang-bash">sudo systemctl status nginx mysql php8.1-fpm
</code></pre>
<p>Verify file permissions in /var/www/html</p>
<p>Check Nginx error logs:</p>
<pre><code class="lang-bash">sudo tail -f /var/<span class="hljs-built_in">log</span>/nginx/error.log
</code></pre>
]]></content:encoded></item></channel></rss>