f w h

Quickly Set Up a Local WordPress (Linux)

I do a lot of work on WordPress, so I find myself downloading the latest copy and setting it up fairly often. It helps to have simple scripts to do these things.

The concept here is to create a shell script that downloads and extracts WordPress to the current folder. We also want to be able to run the script from any folder.

Set the Stage

First, in your home folder, create a new folder called bin. Inside that folder, create a new blank file called wordpress.sh.

Add the Script

Inside the file you just created, add the following script:


sudo wget http://wordpress.org/latest
sudo tar -xvzf latest*
cd wordpress
sudo cp -R * ..
cd ..
sudo rm -rf wordpress/
sudo rm -rf latest*

Save the script, then make it executable by opening your terminal, navigating to ~/bin and running the following command:

sudo chmod -x wordpress.sh

Run the Script from Anywhere

Now, we just need to add the script to the path so we can execute it from anywhere. Run the following command:

export PATH=$PATH:$HOME/bin && echo 'export PATH=$PATH:$HOME/bin >> ~/.bash_profile'

Run the Script

Create a new folder, navigate to it in the terminal and type wordpress.sh. The script will download and extract the latest version of WordPress for you.

What’s Next?

I personally use PHP’s built in server along with a custom domain to develop, so I’ll run sudo php -S roe.dev:80, then go to http://roe.dev in my browser. One could add that line to the shell script just to make the process that much smoother.