<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Diego A. Carrasco Gubernatis | Personal Website (Posts about wp-cli)</title><link>https://diegocarrasco.com/</link><description></description><atom:link href="https://diegocarrasco.com/categories/wp-cli.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:hi@diegocarrasco.com"&gt;Diego Carrasco G.&lt;/a&gt; </copyright><lastBuildDate>Wed, 11 Nov 2026 09:05:15 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Quick and simple Local WordPress Setup for Lazy Developers</title><link>https://diegocarrasco.com/simple-docker-compose-wordpress-setup/</link><dc:creator>Diego Carrasco G.</dc:creator><description>&lt;figure&gt;&lt;img src="https://diegocarrasco.com/images/social-images/simple-docker-compose-wordpress-setup.jpg"&gt;&lt;/figure&gt; &lt;h3 id="quick-and-simple-wordpress-setup-for-lazy-developers"&gt;Quick and simple WordPress Setup for Lazy Developers&lt;/h3&gt;
&lt;p&gt;I needed a fast way to set up WordPress locally. I tried various methods, but they were either too complex or didn't work. So, I created a simple, lazy solution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is by no way secure, but it runs on the first try 😁&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The code is in this GitHub repository. Feel free to use it.&lt;/p&gt;
&lt;p&gt;
    &lt;/p&gt;&lt;div class="github-widget" style="max-width: 100%;"&gt;
        &lt;div class="github-widget-image"&gt;
            &lt;a href="https://github.com/dacog/lazy-docker-compose-wordpress-setup" target="_blank"&gt;
                &lt;img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" alt="NamedUser(login=" dacog max-width="50" max-height="50"&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="repo-info"&gt;
            &lt;a href="https://github.com/dacog/lazy-docker-compose-wordpress-setup" target="_blank"&gt;
                &lt;h4&gt;lazy-docker-compose-wordpress-setup&lt;/h4&gt;
            &lt;/a&gt;
            &lt;p&gt;Set up a local WordPress development environment easily with Docker Compose using this repository. One command sets up WordPress with WP-CLI, MariaDB, and PHPMyAdmin, plus autogenerated aliases for quick management. A second command sources these aliases. Perfect for quick, lazy local development. Not secure for production use.&lt;/p&gt;
            &lt;p&gt;&lt;strong&gt;Languages:&lt;/strong&gt; Shell&lt;/p&gt;
            &lt;ul&gt;
                &lt;li&gt;⭐ Stars: 0&lt;/li&gt;
                &lt;li&gt;&lt;svg aria-hidden="true" height="16" viewbox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch UnderlineNav-octicon"&gt;
    &lt;path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"&gt;&lt;/path&gt;
&lt;/svg&gt; Forks: 0&lt;/li&gt;
                &lt;li&gt;👁 Watchers: 1&lt;/li&gt;
                &lt;li&gt;❗ Open Issues: 0&lt;/li&gt;
            &lt;/ul&gt;
            
        &lt;/div&gt;
    &lt;/div&gt;
    
&lt;h3 id="how-it-works"&gt;How It Works&lt;/h3&gt;
&lt;p&gt;This setup revolves around 4 files:&lt;/p&gt;
&lt;h4 id="1-docker-composeyml"&gt;1 &lt;strong&gt;&lt;code&gt;docker-compose.yml&lt;/code&gt;&lt;/strong&gt;:&lt;/h4&gt;
&lt;p&gt;This file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Uses the latest official containers for WordPress, MariaDB, PHPMyAdmin, and WP-CLI.&lt;/li&gt;
&lt;li&gt;Sets up a &lt;code&gt;wordpress&lt;/code&gt; database with user and password &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Launches a WordPress instance linked to the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="2-setupsh"&gt;2 &lt;strong&gt;&lt;code&gt;setup.sh&lt;/code&gt;&lt;/strong&gt;:&lt;/h4&gt;
&lt;p&gt;This script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Detects whether you have &lt;code&gt;docker-compose&lt;/code&gt; or &lt;code&gt;docker compose&lt;/code&gt; and uses the correct one.&lt;/li&gt;
&lt;li&gt;Sets your UID and GID in a &lt;code&gt;.env&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Generates an alias file for quick commands.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="3-startsh"&gt;3 &lt;strong&gt;&lt;code&gt;start.sh&lt;/code&gt;&lt;/strong&gt;:&lt;/h4&gt;
&lt;p&gt;This script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Creates the WordPress directory.&lt;/li&gt;
&lt;li&gt;Sets permissions to 777 (yes, it's insecure).&lt;/li&gt;
&lt;li&gt;Starts Docker Compose.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="4-aliassh"&gt;4 &lt;strong&gt;&lt;code&gt;alias.sh&lt;/code&gt;&lt;/strong&gt;:&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Autogenerated&lt;/strong&gt; by &lt;code&gt;setup.sh&lt;/code&gt; or &lt;code&gt;start.sh&lt;/code&gt;. Source it to get these aliases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dc&lt;/code&gt;: Docker Compose commands.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;wpcli&lt;/code&gt;: WP-CLI commands.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;wpbackup&lt;/code&gt;: Backs up the database to &lt;code&gt;./backups&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;wpdown&lt;/code&gt;: Backs up and then stops and removes containers and volumes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="how-to-use"&gt;How to Use&lt;/h3&gt;
&lt;p&gt;First you need to clone the repository:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;git&lt;span class="w"&gt; &lt;/span&gt;clone&lt;span class="w"&gt; &lt;/span&gt;https://github.com/dacog/lazy-docker-compose-wordpress-setup.git
&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;lazy-docker-compose-wordpress-setup
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Run these commands to get started:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;+x&lt;span class="w"&gt; &lt;/span&gt;setup.sh
chmod&lt;span class="w"&gt; &lt;/span&gt;+x&lt;span class="w"&gt; &lt;/span&gt;start.sh
./start.sh
&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;alias.sh
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now you are good to go. You will see a new folder &lt;code&gt;wordpress&lt;/code&gt; is created in the path you were in. &lt;/p&gt;
&lt;p&gt;Now you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check http://localhost:8000 for the WordPress site&lt;/li&gt;
&lt;li&gt;Check http://localhost:8080 for PHPMyAdmin. User and password is root&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You receive this information also when you run &lt;code&gt;start.sh&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="using-the-aliases"&gt;Using the Aliases&lt;/h3&gt;
&lt;h4 id="alias-dc"&gt;alias &lt;code&gt;dc&lt;/code&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Bring up the services:  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dc&lt;span class="w"&gt; &lt;/span&gt;up&lt;span class="w"&gt; &lt;/span&gt;-d
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Stop the services:  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dc&lt;span class="w"&gt; &lt;/span&gt;down
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Stop and remove volumes:  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dc&lt;span class="w"&gt; &lt;/span&gt;down&lt;span class="w"&gt; &lt;/span&gt;-v
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;View the status of the services:  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dc&lt;span class="w"&gt; &lt;/span&gt;ps
&lt;/pre&gt;&lt;/div&gt;

&lt;h4 id="alias-wpcli"&gt;alias &lt;code&gt;wpcli&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Run WP-CLI as root (it includes &lt;code&gt;--allow-root&lt;/code&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Check WordPress version:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpcli&lt;span class="w"&gt; &lt;/span&gt;core&lt;span class="w"&gt; &lt;/span&gt;version
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Install a plugin:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpcli&lt;span class="w"&gt; &lt;/span&gt;plugin&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;hello-dolly&lt;span class="w"&gt; &lt;/span&gt;--activate
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Update WordPress core:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpcli&lt;span class="w"&gt; &lt;/span&gt;core&lt;span class="w"&gt; &lt;/span&gt;update
&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Create a new post:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpcli&lt;span class="w"&gt; &lt;/span&gt;post&lt;span class="w"&gt; &lt;/span&gt;create&lt;span class="w"&gt; &lt;/span&gt;--post_title&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'My New Post'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--post_content&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'This is the content of the post.'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--post_status&lt;span class="o"&gt;=&lt;/span&gt;publish
&lt;/pre&gt;&lt;/div&gt;

&lt;h4 id="wpbackup"&gt;&lt;code&gt;wpbackup&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Back up the database to &lt;code&gt;./backups&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpbackup
&lt;/pre&gt;&lt;/div&gt;

&lt;h4 id="wpdown"&gt;&lt;code&gt;wpdown&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Back up the database and files, then stop and remove everything:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;wpdown
&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id="alternatives"&gt;Alternatives&lt;/h3&gt;
&lt;p&gt;Here are some other methods to consider:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://localwp.com/"&gt;Local by Flywheel&lt;/a&gt;&lt;/strong&gt;: User-friendly local WordPress setup with advanced features. To be fair, I completely forgot about this when I was trying to get WordPress to run locally. This is way more powerful, but you need many clicks... and you need to fill a form to download it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://kinsta.com/de/devkinsta/"&gt;DevKinsta&lt;/a&gt;&lt;/strong&gt;: Offers local development with easy deployment to Kinsta hosting. I haven't tried this one.&lt;/li&gt;
&lt;/ol&gt;</description><category>bash</category><category>development</category><category>docker</category><category>docker-compose</category><category>local workspace</category><category>php</category><category>terminal</category><category>wordpress</category><category>wp-cli</category><guid>simple-docker-compose-wordpress-setup</guid><pubDate>Tue, 25 Jun 2024 06:00:00 GMT</pubDate></item></channel></rss>