OPTIONAL: Create LXD container
lxc launch ubuntu-minimal:lts wordpress
lxc shell wordpress
Ubuntu package
https://ubuntu.com/tutorials/install-and-configure-wordpress#1-overview
sudo apt update
sudo apt install -y apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip apg vim
rm /var/www/html/index.html
sudo chown www-data: /var/www/html
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /var/www/html
cat</etc/apache2/sites-available/wordpress.conf
DocumentRoot /var/www/html/wordpress
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
Require all granted
Options FollowSymLinks
Require all granted
EOF
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo a2dissite 000-default
sudo service apache2 reload
DB_PASS=$(apg -m 16 -n1)
WP_PHASE=$(apg -m 32 -n1)
cat < /tmp/wordpress.sql
CREATE DATABASE wordpress;
CREATE USER wordpress@localhost IDENTIFIED BY '${DB_PASS}';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;
FLUSH PRIVILEGES;
EOF
cat /tmp/wordpress.sql | sudo mysql --defaults-extra-file=/etc/mysql/debian.cnf
cd /var/www/html/wordpress
sudo -u www-data cp wp-config-sample.php wp-config.php
sudo -u www-data sed -i 's/database_name_here/wordpress/' wp-config.php
sudo -u www-data sed -i 's/username_here/wordpress/' wp-config.php
sudo -u www-data sed -i "s/password_here/${DB_PASS}/" wp-config.php
sudo -u www-data sed -i "s/put your unique phrase here/${WP_PHASE}/" wp-config.php
# OPTIONAL: enforce https
sed -i '2i\$_SERVER['HTTPS'] = 'on';\' wp-config.php
# Access the server under:
http://your_server/wordpressOLD
cat < /etc/wordpress/config-localhost.php
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'yourpasswordhere');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>
EOF
ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-10.0.129.230.php
# Links
https://help.ubuntu.com/lts/serverguide/wordpress.html
Manual installation