From 43b8f400eb06c11d66838837945c2e23fd6c35c7 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 3 Sep 2020 23:06:42 +0100 Subject: [PATCH] add wordpress install scripts --- install/scripts/install-php.sh | 2 +- install/scripts/install-wordpress.sh | 115 +++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100755 install/scripts/install-wordpress.sh diff --git a/install/scripts/install-php.sh b/install/scripts/install-php.sh index 1025abc..e967c4a 100755 --- a/install/scripts/install-php.sh +++ b/install/scripts/install-php.sh @@ -9,7 +9,7 @@ if [ -n "$wp_user" ] ; then echo 'Installing PHP for WordPress ...' ssh -T $ssh << 'EOSSH' - apt install -y php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \ + apt install -y php libapache2-mod-php php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \ php-mysql php-soap php-xml php-zip _php_config_file=$(php --ini | grep Loaded | awk '{ print $4 }') diff --git a/install/scripts/install-wordpress.sh b/install/scripts/install-wordpress.sh new file mode 100755 index 0000000..a849647 --- /dev/null +++ b/install/scripts/install-wordpress.sh @@ -0,0 +1,115 @@ +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