Since this site is to keep my notes on how to setup technology, I should make the first post about WordPress (or should it be Linux?).
- Setup a LAMP server <Add link to it>
- MySQL Database
- Generate Random Password for wordpress user
- Create Database
- Create User and add Permission
- Download WordPress
- Create Plugin/Update User
- Configure WordPress (CLI) – keep it off the internet till the next step is done
- Configure WordPress (Web)
- Configure Apache (Require Client Certificate and forbid non ssl to wp-admin)
- Create first post – this 🙂
Code (todo – save password to variable and use, update apache conf, permalink, test):
apt-get update && apt-get -y install php7.0-gd lamp-server^
a2enmod rewrite substitute
service apache2 graceful
SQL_PWD=$(openssl rand -base64 32|sed 's_/_-_g')
echo "
CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost IDENTIFIED BY '$SQL_PWD';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit
" | mysql
wget http://wordpress.org/latest.tar.gz -O ~/wordpress.tgz
cd /var/www
tar xzvf ~/wordpress.tgz
rm -fr html
mv wordpress html
mv wordpress/wp-config-sample.php wordpress/wp-config.php
sed -i 's/database_name_here/wordpress/' wordpress/wp-config.php
sed -i 's/username_here/wordpressuser/' wordpress/wp-config.php
sed -i "s/password_here/$SQL_PWD/" wordpress/wp-config.php
while [ $(cat wp-config.php | grep "put your unique phrase here" -c) -gt 0 ]; do sed -i "0,/put your unique phrase here/{s/put your unique phrase here/$(openssl rand -base64 32|sed 's_/_-_g')/}" wp-config.php; done
add-apt-repository ppa:certbot/certbot
apt update
certbot --apache -d example.com -d www.example.com
Add Case insensitive
RewriteMap lc int:tolower