• I want to install wordpress using shell script, idea is like a one click installer, where I need to create automatically create database with username and password and also admin login and password. I found wp-cli as the best practice.

    I used as per the direction as mentioned in the website https://wp-cli.org/ and till completing.

    After that I am not sure how to proceed need guidance.

    vijey,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Would suggest referring to this page for the available commands you can use via WP-CLI to develop your script:

    https://developer.ww.wp.xz.cn/cli/commands/

    Thread Starter raghavan2004

    (@raghavan2004)

    Hi Karolinapan,

    Thanks for the link.. Will check and getback.
    I have a basic doubt. Will this work with bash script in ubuntu shellscript

    Regards,

    Vijey

    Hi @raghavan2004, WP-CLI can indeed be used inside a bash script. Here’s an example:

    #!/usr/bin/env bash
    
    # Output the WP-CLI version.
    wp --version
    Thread Starter raghavan2004

    (@raghavan2004)

    Hi thanks for the update, I write the code as below,
    I created a directory inside html folder and then created a file wp-install.sh. pasted the below code and my wp-cli is working correctly and got the message successfull. I am trying to generate the username, password for the admin automatically and then the DB username and password is hardcoded. I am trying to create a one step installer, where the entire wordpress is setup including the username password and the db and also installed the plugin as mentioned below.

    <code>
    #!/bin/bash curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar php wp-cli.phar --info chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp wp cli update # Variables # Download and extract WordPress # Get the parent directory of the current working directory # sub_dir=$(dirname "$PWD") # Get the name of the parent directory # parent_dir=$(basename "$sub_dir") wp_domain="$(dirname $PWD)" # read -rp "{WP_DOMAIN}"; wp_title="My WordPress Site" db_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9+*$@#' | fold -w 10 | head -n 1) # DB_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9+*$@#' | fold -w 10 | head -n 1) # DB_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9+*$@#' | fold -w 10 | head -n 1) db_user="sammy" db_pass="password" admin_email="[email protected]" DB_HOST="localhost" # WP_DOMAIN="example.com" WP_TITLE="My WordPress Site" wp_admin_user=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9+*$@#' | fold -w 10 | head -n 1) wp_admin_pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9+*$@#' | fold -w 10 | head -n 1) DB_COLLATE="utf8mb4_unicode_ci" # Define WordPress site credentials # Download WordPress core files wp core download --locale=en_US # Create wp-config.php file wp config create --dbname=$db_name --dbuser=$db_user --dbpass=$db_pass # Install WordPress wp core install --url=$wp_domain --title="$wp_title" --admin_user=$wp_admin_user --admin_password=$wp_admin_pass --admin_email=$admin_email # Update WordPress permalink structure wp rewrite structure '/%postname%/' # Install default WordPress theme and plugins wp theme install twentysixteen --activate wp plugin install akismet --activate wp plugin install jetpack --activate
    </code>

    Attached the link for the screenshot

    https://prnt.sc/foz0qwJiu1BF

    • This reply was modified 1 year, 1 month ago by raghavan2004.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Regarding wp-cli’ is closed to new replies.