Skip to content

Instantly share code, notes, and snippets.

@alfmatos
Last active December 10, 2020 10:16
Show Gist options
  • Save alfmatos/778db99fb16932b71fb18ad340111954 to your computer and use it in GitHub Desktop.
Save alfmatos/778db99fb16932b71fb18ad340111954 to your computer and use it in GitHub Desktop.
Wordpress on Lightsail Cheat Sheet

Wordpress on Lighsail 2018.14

Setup new instance

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.

Update the system

apt update && apt -y dist-upgrade

Firewall

Setup a simple firewall that comes with Ubuntu.

ufw allow OpenSSH
ufw enable
ufw status

NGINX

Setup nginx as a web server.

apt install nginx
ufw allow 'Nginx Full'

MYSQL & PHP

Install and configure MySQL server and PHP

apt install mysql-server
mysql_secure_installation
apt install php-fpm php-mysql

Configure the website

nginx

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

certbot

$ add-apt-repository ppa:certbot/certbot
$ apt install certbot python-certbot-nginx
$ certbot --nginx -d mydomain.com -d www.mydomain.com

PHP modules for wordpress

$ 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

Wordpress

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.

Default configurations

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;
        }

}
@Peneheals
Copy link

sed -i "s/pho/php/g"

@alfmatos
Copy link
Author

sed -i "s/pho/php/g"

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment