-
-
Save cdsaenz/9670764cec2305b1d1b5b8439c6be3db to your computer and use it in GitHub Desktop.
#wp #bash #cli Install and initial set up for WordPress sites (uses WP-CLI)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get wp-cli | |
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && sudo mv wp-cli.phar /usr/local/bin/wp | |
# wp-cli auto-completion | |
# wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash && source wp-completion.bash && echo -e "\nsource wp-completion.bash" >> .bashrc | |
#verify if wp-cli correctly installed | |
# wp --info | |
install_path='/var/www/project/repo/www' | |
db_host='localhost' | |
db_name='wpdb' | |
db_user='wpuser' | |
db_pwd='somestrongpwd' | |
db_prefix='wp' | |
site_url='http://www.example.com' | |
site_title='Site Title' | |
site_desc='Site Desc' | |
admin_user='johndoe' | |
admin_pwd='somestrongpwd' | |
admin_email='[email protected]' | |
# Install WordPress and create the wp-config.php file... | |
wp core download --path=$install_path | |
wp core config --path=$install_path --dbname=$db_name --dbuser=$db_user --dbpass=$db_pwd --dbhost=$db_host --dbprefix=$db_prefix"_" --extra-php <<PHP | |
define( 'WP_DEBUG', true ); | |
PHP | |
wp core install --path=$install_path --title="$site_title" --url="$site_url" --admin_user=$admin_user --admin_email=$admin_email --admin_password=$admin_pwd | |
# Go in the install directory | |
cd $install_path | |
# Create database | |
# wp db create | |
# Update WordPress options | |
wp option update blogdescription "$site_desc" | |
wp option update permalink_structure '/%category%/%postname%/' | |
wp option update default_ping_status 'closed' | |
wp option update default_pingback_flag '0' | |
wp option update start_of_week '0' | |
wp option update gmt_offset '6' | |
#install starter theme | |
# currently throwing, Error: Could not decompress your theme files ('/tmp/underscores-TBs0rI.tmp') at '/var/www/html/wp-content/themes': Incompatible Archive. | |
# wp scaffold _s projectname --theme_name="Project Name Theme" --author="John Doe" --sassify | |
# alternative | |
curl --data 'underscoresme_name=Project Theme Name&underscoresme_slug=projecttheme&underscoresme_author=John Doe&underscoresme_generate_submit=Generate&underscoresme_generate=1&underscoresme_sass=1' http://underscores.me -o /tmp/_stheme.zip | |
sudo apt-get install -y unzip | |
unzip /tmp/_stheme.zip -d ./wp-content/themes/ | |
rm /tmp/_stheme.zip | |
wp theme activate projecttheme | |
# alternative starter theme | |
# wp theme install wp-bootstrap-starter --activate | |
# Get rid of default themes and Hello Dolly plugin | |
wp theme delete twentyfifteen twentysixteen twentyseventeen | |
wp plugin delete hello | |
#some plugins need write permission to .htaccess or wp-content/ | |
sudo chown -R :www-data $install_path | |
# Install plugins | |
plugins=( developer \ | |
abt-relative-urls \ | |
attachments \ | |
wordpress-seo \ | |
w3-total-cache \ | |
google-analytics-dashboard-for-wp \ | |
cloudflare \ | |
jarvis \ | |
fakerpress \ | |
) | |
wp plugin install --activate ${plugins[@]} | |
# Update plugins | |
wp plugin update --all | |
# Download and import photo samples | |
# mkdir tmp | |
# cd tmp | |
# wget http://lorempixel.com/1920/1080/abstract/{1..10} | |
# wget http://lorempixel.com/1920/1080/nature/{1..10} | |
# find . -type f -execdir mv {} {}.jpg ';' #rename all files to name.jpg otherwise wp import wont work | |
# wp media import *.jpg | |
# cd .. | |
# rm -rf tmp | |
# Import dummy/test data (https://github.com/poststatus/wptest) | |
wp plugin install wordpress-importer --activate | |
curl -OL https://raw.githubusercontent.com/poststatus/wptest/master/wptest.xml | |
wp import wptest.xml --authors=create | |
rm wptest.xml | |
wp plugin uninstall wordpress-importer --deactivate | |
# post-install permission | |
sudo chown -R $USER:$USER $install_path | |
sudo chown -R :www-data $install_path/wp-content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment