Welcome to Centmin Mod Community
Become a Member

install many wordpress blogs

Discussion in 'Install & Upgrades or Pre-Install Questions' started by adamus007p, Jun 11, 2025.

  1. adamus007p

    adamus007p Member

    378
    19
    18
    Feb 8, 2019
    Ratings:
    +38
    Local Time:
    11:30 AM
    Hello @eva2000 is it possible to install via command line for example 30 new Wordpres blogs (diffrenet domains). Do not choose it from the menu but write 30 command lines with domains?

     
  2. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    7:30 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
  3. adamus007p

    adamus007p Member

    378
    19
    18
    Feb 8, 2019
    Ratings:
    +38
    Local Time:
    11:30 AM
    Thank you :)

    @eva2000 is there any tutorial regards migration from direct admin to centminmod?
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    7:30 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    None right now but you can read these to get an idea

    https://community.centminmod.com/threads/centmin-mod-site-data-migration-guide.10382/, which outlines Centmin Mod to Centmin Mod data transfers using tools and techniques that apply to any server move. This migration process I've been doing for decades, and the basic underlying tools and what they are used for are always the same for any server move even on non-centminmod servers :)
     
  5. adamus007p

    adamus007p Member

    378
    19
    18
    Feb 8, 2019
    Ratings:
    +38
    Local Time:
    11:30 AM
    I want to share with my script to create a multiple Wordpress domains/vhosts.


    Make sure you have expect installed (yum install expect / apt-get install expect).

    Copy the above code to wpnv_batch.sh.

    If you want to change any of the default "yes/no" or option numbers (SSL, cache, etc.), edit the "#1) Default settings" section at the beginning.

    If your domain list changes, add/remove entries in the set domains { … } block.


    Code (Text):
    touch wpnv_batch.sh
    chmod +x wpnv_batch.sh
    ./wpnv_batch.sh



    Give the script execute permissions and run it:

    Code (Text):
    #!/bin/expect -f
    #
    # wpnv_batch.sh — batch “Add WordPress Nginx vhost + Cache Plugin”
    # Centmin Mod 131.00stable
    
    set timeout -1
    #exp_internal 1 ;# enable to see full debug
    
    # ---------- 1) Default values ----------
    set ssl_self_signed "y"
    set ssl_letsencrypt "y"
    set ssl_option "4"
    set install_theme "n"
    set install_classic "y"
    set install_autoptimize "y"
    set install_lazyload "y"
    set custom_admin_display "y"
    set admin_display_name "admin3211"
    set install_subdir_blog "n"
    set disable_auto_wp "n"
    set disable_wp_login "n"
    set admin_email "admin@domain.com"
    set cache_option "1"
    set generate_ftp_pass "y"
    set exclude_mobile "y"
    
    # ---------- 2) Domains ----------
    set domains {
    domain1.com
    domain2.com
    domain3.com
    }
    
    # ---------- 3) Loop ----------
    foreach domain $domains {
    
    set ftp_user [string map {"." ""} $domain]
    append ftp_user "user"
    
    spawn centmin
    
    expect -re {Enter option.*} { send "22\r" }
    expect -re {continue with Nginx vhost site creation.*\[y/n\]} { send "y\r" }
    expect -re {domain name you want to add.*:} { send "$domain\r" }
    expect -re {self-signed SSL certificate.*\[y/n\]} { send "$ssl_self_signed\r" }
    expect -re {Letsencrypt SSL certificate.*\[y/n\]} { send "$ssl_letsencrypt\r" }
    expect -re {Enter option number 1-4:} { send "$ssl_option\r" }
    
    expect -re {Install CyberChimps Responsive Theme.*\[y/n\]} { send "$install_theme\r" }
    expect -re {Install Classic Editor Wordpress Plugin.*\[y/n\]} { send "$install_classic\r" }
    expect -re {Autoptimize Gzip Companion Wordpress Plugin.*\[y/n\]} { send "$install_autoptimize\r" }
    expect -re {Google Native LazyLoad Plugin.*\[y/n\]} { send "$install_lazyload\r" }
    
    expect -re {Set custom WP Admin Display Name.*\[y/n\]} { send "$custom_admin_display\r" }
    if {$custom_admin_display == "y"} {
    expect -re {Enter Custom WP Admin Display Name.*:} { send "$admin_display_name\r" }
    }
    
    expect -re {/blog.*\[y/n\]:} { send "$install_subdir_blog\r" }
    
    expect -re {Disable Auto Generated WP Admin Username.*\[y/n\]} { send "$disable_auto_wp\r" }
    expect -re {Disable wp-login\.php password protection.*\[y/n\]} { send "$disable_wp_login\r" }
    expect -re {email address for Admin User.*:} { send "$admin_email\r" }
    
    expect -re {Enter option\s*\[\s*1\s*-\s*3\s*\]} { send "$cache_option\r" }
    
    # --- FTP: support both prompt variants ---
    expect {
    -re {Enter option.*} {
    send "1\r"
    exp_continue
    }
    -re {Create FTP username for vhost domain.*:} {
    send "$ftp_user\r"
    }
    }
    
    expect -re {auto generate FTP password.*\[y/n\]} { send "$generate_ftp_pass\r" }
    expect -re {exclude mobile/tablet devices.*\[y/n\]} { send "$exclude_mobile\r" }
    
    # ---------- RETURN TO MENU & EXIT ----------
    expect -re {Enter option\s*\[\s*1\s*-\s*24\s*\]} { send "24\r" }
    
    # only now the centmin process ends
    expect eof
    }
    
    puts "\nAll domains processed."



    Please write if you have any feedbacks or tweaks. This is my first script.
     
    Last edited: Jun 14, 2025