Skip to content

Instantly share code, notes, and snippets.

@areski
Forked from bgallagh3r/wp.sh
Last active January 25, 2022 05:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save areski/23a131a58aa57bab7333 to your computer and use it in GitHub Desktop.
Save areski/23a131a58aa57bab7333 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
#
# Install Wordpress Script - This script intend to install WP on Ubuntu 14.04 LTS
#
INSTALL_DIR="/var/www/"
dbuser="root"
SALT=`</dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 20)`
#Install deps
apt-get install -y unzip wget
clear
echo ""
echo "WordPress Install Script in $INSTALL_DIR"
echo "========================================"
echo "Database Name: "
read -e dbname
echo "Database Password: "
read -e dbpass
echo "Website Domain (google):"
read -e website_domain
echo "Website extension (com):"
read -e website_extension
echo "URL Template to install: "
read -e url_template
templatefile="${url_template##*/}"
echo "templatefile is $templatefile"
echo ""
echo "run install? (y/n)"
read -e run
if [ "$run" == n ] ; then
exit
fi
#Create DB wordpress
mysqladmin create --password=$dbpass wordpress
echo "Add header module to apache"
a2enmod headers
a2enmod rewrite
cd $INSTALL_DIR
echo ""
echo "Installing WordPress for you..."
echo "==============================="
#download wordpress
curl -O https://wordpress.org/latest.tar.gz
#unzip wordpress
tar -zxvf latest.tar.gz
rm -latest.tar.gz
#change dir to wordpress
cd 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
perl -pi -e "s/password_here/$dbpass/g" wp-config.php
perl -pi -e "s/put your unique phrase here/$SALT/g" wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 777 wp-content/uploads
#remove bash script
rm wp.sh
#Install template
#----------------
cd /var/www/wordpress/wp-content/themes/
wget $url_template
unzip $templatefile
#Install plugins
#----------------
cd /var/www/wordpress/wp-content/plugins/
wget https://github.com/Star2Billing/a2billing/raw/develop/addons/contrib/wordpress/a2billing.zip
unzip a2billing.zip
wget http://downloads.wordpress.org/plugin/contact-form-7.3.9.3.zip
unzip contact-form-7.3.9.3.zip
wget http://downloads.wordpress.org/plugin/raw-html.1.4.12.zip
unzip raw-html.1.4.12.zip
cd /var/www/wordpress
#HTACCESS
#--------
curl -O https://gist.githubusercontent.com/areski/4bf63d75d6b110aa4272/raw/67e65a9c603edf08a4485038c408eb405ddfc247/wp_htaccess
mv wp_htaccess .htaccess
perl -pi -e "s/DOMAINNAME/$website_domain/g" .htaccess
perl -pi -e "s/DOMAINEXT/$website_extension/g" .htaccess
#ROBOTS.txt
#----------
curl -O https://gist.githubusercontent.com/areski/e550c0229c35133339ad/raw/4a79da09f57a1eea59778fdfe25882be26df16f6/robots.txt
perl -pi -e "s/DOMAINNAME/$website_domain/g" robots.txt
perl -pi -e "s/DOMAINEXT/$website_extension/g" robots.txt
#Prepare Apache Conf
#-------------------
sed -i "s/\/var\/www/\/var\/www\/wordpress/g" /etc/apache2/sites-enabled/000-default
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/sites-enabled/000-default
wget https://gist.githubusercontent.com/areski/790f1cde73ac05afe477/raw/fd24d459a1e3ca1f8b1ab46b2276c9d8ed6afa8e/a2billing_webservice.conf
mv a2billing_webservice.conf /etc/apache2/sites-enabled/
/etc/init.d/apache2 restart
echo "======================================="
echo "Installation is completed!"
echo ""
echo "Enable the Template & Plugins installed!"
echo ""
echo "Got to /wp-admin/options-permalink.php"
echo " -> Select Post name"
echo ""
echo "======================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment