/* */ Februar 2019 – Blog Gebert iT – Home

WordPress mit wp-cli automatisch in 3 Minuten auf eurem Webspace installieren

Mit diesem Script installiert ihr WordPress mit euren Plugins völlig automatisch und bereinigt es von den Beispiel Einträgen. Ihr müsst lediglich vorher eure Daten eintragen, eventuell eure eigenen Plugins hinzufügen. Einfach das Script in euer Root Verzeichnis mit dem ihr Zugriff über den Browser habt, kopieren. Mit ssh auf euren Wepspace (Hoster) einloggen und per sh Scriptname das Script aufrufen.

Das folgende ist nicht notwendig, aber eine zusätzliche Möglichkeit eure Plugins automatisch zu installieren.
Ihr könnt mit Hilfe eines login.wordpress.org Konto eure Plugins favorisieren, indem ihr auf das Herz klickt.

Im Abschnitt WordPress.org Konto einfach euren Benutzernamen eintragen.

Was kann das Script?

    Vollkommen automatisch WordPress installieren
  • WordPress in eine vorhandenen Datenbank mit eigenem Tabellen Prefix installieren
  • Leere Seiten mit Überschrift erstellen
  • Eigenes Menü erstellen
  • Kategorien und Schlagwörter anlegen
  • Statische Seite oder Beiträge anzeigen
  • WordPress.org Favoriten Plugins automatisch installieren
  • Automatisch wp-cli installieren, falls noch nicht vorhanden
  • Ordner Eingabe abfragen, indem WordPress installiert werden soll
  • Abfragen ob SSL genutzt wird
  • Alle Themen löschen, außer die aktive
  • Medien in einem Ordner ablegen
  • Untertitel der Seite benennen
  • Standard Beitrag löschen
  • Unnütze Standard Plugins deinstallieren
  • Eigene Plugins installieren
  • Permalinks ändern
  • Automatisch eine WordPress .htaccess Datei erstellen, wird für die Permalinks benötigt
  • Suchmaschinen Index ein oder ausschalten
  • Automatisch eine Impressum Seite erstellen
  • Sicherheitskey von der wp-config automatisch ändern
  • Andere nützliche wp Befehle sind im Script dokumentiert
  • Hier ist das Script. Viel Spaß damit

    [bash]
    #!/bin/bash
    # Info https://developer.wordpress.org/cli/commands/
    # Info https://comlounge.net/wordpress-kommandozeile-wp-cli/
    # Info https://wp-cli.org/de/

    #######################################################
    # #
    # Bitte eure Daten eintragen: #
    # #
    #######################################################
    #
    # Bitte deine Webseite genau wie im Beispiel angeben
    # Beispiel: gebert.it/ oder www.gebert.it/
    web=gebert.it/
    #
    #
    #######################################################
    # #
    # Server Daten von eurem Hoster #
    # #
    #######################################################
    #
    ### Datenbank Name ###
    dbname=datenbank
    ### Benutzer Name Datenbank ###
    dbuser=benutzer
    ### Passwort Datenbank ###
    dbpass=pw
    ### Datenbank Host ###
    dbhost=host.de
    #
    #
    #######################################################
    # #
    # WordPress Daten #
    # #
    #######################################################
    #
    ### WordPress Benutzer Name ###
    wpuser=admin
    ### WordPress Passwort ###
    wppass=geheim
    ### E-Mail für WordPress ###
    wpmail=email
    ### Seiten Name ###
    sitename="Meine Seite"
    ### Seite Home und IMPRESSUM wird automatisch erstellt. Nicht in mypages schreiben ###
    ### Soll kein Menü erstellt werden, mypages mit # auskommentieren ###
    mypages=News,"Über Uns"
    ### Meine Kategorien und Schlagwörter erstellen ###
    category=Internet,Hardware,Software,Android,macOS,Linux,Windows,Programme,Apps,Sicherheit,WordPress
    ### Als Beiträge (ja) oder statische Seite (nein) die Startseite anzeigen? ###
    my_blog=ja
    #
    #
    #######################################################
    # #
    # WordPress.org Konto für Favoriten Plugins #
    # #
    #######################################################
    #
    ### Plugins von login.WordPress.org konto installieren ###
    # Benutzer von WordPress.org eintragen – Nicht unbedingt nötig #
    wordpressuser=
    #
    #
    #######################################################
    # #
    # Ab hier nichts ändern #
    # #
    #######################################################

    type clear >/dev/null 2>&1 && clear
    RED=’\033[0;31m’
    YEL=’\033[1;33m’
    CY=’\033[0;36m’
    NC=’\033[0m’

    printf "${RED}"
    echo " ====================================================================================="
    echo ""
    echo " wp cli WordPress Installer Script, by Gebert it Consult"
    echo ""
    echo " ====================================================================================="
    echo ""
    echo ""
    printf "${CY}"
    echo " ====================================================================================="
    echo ""
    echo " Das Script muss in dem Hauptordner von eurer Domain gelegt"
    echo " werden, der vom Browser erreichbar ist."
    echo " Eure Seite lautet z.b. http://www.gebert.it/ und das Script"
    echo " fragt euch, in welchem Ordner WordPress installiert werden soll."
    printf " Die URL schaut dann so aus: ${YEL} http://www.gebert.it/EUER_ORDNER_EINFGABE"
    echo ""
    printf "${RED} Achtung: Am Ende des Script wird gefragt ob die Webseite auf https (SSL) läuft."
    printf "${CY}"
    echo ""
    echo ""
    echo " ====================================================================================="
    printf "${NC}"
    echo ""

    echo " Ist wp-cli installiert?"
    # Es wird überprüft ob wp-cli installiert ist, wenn nicht, wird es installiert
    test -x wp >/dev/null 2>&1 && echo " wp ist installiert" ||
    {
    echo " wp-cli wird installiert, bitte warten"
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar >/dev/null 2>&1
    mv wp-cli-nightly.phar wp
    chmod 555 wp
    php -d memory_limit=512M wp package install anhskohbo/wp-cli-themecheck >/dev/null 2>&1
    # Sicherheitstest wp wp-sec check
    php -d memory_limit=512M wp package install markri/wp-sec >/dev/null 2>&1
    # Favoriten anzeigen wp plugin favorites matt –verbose
    php -d memory_limit=512M wp package install mikedance/wp-cli-favorite-plugins >/dev/null 2>&1
    }
    export PATH="$PATH:$(pwd)/"

    # Ordner Abfragen indem WordPress entpackt werden soll
    echo ""
    printf "${YEL} Bitte den Ordner angeben in dem WordPress installiert werden soll."
    printf "${YEL} Der Ordner wird automatisch erstellt."
    echo ""
    printf "${RED} Nur den Ordner Namen angeben, keinen Pfad: ${NC}"
    read apwd
    test -d $apwd && printf "${RED} Ordner ist vorhanden!! Script neu starten. ${NC}""" && echo "" && exit || mkdir $apwd
    cd $apwd
    echo ""
    echo ""

    # Aktuellen Ordner Namen ermitteln
    apwd=${PWD##*/}

    printf "${YEL} WordPress Seite:${NC}"
    echo ""
    echo " Webseite: http://$web$apwd/"
    echo ""
    printf "${YEL} Server Daten:${NC}"
    echo ""
    echo " Datenbank: $dbname"
    echo " Benutzer: $dbuser"
    echo " Passwort: $dbpass"
    echo " Host: $dbhost"
    echo ""
    printf "${YEL} WordPress Daten:${NC}"
    echo ""
    echo " Benutzer: $wpuser"
    echo " Passwort: $wppass"
    echo " E-Mail: $wpmail"
    echo ""
    printf "${YEL} Die https (SSL) Frage kommt noch. ${NC}"
    echo ""
    echo ""

    # Abfrage ob alle Daten richtig eingegeben wurden
    printf "${RED} Is das so ok? (J/n)"
    read nein
    if [ "$nein" = "n" ];
    then
    echo " Bitte die Daten richtig eingeben." && printf "${NC}" && exit
    else
    printf "${NC}"
    echo ""
    fi

    # Deutsches WordPress download
    wp core download –locale=de_DE
    # Englisches WordPress download
    # wp core download

    # wp-config table_prefix ändern auf Ordner Namen
    p1=_wp_
    mid=$(LC_CTYPE=C tr -dc 0-9 < /dev/urandom | head -c 3)
    prefix=$apwd$mid$p1
    # sed -i "s/^\$table_prefix \= .*/\$table_prefix \= ‘$prefix’/1" $(pwd)/wp-config.php
    # cat $(pwd)/wp-config.php

    # wp-config wird mit den benötigten Daten erstellt
    wp core config –dbhost="$dbhost" –dbuser="$dbuser" –dbpass="$dbpass" –dbname="$dbname" –extra-php <<PHP
    define( ‘WP_DEBUG’, true );
    define( ‘SAVEQUERIES’, true );
    define( ‘DISALLOW_FILE_EDIT’, true );
    define( ‘WP_MEMORY_LIMIT’, ’64M’ );
    \$table_prefix = ‘$prefix’;
    PHP
    echo " wp-config wurde erstellt"

    #define( ‘WP_SITEURL’, ‘http://$web$apwd’ );
    #define( ‘WP_HOME’, ‘http://$web$apwd/’ );
    #define( ‘RELOCATE’, true );

    # Sicherheitskey in wp-config automatisch neu generieren
    wp config shuffle-salts

    # Doppelten $table_prefix Eintrag aus wp-config löschen
    # macOS Syntax
    # sed -i ” "s/^\$table_prefix \= ‘wp_’\;//1" $(pwd)/wp-config.php
    # Linux Syntax
    sed -i "s/^\$table_prefix \= ‘wp_’\;//1" $(pwd)/wp-config.php

    # WordPress Datenbank wird installiert
    echo " WordPress Datenbank wird installiert"
    wp core update-db >/dev/null 2>&1

    # WordPress Benutzerdaten automatisch eintragen
    echo " Die Benutzerdaten für WordPress werden automatisch eingetragen"
    wp core install –url="$web" –title="$sitename" –admin_user="$wpuser" –admin_password="$wppass" –admin_email="$wpmail" –skip-email

    # Abfrage ob dieses Seite auf SSL läuft
    echo " Aktuelle Webseite URL:"
    wp option get siteurl
    printf "${RED} Habt ihr https:// (SSL)? (J/n) ${NC}"
    read nein2
    if [ "$nein2" = "n" ];
    then
    wp option update siteurl http://$web$apwd
    wp option update home http://$web$apwd
    else
    wp option update siteurl https://$web$apwd
    wp option update home http://$web$apwd
    fi
    echo ""
    echo " Webseiten URL wurde angepasst"
    echo ""
    printf "${YEL}"
    echo ""
    echo "================================================================="
    echo ""
    echo " WordPress wird installiert und konfiguriert"
    echo ""
    echo "================================================================="
    printf "${NC}"
    echo ""
    echo ""

    # Deutsche Sprache installieren
    # echo " Deutsche Sprache wird installiert"
    # wp language core install de_DE

    echo " Theme Sprachpaket update wird installiert"
    wp language theme update de_DE

    # Deutsche Sprache aktivieren
    # wp site switch-language de_DE

    # Untertitel der Seite ändern
    wp option update blogdescription "Ein Blog der anderen Art"

    # Medien in einem Ordner
    wp option update uploads_use_yearmonth_folders 0

    # Kommentare müssen genehmigt werden
    wp option update comment_moderation 1

    # Standard Beitrag löschen
    wp post delete 1 –force

    # Permalinks auf Beitragsname ändern
    wp rewrite structure ‘/%postname%/’ –hard
    echo " Warning ist gefixed mit der .htaccess am Ende"
    wp rewrite flush –hard
    echo " Warning ist gefixed mit der .htaccess am Ende"

    # Standard Themen löschen
    wp theme list –status=inactive –field=name | while read THEME; do wp theme delete $THEME; done;

    # Beispiel Seite löschen
    wp post delete 2 –force

    # Datenschutz Seite löschen
    wp post delete 3 –force

    # Suchmaschinen indexieren zulassen und einschalten
    wp option update blog_public 1

    # Nur 7 Einträge pro Archiv Seite anzeigen
    wp option update posts_per_page 7

    # Home Seite erstellen
    wp post create –post_type=page –post_title=Home –post_status=publish –post_author=$(wp user get $wpuser –field=ID)

    # Test Beiträge erstellen
    # curl http://loripsum.net/api/4 | wp post generate –post_content –count=2

    # Child Theme erstellen
    # wp scaffold child-theme "Child Theme Divi" –parent_theme=Divi –theme_name="Child Theme Divi" –author="Michael Gebert" –author_uri="https://www.gebert.it" –theme_uri="https://www.gebert.it" –activate –force

    # IMPRESSUM erstellen
    echo "Impressum Seite wird erstellt"
    # wp post create –post_type=page –post_status=publish –post_author=$wpuser –post_title=IMPRESSUM
    wp post create –post_type=page –post_status=publish –post_author=$wpuser –post_content="$(curl https://www.gebert.it/_/muster_impressum.html)" –post_title=Impressum

    # IMPRESSUM als Datenschutzseite
    wp option update wp_page_for_privacy_policy $(wp post list –post_type=page |grep impressum | awk ‘{print $1}’)

    # Meine Seiten erstellen
    if [ "$mypages" ]; then
    export IFS=","
    for page in $mypages; do
    wp post create –post_type=page –post_status=publish –post_author=$wpuser –post_title="$(echo $page | sed -e ‘s/^ *//’ -e ‘s/ *$//’)"
    done
    fi

    # create a navigation bar
    wp menu create "standardmenu"

    # Eigene Seiten ins Standard Menü
    export IFS=" "
    for pageid in $(wp post list –order="ASC" –orderby="date" –post_type=page –post_status=publish –posts_per_page=-1 –field=ID –format=ids); do
    wp menu item add-post standardmenu $pageid
    done

    # Erstelltes Menü aktivieren
    if [ "$mypages" ]; then
    wp menu location assign standardmenu menu-1
    fi

    # Meine Kategorien und Schlagwörter erstellen
    echo "Kategorien werden erstellt"
    if [ "$category" ]; then
    # wp term delete category 1
    export IFS=","
    for tags in $category; do
    wp term create category $tags
    wp term create post_tag $tags
    done
    fi

    # Beiträge oder statische Seite?
    if [ "$my_blog" = "ja" ]; then
    echo "WordPress wird als Blog installiert"
    else
    echo "Wordpress wird als Homepage installiert"
    wp option update show_on_front ‘page’
    wp option update page_on_front $(wp post list –post_type=page –post_status=publish –posts_per_page=1 –pagename=home –field=ID –format=ids)
    fi

    # Plugin löschen
    wp plugin delete hello
    wp plugin delete akismet

    # Plugins installieren
    wp plugin install child-theme-configurator –activate
    wp plugin install debug-bar –activate
    wp plugin install cookie-notice –activate
    wp plugin install file-manager-advanced –activate
    wp plugin install wordpress-importer –activate
    wp plugin install google-sitemap-generator –activate
    wp plugin install google-captcha –activate
    wp plugin install google-analytics-dashboard-for-wp –activate
    wp plugin install wp-statistics –activate
    wp plugin install syntaxhighlighter –activate
    wp plugin install shortcodes-ultimate
    wp plugin install simple-custom-css –activate
    wp plugin install code-snippets

    # WordPress.org Favoriten installieren
    if [ "$wordpressuser" ]; then
    wp plugin favorites $wordpressuser | xargs wp plugin install –activate
    fi

    # Revesionen verwalten
    #
    # Alle amzeigen: wp revisions list
    # Alle löschen außer die letzten 3 von jedem Posting: wp revisions clean 3
    wp plugin install https://github.com/trepmal/wp-revisions-cli/archive/master.zip –activate

    # Plugins die nützlich sein können (Backup)
    # wp plugin install loco-translate
    # wp plugin install duplicator
    # wp plugin install classic-editor
    # wp plugin install classic-editor-addon
    # wp plugin install all-in-one-wp-migration
    # wp plugin install ml-slider

    ################################################################################
    # #
    # Verschiedene nützliche Befehle #
    # #
    ################################################################################

    # Plugin von einem eigenen Backup Server installieren
    # wp plugin install https://www.Domaine.de/_wp_plugins_backup_/divi-builder.zip

    # Plugin Suchen
    # wp plugin search dsgnwrks

    # Alle Plugin updaten
    # wp plugin update –all

    # Plugin löschen
    # wp plugin –deactivate uninstall bbpress

    # Plugin deaktivieren
    # wp plugin –deactivate –all
    # wp plugin deactivate 404-redirected

    # Alle Plugins aktivieren
    # wp plugin activate –all

    # Alle SPAM Kommentare auf einmal löschen
    # wp comment delete $(wp comment list –status=spam –format=ids)

    # Wenn die Datenbank zu groß oder die Seite langsam ist – Müll entsorgen
    # wp transient delete-all

    # Suchen und Ersetzen in der Datenbank (-dry-run zum testen)
    # wp search-replace ‘http://example.dev‘ ‘http://example.com‘ –skip-columns=guid

    # wp-cli update
    # wp cli update –nightly

    # Datenbank Backup
    # wp db export –add-drop-table
    # wp db import wordpress_dbase.sql

    # E-Mail vom Admin ändern
    # wp option update admin_email someone@example.com

    ################################################################################
    # #
    # wp-cli addons #
    # #
    ################################################################################

    # Theme testen mit wp themecheck
    wp plugin install theme-check –activate

    # Favoriten anzeigen wp plugin favorites matt –verbose
    # Favoriten Plugins von wordpress.org installieren mit
    # wp plugin favorites <user> | xargs wp plugin install –activate
    # Alle installieren ausser die 2 genannten
    # wp plugin favorites <user> | grep -vwE "(hello-dolly|akismet)" | xargs wp plugin install –activate

    # Standard WordPress .htaccess, wird für die Permalinks benötigt
    echo " .htaccess Datei für WordPress erstellen"

    cat > .htaccess <<EOF
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    EOF

    printf "${CY}"
    echo ""
    echo " ================================================================="
    echo ""
    echo " Installation ist beendet. Dein username/password lautet:"
    echo ""
    echo " Username: $wpuser"
    echo " Password: $wppass"
    echo " E-Mail: $wpmail"
    echo " Webseite: http://$web$apwd"
    echo ""
    echo " ================================================================="
    printf "${NC}"
    echo ""
    [/bash]

    Ads Blocker Image Powered by Code Help Pro

    Ads Blocker Detected!!!

    We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

    Powered By
    Best Wordpress Adblock Detecting Plugin | CHP Adblock