Bash: WordPress Installer

A basic WordPress installer in Bash. Assumes Ubuntu 14.04 LTS, so adjust as necessary. The end-of-line backslashes here are added for ease of display, so remove them before running this.

#!/bin/bash
# Set sitename and directory for WordPress
WPDIR=/var/www/wordpress;
SITENAME=mydomain.com;
EMAIL=myemail@somewhere.com;
 
# Download latest WordPress and untar it
wget https://wordpress.org/latest.zip;
unzip latest.zip;
mv wordpress/* $WPDIR;
 
# Set permissions on /var/www/wpdir to web user
# Assumes Debian/Ubuntu; for Fedora/CentOS use apache:apache
chown -hR www-data:www-data $WPDIR;
 
# Write an Apache virtual host file for
# Again assumes Debian/Ubuntu, for Fedora/CentOS use httpd instead of apache2, etc.
echo -e "<virtualhost *:80="">ntServerAdmin $EMAILntServerName $SITENAMEntDocumentRoot 
$WPDIRn</virtualhost>" > /etc/apache2/sites-available/$SITENAME.conf;
a2ensite $SITENAME.conf;
service apache2 restart;
 
# Set up database
mysql -uroot -p -e "CREATE DATABASE wordpress DEFAULT CHARACTER SET='utf8'; 
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, 
CREATE TEMPORARY TABLES ON wordpress.* TO 'wp-user'@'localhost' IDENTIFIED BY 'wp-password'; 
FLUSH PRIVILEGES;"

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *