Create and setup and instance on AWS Lightsail with a public ip address, an ssh user and an access key. Place the access key on the the local .ssh, and create the proper Host entry on .ssh/config.
Don't forget to update the dns entry to the public lightsail address.
apt update && apt -y dist-upgrade
Setup a simple firewall that comes with Ubuntu.
ufw allow OpenSSH
ufw enable
ufw status
Setup nginx as a web server.
apt install nginx
ufw allow 'Nginx Full'
Install and configure MySQL server and PHP
apt install mysql-server
mysql_secure_installation
apt install php-fpm php-mysql
Create an nginx configuration and load it
vim /etc/nginx/sites-available/example.com
mkdir -p /var/www/example.com
nginx -t
systemctl reload nginx
$ add-apt-repository ppa:certbot/certbot
$ apt install certbot python-certbot-nginx
$ certbot --nginx -d mydomain.com -d www.mydomain.com
$ apt update
$ apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip
$ systemctl restart php7.2-fpm
$ systemctl reload nginx
Base wordpress files
$ cd /tmp
$ curl -LO https://wordpress.org/latest.tar.gz
$ tar xzvf latest.tar.gz
$ cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
$ cp -R /tmp/wordpress/* /var/www/1function.com
$ chown -R www-data:www-data /var/www/1function.com/
Mysql setup
$ sudo mysql -p
For this intended config:
db: wp_db
user: wp_db_user
password: super.pA33word!999
CREATE DATABASE wp_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON wp_db.* TO 'wp_db_user'@'localhost' IDENTIFIED BY 'super.pA33word!999';
Then edit the wp-config.php file to reflect the changes.
server {
root /var/www/example.com;
index index.php index.html index.htm;
server_name example.com www.example.com;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
sed -i "s/pho/php/g"