These instructions assume that PHP, Mysql / MariaDB, and Apache have already been setup on the Ubuntu 16.04 installation, and instructions for such preparation can be found here: Setting Up Apache 2.4, MariaDB, and PHP 7 with Ubuntu 16.04 on a Digital Ocean VPS.
- Download wp cli
- Download:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar - Test:
php wp-cli.phar --info - Adjust permissions:
chmod +x wp-cli.phar - Rename and move utility to a directory in path
sudo mv wp-cli.phar /usr/local/bin/wp
- Download:
- Create a database, database user, and assign privileges (MySQL or MariaDB)
- Create database:
mysql -u root -p -ve "create database test" - Create database user:
mysql -u root -p -ve "create user 'test_user'@'localhost' identified by 'password'" - Assign privileges:
mysql -u root -p -ve "grant all privileges on test.* to 'test_user'@'localhost'" - Flush privileges:
mysql -u root -p -ve "flush privileges"
- Create database:
- Install and Configure WordPress
- Create a folder for the WordPress installation:
mkdir wordpress && cd wordpress - Download WordPress:
wp core download - Configure WordPress:
wp core config --dbname=test --dbuser=test_user --dbpass="password" - Setup WordPress:
wp core install --url="localhost/wp" --title="Test" --admin_user="admin" --admin_password="password" --admin_email="user@domain.com" - Remove sample config:
rm wp-config-sample.php - Add
define('FS_METHOD', 'direct');towp-config.php - Install plugins:
wp plugin install wordpress-seo --activate - Install theme:
wp theme install thebesttheme --activate - Remove default unused themes:
wp theme delete twentyfourteenwp theme delete twentyfifteenwp theme delete twentysixteen
- Move wordpress to web root:
sudo mv wordpress/ /var/www/ - Configure permissions:
- Assign ownership of WordPress files in the document root to system user:
sudo chown -R ubuntu:www-data /var/www/wordpress/ - Set
setgidbit to cause new files to inherit group of parent directory:sudo find /var/www/wordpress/ -type d -exec chmod g+s {} \; - Group write access to
wp-contentdirectory:sudo chmod g+w /var/www/wordpress/wp-content - Group write access to
wp-content/themesdirectory:sudo chmod -R g+w /var/www/wordpress/wp-content/themes - Group write access to
wp-content/pluginsdirectory:sudo chmod -R g+w /var/www/wordpress/wp-content/plugins
- Assign ownership of WordPress files in the document root to system user:
- Enable
VirtualHost:sudo a2ensite wordpress.conf - Restart Apache:
sudo systemctl restart apache2.service
- Create a folder for the WordPress installation:
- Information about WordPress permissions: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04
- WP CLI source: https://github.com/wp-cli/wp-cli