echo "Installing WordPress .." _mysql_cmd="mysql -uroot -p$db_root_pass -e " ssh -T $ssh << EOSSH # install wp-cli first if [ ! -f /usr/local/bin/wp ] ; then wget -nv -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \ && chmod +x /usr/local/bin/wp fi su "$user" if wp core is-installed --quiet --path="$wp_path" ; then echo "WordPress already installed" else # first create database and user if command -v mysql ; then $_mysql_cmd "CREATE DATABASE $wp_db_name;" $_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';" $_mysql_cmd "FLUSH PRIVILEGES;" else echo "ERROR: no installed database found - aborting WordPress install" exit 40 fi wp core download \ --version="$wp_version" \ --path="$wp_path" \ --skip-content \ --locale="$wp_locale" wp config create \ --path="$wp_path" \ --dbname="$wp_db_name" \ --dbuser="$wp_db_user" \ --dbpass="$wp_db_pass" \ --locale="$wp_locale" \ --extra-php < $config_path ServerName $domain DocumentRoot $wp_path ErrorLog /var/log/wordpress/error.log CustomLog /var/log/wordpress/access.log combined AllowOverride All RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] EOF a2enmod rewrite a2ensite wordpress a2dissite 000-default systemctl reload apache2 fi EOSSH