add wordpress install scripts
This commit is contained in:
parent
a68f71337b
commit
43b8f400eb
|
@ -9,7 +9,7 @@ if [ -n "$wp_user" ] ; then
|
||||||
echo 'Installing PHP for WordPress ...'
|
echo 'Installing PHP for WordPress ...'
|
||||||
|
|
||||||
ssh -T $ssh << 'EOSSH'
|
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-mysql php-soap php-xml php-zip
|
||||||
|
|
||||||
_php_config_file=$(php --ini | grep Loaded | awk '{ print $4 }')
|
_php_config_file=$(php --ini | grep Loaded | awk '{ print $4 }')
|
||||||
|
|
|
@ -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 <<PHP
|
||||||
|
define( 'WP_DEBUG', true );
|
||||||
|
define( 'WP_DEBUG_LOG', true );
|
||||||
|
PHP
|
||||||
|
wp core install \
|
||||||
|
--path="$wp_path" \
|
||||||
|
--url="$domain".com \
|
||||||
|
--title="$wp_title" \
|
||||||
|
--admin_user="$wp_user" \
|
||||||
|
--admin_password="$wp_pass" \
|
||||||
|
--admin_email="$wp_email"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$wp_themes" ] ; then
|
||||||
|
printf "\nInstalling themes ..."
|
||||||
|
option='--activate'
|
||||||
|
for theme in $wp_themes ; do
|
||||||
|
echo " installing $theme ..."
|
||||||
|
wp theme install $theme "$option" --path="$wp_path" --allow-root
|
||||||
|
option=''
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$wp_plugins" ] ; then
|
||||||
|
printf "\nInstalling plugins ..."
|
||||||
|
for plugin in $wp_plugins ; do
|
||||||
|
echo " installing $plugin ..."
|
||||||
|
wp plugin install $plugin --path="$wp_path" --allow-root
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$wp_plugins_active" ] ; then
|
||||||
|
printf "\nInstalling plugins to activate ..."
|
||||||
|
for plugin in $wp_plugins_active ; do
|
||||||
|
echo " installing $plugin ..."
|
||||||
|
wp plugin install $plugin --activate --path="$wp_path" --allow-root
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$wp_plugins_active" ] ; then
|
||||||
|
printf "\nUninstalling plugins ..."
|
||||||
|
for plugin in $wp_plugins_uninstall ; do
|
||||||
|
echo " installing $plugin ..."
|
||||||
|
wp plugin deactivate $plugin --path="$wp_path" --allow-root
|
||||||
|
wp plugin uninstall $plugin --path="$wp_path" --allow-root
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
EOSSH
|
||||||
|
|
||||||
|
config_path='/etc/apache2/sites-available/wordpress.conf'
|
||||||
|
ssh -T $ssh << EOSSH
|
||||||
|
if [ -n "$apache2_version" ] ; then
|
||||||
|
mkdir -p /var/log/wordpress/
|
||||||
|
cat << EOF > $config_path
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName $domain
|
||||||
|
DocumentRoot $wp_path
|
||||||
|
ErrorLog /var/log/wordpress/error.log
|
||||||
|
CustomLog /var/log/wordpress/access.log combined
|
||||||
|
<Directory $wp_path/>
|
||||||
|
AllowOverride All
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule . /index.php [L]
|
||||||
|
</IfModule>
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
|
EOF
|
||||||
|
a2enmod rewrite
|
||||||
|
a2ensite wordpress
|
||||||
|
a2dissite 000-default
|
||||||
|
systemctl reload apache2
|
||||||
|
fi
|
||||||
|
EOSSH
|
Loading…
Reference in New Issue