Skip to content

Instantly share code, notes, and snippets.

@jdembowski
Last active November 26, 2016 21:19
Show Gist options
  • Save jdembowski/d5e97c90c1af2160efc1123d803a7f59 to your computer and use it in GitHub Desktop.
Save jdembowski/d5e97c90c1af2160efc1123d803a7f59 to your computer and use it in GitHub Desktop.
#
# Start with a fresh Raspbian Jessie Lite installation from https://www.raspberrypi.org/downloads/raspbian/
#
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y install vim
sudo apt-get -y install subversion
sudo apt-get -y install git
sudo apt-get -y install sendmail-bin
sudo apt-get -y install telnet
sudo apt-get -y install dnsutils
sudo apt-get -y install tcpdump
#
# Password for mariadb root user is "root" until I learn how to make it headless
# in a reproducable way.
#
sudo apt-get -y install mariadb-server
sudo apt-get -y install apache2
sudo apt-get -y install libapache2-mod-php5
sudo apt-get -y install php5-mysql
sudo apt-get -y install php5-imagick
sudo apt-get -y install php5-gd
cat <<EOL >~/wordpress.local.conf
<VirtualHost *:80>
ServerName wordpress.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vhosts/wordpress.local
<Directory /var/www/vhosts/wordpress.local>
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOL
sudo mv ~/wordpress.local.conf /etc/apache2/sites-available/
sudo chown root:root /etc/apache2/sites-available/wordpress.local.conf
sudo a2ensite wordpress.local
sudo a2enmod rewrite
sudo service apache2 restart
sudo systemctl daemon-reload
#
# Install wp-cli
#
cd /usr/local/bin/
sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo mv wp-cli.phar wp
sudo chmod +x wp
sudo mkdir -p /var/www/vhosts/wordpress.local
sudo chown www-data:www-data /var/www/vhosts/wordpress.local
cd /var/www/vhosts/wordpress.local
#
# Setup WordPress DB, db user and password.
# Yes, I'm going with a reproducable default password
#
mysql -u root -proot << EOL
create database wordpresspi;
grant all privileges on wordpresspi.* to "pi"@"localhost" identified by "raspberry";
flush privileges;
EOL
sudo -u www-data wp core download
sudo -u www-data wp core config --dbname=wordpresspi \
--dbuser=pi \
--dbpass=raspberry \
--extra-php << EOL
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
EOL
sudo -u www-data wp core install --admin_user=pi \
--admin_password=raspberry \
[email protected] \
--url=wordpress.local \
--title="WordPress Pi"
sudo -u www-data wp option update blogdescription \
"WordPress Pi Zero Installation"
sudo -u www-data wp option update comment_moderation 1
sudo -u www-data wp option update comments_notify 0
sudo -u www-data wp option update moderation_notify 0
sudo -u www-data wp option update comment_whitelist 0
sudo -u www-data wp user update 1 --first_name="Pi" \
--last_name="Zero" \
--display_name="Pi Zero"
sudo -u www-data wp plugin update --all
sudo -u www-data wp theme update --all
# Change the raspberrypi to wordpress.
# It will be reachable via the directly connected PC or Mac as wordpress.local
sudo sed -i 's/raspberrypi/wordpress/g' /etc/hostname
sudo sed -i 's/raspberrypi/wordpress/g' /etc/hosts
# Reboot. Weird things will happen if you don't.
echo "Rebooting..."
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment