• I recently heard about WP-CLI and attempted to install it onto my host. It turns out that because my plan is a “shared server” plan, I can’t use the sudo or mv cli commands.

    I can navigate to /usr/local/bin but cannot mkir wp.

    Does anyone have suggestions for an alternate path and directory?

    Thank you,

    Tod

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi. I believe you can use WP-CLI without sudo, and you don’t need to place it under /usr/local/bin/. You could, for example, place it in the home directory of your user, if your user is foo, this would be /home/foo/.

    Once you transferred the wp-cli.phar file to your server, you can move it to your home directory:

    mv wp-cli.phar /home/foo/

    WP-CLI’s docs recommends you rename the file to just wp:

    cd /home/foo
    mv wp-cli.phar wp

    You then need to make the file executable:

    chmod +x wp

    Once this is done, you can run WP-cli from any directory as follows:

    cd path-to-your-wordpress-site
    ./home/foo/wp --info
    • This reply was modified 3 years, 6 months ago by Paulo Pinto. Reason: Improve formatting
    • This reply was modified 3 years, 6 months ago by Paulo Pinto. Reason: Improve formatting

    Normally you can create a bin in your home account

    e.g. /home/myaccount/bin

    hopefully when you echo $PATH ~/bin is on your path

    if not you can add it to your path in .profile

    export PATH="$HOME/bin:$PATH"

    and reload your profile ( e.g. source .profile )

    Thread Starter todindiana

    (@todindiana)

    @alanfuller : Thanks for your input. I’ll keep your advice on hand.

    @psrpinto : Thanks for your detailed help. I am okay up to the wp –info command.

    My path is /home/crucl. The wp-cli is installed in that directory. I was successful at changing its name to “wp” as well as the chmod command.

    When I type in wp –info in its directory, I get “command not found”. If I’m in another directory and type cd ./home/crucl/wp –info, I get the same error.

    ?????♂?

    Note: unfortunately my server’s Terminal window doesn’t allow me to highlight and copy.

    You can see a screen grab here:

    Btw try shift-ctl-c ( or shift-cmd-c on mac )

    For copy and shift-ctl-v for paste

    To execute a program (that is not on your $PATH), you need to prefix it with ./, so you can execute wp as follows:

    ./wp --info

    Thread Starter todindiana

    (@todindiana)

    @alanfuller Thanks. Unfortunately I’m working with an iPad without a BT keyboard.

    Thread Starter todindiana

    (@todindiana)

    @psrpinto Thanks for that. I’ve gone through that stp but unfortunately I’m stuck when it comes to executing a wp-cli command

    I’m in my blog’s directoy:

    todw.us $ wp plugin status
    bash: wp: command not found

    That command is listed in the list of commands, so I’m at a loss.

    Tod

    Not sure if that helps, but to run WP from command line you might need to run if using php,i.e.:

    /usr/local/bin/php /usr/local/bin/wp

    My problem was the reverse, I own a server and I wanted as root to run WP sudoing the user account so files didn′t get the wrong ownership.

    I created a .bash_aliases like:

    function wp () {
    userwp=/usr/bin/stat -c "%U" .
    sudo -u “$userwp” — /usr/local/bin/php /usr/local/bin/wp $@;
    }

    so now I can run WP when I′m on a WordPress installation and run any WP-CLI command

    Thread Starter todindiana

    (@todindiana)

    @ibertrix

    I’m sorry for the late reply.

    Thank you for your point of view. It looks interesting. I’ll experiment with it soon.

    Cheers,

    Tod

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WP-CLI – use on host’s shared server possible?’ is closed to new replies.