<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Docker error 500 &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/docker-error-500/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Mon, 12 Oct 2026 11:54:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Fixing HTTP 500 Errors When Setting Up a Local WordPress Development Environment with Docker</title>
		<link>https://www.bestdevops.com/setup-local-wordpress-development-environment-with-docker-error-500/</link>
					<comments>https://www.bestdevops.com/setup-local-wordpress-development-environment-with-docker-error-500/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Mon, 26 Jun 2017 07:30:40 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[DevOps Tools]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Docker Compose]]></category>
		<category><![CDATA[Docker error 500]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Wordpress development]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=1939</guid>

					<description><![CDATA[Learn how to configure Nginx, PHP-FPM, and MariaDB with Docker Compose for a local WordPress environment, and troubleshoot the HTTP 500 error that appears during WordPress setup-config.php.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Setting up a local WordPress development environment with Docker gives you full control over the stack — but it also means you have to wire up Nginx, PHP-FPM, and MariaDB yourself. A common stumbling block is an HTTP 500 error that appears silently during the WordPress installation wizard, specifically when submitting database credentials at <code>/wp-admin/setup-config.php?step=1</code>. This article walks through a working Docker Compose configuration and explains why the 500 error occurs and how to fix it.</p>



<h2 class="wp-block-heading">The Target Stack</h2>



<p class="wp-block-paragraph">The setup uses three containers managed by Docker Compose:</p>



<ul class="wp-block-list">
<li><strong>nginx</strong> — reverse proxy and static file server</li>
<li><strong>phpfpm</strong> — PHP-FPM process manager that executes WordPress PHP files</li>
<li><strong>mariadb</strong> — MySQL-compatible database server</li>
</ul>



<h2 class="wp-block-heading">docker-compose.yml</h2>



<p class="wp-block-paragraph">Below is the Docker Compose file that describes the three services. Note that the <code>wordpress</code> directory is bind-mounted into both the <code>nginx</code> and <code>phpfpm</code> containers so they share the same document root.</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">version: <span class="hljs-string">'3'</span>

<span class="hljs-attr">services</span>:
  nginx:
    image: nginx:latest
    <span class="hljs-attr">ports</span>:
      - <span class="hljs-string">"80:80"</span>
    <span class="hljs-attr">volumes</span>:
      - ./wordpress:<span class="hljs-regexp">/var/</span>www/html
      - ./config/nginx:<span class="hljs-regexp">/etc/</span>nginx/conf.d
      - ./logs/nginx:<span class="hljs-regexp">/var/</span>log/nginx
    <span class="hljs-attr">depends_on</span>:
      - phpfpm
    <span class="hljs-attr">restart</span>: always

  <span class="hljs-attr">mariadb</span>:
    image: mariadb:latest
    <span class="hljs-attr">ports</span>:
      - <span class="hljs-string">"3306:3306"</span>
    <span class="hljs-attr">volumes</span>:
      - ./data/db:<span class="hljs-regexp">/var/</span>lib/mysql
    <span class="hljs-attr">environment</span>:
      MYSQL_ROOT_PASSWORD: password
      <span class="hljs-attr">MYSQL_DATABASE</span>: wordpress
      <span class="hljs-attr">MYSQL_USER</span>: wordpress
      <span class="hljs-attr">MYSQL_PASSWORD</span>: password
    <span class="hljs-attr">restart</span>: always

  <span class="hljs-attr">phpfpm</span>:
    image: php:fpm
    <span class="hljs-attr">ports</span>:
      - <span class="hljs-string">"9000:9000"</span>
    <span class="hljs-attr">volumes</span>:
      - ./wordpress:<span class="hljs-regexp">/var/</span>www/html
    <span class="hljs-attr">depends_on</span>:
      - mariadb
    <span class="hljs-attr">restart</span>: always</code></span></pre>


<h2 class="wp-block-heading">Nginx wordpress.conf</h2>



<p class="wp-block-paragraph">Place the following file at <code>./config/nginx/wordpress.conf</code>. It passes all <code>.php</code> requests to the <code>phpfpm</code> container over FastCGI on port 9000, and uses the standard WordPress <code>try_files</code> rewrite rule.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">server {
    listen <span class="hljs-number">80</span>;
    server_name localhost;

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

    access_log /<span class="hljs-keyword">var</span>/log/nginx/access.log;
    error_log /<span class="hljs-keyword">var</span>/log/nginx/error.log;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =<span class="hljs-number">404</span>;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass phpfpm:<span class="hljs-number">9000</span>;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        <span class="hljs-keyword">include</span> fastcgi_params;
    }
}</code></span></pre>


<h2 class="wp-block-heading">The HTTP 500 Error During WordPress Setup</h2>



<p class="wp-block-paragraph">After running <code>docker-compose up</code> you can reach <code>http://127.0.0.1/wp-admin/setup-config.php</code> and start the WordPress installation. The first step loads fine. However, after submitting the database credentials form at step 1, the browser displays a blank page and the Nginx access log records a 500 response:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript"><span class="hljs-number">172.18</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> - - &#91;<span class="hljs-number">24</span>/Jun/<span class="hljs-number">2017</span>:<span class="hljs-number">07</span>:<span class="hljs-number">25</span>:<span class="hljs-number">54</span> +<span class="hljs-number">0000</span>] <span class="hljs-string">"POST /wp-admin/setup-config.php?step=2 HTTP/1.1"</span> <span class="hljs-number">500</span> <span class="hljs-number">5</span> <span class="hljs-string">"http://127.0.0.1/wp-admin/setup-config.php?step=1"</span> <span class="hljs-string">"Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"</span></code></span></pre>


<p class="wp-block-paragraph">No corresponding entry appears in the Nginx <em>error</em> log, which means Nginx itself completed the FastCGI transaction successfully — the 500 status was generated by PHP, not Nginx.</p>



<h2 class="wp-block-heading">Root Cause: Missing MySQL Extension in the Official php:fpm Image</h2>



<p class="wp-block-paragraph">The official <code>php:fpm</code> Docker image ships with a minimal set of PHP extensions. Critically, it does <strong>not</strong> include the <code>mysqli</code> or <code>pdo_mysql</code> extensions that WordPress requires to connect to a database. When WordPress&#8217;s setup wizard attempts to write <code>wp-config.php</code> and test the database connection, PHP throws a fatal error internally, resulting in the blank 500 response.</p>



<p class="wp-block-paragraph">Because PHP fatal errors at this stage are caught before WordPress&#8217;s error handler is fully initialised, no useful message reaches the browser or the Nginx error log. You may see something useful in the PHP-FPM log, which you can check with:</p>


<pre class="wp-block-code"><span><code class="hljs">docker-compose logs phpfpm</code></span></pre>


<h2 class="wp-block-heading">Fix 1: Build a Custom PHP-FPM Image with MySQL Extensions</h2>



<p class="wp-block-paragraph">Create a <code>Dockerfile</code> alongside your <code>docker-compose.yml</code> that extends the official image and installs the required extensions:</p>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">FROM</span> <span class="hljs-selector-tag">php</span><span class="hljs-selector-pseudo">:fpm</span>

<span class="hljs-selector-tag">RUN</span> <span class="hljs-selector-tag">docker-php-ext-install</span> <span class="hljs-selector-tag">mysqli</span> <span class="hljs-selector-tag">pdo</span> <span class="hljs-selector-tag">pdo_mysql</span></code></span></pre>


<p class="wp-block-paragraph">Then update the <code>phpfpm</code> service in your <code>docker-compose.yml</code> to build from this Dockerfile instead of pulling the image directly:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">  phpfpm:
    build: .
    ports:
      - <span class="hljs-string">"9000:9000"</span>
    <span class="hljs-attr">volumes</span>:
      - ./wordpress:<span class="hljs-regexp">/var/</span>www/html
    <span class="hljs-attr">depends_on</span>:
      - mariadb
    <span class="hljs-attr">restart</span>: always</code></span></pre>


<p class="wp-block-paragraph">Rebuild and restart the stack:</p>


<pre class="wp-block-code"><span><code class="hljs">docker-compose up --build</code></span></pre>


<h2 class="wp-block-heading">Fix 2: Use the Official wordpress:fpm Image</h2>



<p class="wp-block-paragraph">If you do not need a fully custom PHP build, the simplest alternative is to replace the <code>php:fpm</code> image with the official <code>wordpress:fpm</code> image. This image is purpose-built for WordPress and already includes <code>mysqli</code>, <code>pdo_mysql</code>, and other extensions WordPress depends on:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">  phpfpm:
    image: wordpress:fpm
    <span class="hljs-attr">ports</span>:
      - <span class="hljs-string">"9000:9000"</span>
    <span class="hljs-attr">volumes</span>:
      - ./wordpress:<span class="hljs-regexp">/var/</span>www/html
    <span class="hljs-attr">environment</span>:
      WORDPRESS_DB_HOST: mariadb:<span class="hljs-number">3306</span>
      <span class="hljs-attr">WORDPRESS_DB_NAME</span>: wordpress
      <span class="hljs-attr">WORDPRESS_DB_USER</span>: wordpress
      <span class="hljs-attr">WORDPRESS_DB_PASSWORD</span>: password
    <span class="hljs-attr">depends_on</span>:
      - mariadb
    <span class="hljs-attr">restart</span>: always</code></span></pre>


<p class="wp-block-paragraph">The <code>wordpress:fpm</code> image also auto-generates <code>wp-config.php</code> from the environment variables above, which eliminates the need to complete the setup wizard at all.</p>



<h2 class="wp-block-heading">Additional Troubleshooting Steps</h2>



<h3 class="wp-block-heading">Enable PHP Error Logging</h3>



<p class="wp-block-paragraph">Add the following to your custom Dockerfile or mount a custom <code>php.ini</code> to expose PHP errors during development:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">RUN echo <span class="hljs-string">"error_reporting = E_ALL"</span> &gt;&gt; <span class="hljs-regexp">/usr/</span>local/etc/php/php.ini \
 &amp;&amp; echo <span class="hljs-string">"display_errors = On"</span> &gt;&gt; <span class="hljs-regexp">/usr/</span>local/etc/php/php.ini \
 &amp;&amp; echo <span class="hljs-string">"log_errors = On"</span> &gt;&gt; <span class="hljs-regexp">/usr/</span>local/etc/php/php.ini</code></span></pre>


<p class="wp-block-paragraph">Never enable <code>display_errors</code> in a production environment.</p>



<h3 class="wp-block-heading">Verify Database Connectivity</h3>



<p class="wp-block-paragraph">WordPress must connect to the database using the <em>service name</em> as the hostname, not <code>localhost</code> or <code>127.0.0.1</code>. In the Docker Compose network, the correct hostname for the database is <code>mariadb</code> (matching the service name). Set the database host to <code>mariadb</code> in the WordPress setup wizard or in <code>wp-config.php</code>.</p>



<h3 class="wp-block-heading">Check File Permissions</h3>



<p class="wp-block-paragraph">WordPress needs write access to the document root to create <code>wp-config.php</code>. If the <code>./wordpress</code> directory on the host is owned by root or has restrictive permissions, the PHP-FPM process (which typically runs as <code>www-data</code>) cannot write the file, producing a 500 error. Fix ownership with:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">sudo chown -R <span class="hljs-number">33</span>:<span class="hljs-number">33</span> ./wordpress   <span class="hljs-comment"># 33 is the UID for www-data on Debian-based images</span></code></span></pre>


<h3 class="wp-block-heading">Timing: MariaDB May Not Be Ready</h3>



<p class="wp-block-paragraph">Docker Compose&#8217;s <code>depends_on</code> only waits for a container to <em>start</em>, not for the service inside it to be ready to accept connections. MariaDB can take several seconds to initialise on first run. If PHP-FPM tries to connect before MariaDB is ready, the connection will fail and WordPress will return a 500. Solutions include:</p>



<ul class="wp-block-list">
<li>Waiting a few seconds after <code>docker-compose up</code> before loading the setup wizard.</li>
<li>Using a health-check and <code>condition: service_healthy</code> in Compose v3.x+ to delay the phpfpm container until MariaDB is accepting connections.</li>
<li>Using a startup script with a <code>wait-for-it</code> or similar utility.</li>
</ul>



<h2 class="wp-block-heading">Summary</h2>



<p class="wp-block-paragraph">The HTTP 500 error during WordPress setup with a custom Docker Compose stack almost always traces back to one of three causes: missing PHP MySQL extensions in the <code>php:fpm</code> base image, using <code>localhost</code> instead of the MariaDB service name as the database host, or file permission problems on the WordPress directory. Installing <code>mysqli</code> and <code>pdo_mysql</code> via <code>docker-php-ext-install</code> — or switching to the official <code>wordpress:fpm</code> image — resolves the most common case.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/setup-local-wordpress-development-environment-with-docker-error-500/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
