I am trying to make installations easier on my Mac using MAMP by using WP-CLI.

I made a simple .sh file:

wp core download
wp core config --dbname=dbname --dbuser=root --dbpass=root
wp db create
wp core install --url="http://localhost:8888/folder" --title="name" --admin_user="admin" --admin_password="password" --admin_email="[email protected]"

This works fine when I enter it line by line in the terminal, however as soon as I turn it into a .sh file and run it through sh install.sh, it stops as soon as the database is created, but doesn't actually install Wordpress into the database.

What could cause this? This is the wp --info output:

PHP binary: /Applications/MAMP/bin/php/php7.1.0/bin/php
PHP version:    7.1.0
php.ini used:   /Applications/MAMP/bin/php/php7.1.0/conf/php.ini
WP-CLI root dir:    phar://wp-cli.phar
WP-CLI packages dir:    
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 1.0.0

3 Answers 3


The reason is because the cron script's environment has minimal configuration. When you as a user log into your system, additional environment variable are set which allow you to execute programs without explicitly defining the full path.

The best way to fix this is to define the full path to your program(s) in your cron script. This is generally best practice even for system calls. For example if your wp resides in /usr/local/bin, modify your cron script:

/usr/local/bin/wp core download
/usr/local/bin/wp core config --dbname=dbname --dbuser=root --dbpass=root
/usr/local/bin/wp db create
/usr/local/bin/wp core install --url="http://localhost:8888/folder" --title="name" --    admin_user="admin" --admin_password="password" --admin_email="[email protected]"

I had a similar problem using WSL. The problem was that I had created the .sh script under Windows, so it had Windows style line ending (CR LF) instead of just LF.

Changing the line endings to LF fixed it for me.


I have created a bash script to install wordpress.

This script will automate the following:

Downlaod and install Wordpress automatically Create Default Users with passwords Install all default plugins Install the default or custom theme by zip url you mostly used. You can find script on github.com


  • 1
    Page not found.
    – leymannx
    Commented May 14, 2019 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.