Install WordPress from the OSX Terminal

This little snippet comes handy to install the latest version of WordPress quickly from the terminal. Drop the function on your /Username/.bash_profile and then simply call wp_install from the directory you want to install it.

wp_install() {
        curl -O $latest
        rm -rf __MACOSX
        cp -rf ./wordpress/* ./
        rm -rf ./wordpress/
        mkdir ./wp-content/uploads/
        mv wp-config-sample.php wp-config.php
        touch .htaccess
        mate wp-config.php
# Note: If you are not a TextMate owner, change the line:
# mate wp-config.php
# to
# vi wp-config.php

Feel free to fork it at GitHub.

Reactions (5)

  1. I am trying to make this work in my web server, but as expected mate and open are not working.

    How can I change this to work ?

    I do have textmate, but it seems the command will not work in a web server.

    I already have the sh file and wordpress installs, but I want it to work as locally in Mac OS X.

    Any advice ?

  2. Sorry to add in another comment, you can mix them.

    Also in github there are more lines.

    vhosts() {
    mate /etc/hosts
    mate /etc/apache2/extra/httpd-vhosts.conf

    Are those needed locally or for web server ? Because WordPress installs fine without them.


  3. Hi Peter,

    Unfortunately I haven’t test if it works on remote server as it is. A solution could be to mount the system with MacFUSE or any similar SSHFS application. You can then navigate the system as if it’s a local directory with the great addition that you have access to all your local tools.

    The vhosts() line is just a simple function to quickly open the current user Virtual Hosts files. It’s actually opening two file located on the /etc/ folder. These are the ones you need to modify if you want to add virtual domains for local developing.

  4. Well its working in my server now and I can install WordPress in any domain I want using the Terminal.

    I just wanted to have the mate and open commands working.


    • That is great news then! Have you added the script to your server’s user profile?