#!/bin/bash -e clear echo "============================================" echo "WordPress Install Script" echo "============================================" echo "Don't forget to ensure that the database has remote access for this server!" # Gathering database login credentials from user input read -p "Database Host: " dbhost read -p "Database Name: " dbname read -p "Database User: " dbuser read -sp "Database Password: " dbpass echo echo # Starting the Wordpress installation process clear echo "===================================" echo "Choose Wordpress installation mode:" echo "===================================" echo echo "1. Install Wordpress using wp-cli" echo "2. Install Wordpress without wp-cli" echo read -p "Choose install method: " install_method if [ "$install_method" == 1 ]; then # Starting the Wordpress installation process using wp-cli # echo "===================================" # echo "Please wait while we install wp-cli" # echo "===================================" # curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # chmod +x wp-cli.phar # cp wp-cli.phar /usr/bin/wp # # echo "==========================" # echo "Finished installing wp-cli" # echo "==========================" echo read -p "Install wordpress in a new directory (y/n): " new if [ "$new" == y ] ; then read -p "Name of the wordpress directory: " dir_name mkdir -p $dir_name cd $dir_name fi # Download the latest wordpress package using wp-cli wp core download # Creating wp-config file using credentials defined on lines 8-11 wp core config --dbhost=$dbhost --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass chmod 644 wp-config.php # Entering details of the new Wordpress site clear echo "=======================================================" echo "Ready to install Wordpress. Just enter few more details" echo "=======================================================" read -p "Website url: " url read -p "Website title: " title read -p "Admin username: " admin_name read -sp "Admin password: " admin_pass echo read -p "Admin email: " admin_email echo read -p "Run install? (y/n): " run_wp_install if [ "$run_wp_install" == n ] ; then exit else echo "============================================" echo "A robot is now installing WordPress for you." echo "============================================" echo # Installing Wordpress site using credentials defined on lines 71-76 wp core install --url=$url --title="$title" --admin_name=$admin_name --admin_password=$admin_pass --admin_email=$admin_email --allow-root fi else # download wordpress curl -O https://wordpress.org/latest.tar.gz # unzip wordpress tar -zxvf latest.tar.gz # change dir to wordpress cd wordpress # copy file to parent dir cp -rf . .. # move back to parent dir cd .. # remove files from wordpress folder rm -R wordpress # create wp config cp wp-config-sample.php wp-config.php # set database details with perl find and replace perl -pi -e "s/database_name_here/$dbname/g" wp-config.php perl -pi -e "s/username_here/$dbuser/g" wp-config.php perl -pi -e "s/password_here/$dbpass/g" wp-config.php # set WP salts perl -i -pe' BEGIN { @chars = ("a" .. "z", "A" .. "Z", 0 .. 9); push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|"; sub salt { join "", map $chars[ rand @chars ], 1 .. 64 } } s/put your unique phrase here/salt()/ge ' wp-config.php # create uploads folder and set permissions mkdir wp-content/uploads chmod 755 wp-content/uploads echo "Cleaning..." # remove zip file rm latest.tar.gz echo "=========================" echo "Installation is complete." echo "=========================" fi wp option update permalink_structure '/%postname%/' wp option update default_ping_status 'closed' wp option update default_pingback_flag '0' # Install and activate defaults plugins wp plugin --activate # Install defaults plugins plugin_list="email-address-encoder connect-polylang-elementor polylang wordfence elementor wordpress-seo acf-openstreetmap-field acf-image-aspect-ratio-crop advanced-custom-fields options-page-admin-for-acf acf-frontend-form-element acf-extended classic-editor" for i in $plugin_list; do #Set parameter of the menu options. read -p "Install $i? (y/n): " install_plugin if [ "$install_plugin" == y ] ; then plugin_install_list="$plugin_install_list $i"; fi done wp plugin install $plugin_install_list # Update plugins wp plugin update --all # Themes wp theme install hello-elementor --activate wp scaffold child-theme hello-elementor-child --parent_theme=hello-elementor wp theme activate hello-elementor-child # Other plugins to transfer # FG Drupal to WordPress # ACF PRO # Elementor Pro # Civicrm !! At the right version in case of migration from drupal !! # My_basic utility plugin rename to project specific plugin # civicrm_wp_media # toggle-aid???? test acf-frontend-form-element # # https://download.civicrm.org/latest/ # https://download.civicrm.org/latest/civicrm-STABLE-wordpress.zip # https://download.civicrm.org/latest/civicrm-STABLE-l10n.tar.gz # https://download.civicrm.org/civicrm-5.41.1-wordpress.zip # wget https://download.civicrm.org/civicrm-x.x.x-wordpress.zip # https://download.civicrm.org/civicrm-5.41.1-l10n.tar.gz # cd /var/www/wordpress/wp-content/plugins