update

Home

Use C-c . hammer to update date

1 Chris Titus Tech youtube video

This cheat was inspired by this youtube.com

I'm going over how to set up and host a website on the free tier of Google Cloud Platform. Never pay for hosting again when it can be free!

Recommended VPN :: Express VPN :: https://links.christitus.com/expressvpn

::Here is my complete write up with all the commands I used:: https://www.christitus.com/wordpress-…

::FAQ on Google Cloud Platform Free Tier:: https://cloud.google.com/free/docs/gc

free wordpress #wordpress

💻 Recommendations 💻

🕹 Live Streams Monday & Friday 🕹

🖥 Contact me 🖥

🚑 Need Help!? Ask our community! 🚑

💰 My Amazon Store (YouTube Gear, PC Hardware, and Books I recommend) 💰

  • dnf install gcloud
  • console.cloud.google.com
  • Compute engine
  • create VM
  • pick image
  • 20G
  • but for machine type, select micro 1 shared 0.6 GB
  • pick a region
  • firewall click on both http and https
  • wordpress (not sure if I need to do this) this will create an external ip address as well. yippeee
  • creation takes about 2 min.
  • Next we run the gcloud command to connect to the newly created instance.
  • Copy the command from the website and paste into a terminal.
  • Once booted, we do a sudo dnf upgrade. (if we have installed a CentOS image)
  • Now our micromachine is up and updated.

1.1 Step 2)

the micro image only has 582 MB RAM, so we need to add a swap file.

  • htop to check,
  • sudo fallocate -l 1G /swapfile
  • sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
  • sudo chmod 600 /swapfile (to protect it to just root read/write
  • sudo mkswap /swapfile
  • sudo swapon /swapfile
  • htop

Then reboot /etc/fstab

  • /swapfile swap swap defaults 0 0

ALWAYS after modifying the /etc/fstab, you should do a sudo mount -a to confirm that everything mounts and that you haven't made an error in your /etc/fstab file edits.

htop (should show 1 Gig of space)

1.2 Step 3)

Install LAMP stack.

THe easiest way is to do a bundle:

  • sudo dnf install tasksel ??? or is this just an apt get ??
  • sudo tasksel install lamp-server
  • sudo dnf install lamp-server

Step 3.5) Add extra stuff:

  • sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc

1.3 Step 4)

configuration.

get the static IP for this machine? - curl ifcofnig.me 15.4.5.2

Copy this and add it to your domain, an A record. ( chris cheated with his, and just used a /etc/hosts file ) He created a bogus domain site: squaregatorisfornoobs.com He did this BOTH on the new micro vm in the cloud, as well as his home machine.

1.4 Step 5)

Configure Apache

cd /etc/apache2/sites-available setup the domain name in the apache config file: /etc/apache2/sites-available

backup (cp) the existing one to an .original file Then sudo cp 000.default.conf zintis.net.conf

sudo -i edit zintis.com.conf

<Directory /var/www/html>
    Require all granted
</Directory>
ServerName zintis.net
ServierAlias www.zintis.net
DocumentRoot /var/www/html

disable the default web site: 2dissite 000-default.conf

a2ensite zintis.net.conf Then activate by reload (what is the difference between reload and restart?): systemctl reload apache2

2 php

You cna do this once, from the terminal and then leave it alone. As follows:

mysql -u root

mysql>CREATE DATABASE wordpress;
mysql>GRANT ALL ON wordpress.* TO l'wordpressuser' IDENTIFIED BT 'Secure!2345!'
mysql>quit

mysql_secure_installation
> run through script to lock down your mysql setup

2.1 edit .ini ???=

cd /etc/php/7.2/apache2 vi php.ini

max_input_time = 30
upload_max_filesize = 30M

post_max_size = 25M

3 Create proper web page

  • cd /var/www/html
  • mv index.html index.original.html

create your web page root and save as index.html

wget https://wordpress.org/latest.tar.gz

tar -xvf latest.tar.gz.

cd wordpress mv * ..

3.1 cleanup

rm latest.tar.gz

Before you replace the wp-config.php, be ready with all your files, as leaving the wp-config-sample.php as your wp-config.php SHOULD ONLY BE A TEMPORARY moment, as it leaves you WIDE OPEN. So do all your edits ahead, and then end with this next "mv" statement.

mv wp-config-sample.php wp-config.php

vi wp-config.php

define ( 'DB_NAME', 'wordpress' );
define ( 'DB_USER', 'wordpressuser' );
define ( 'DB_PASSWORD', ''Secure!2345!' );

DO NOT LEAVE THE DEFAULT SALTS AND KEYS.... delete them.  ALL OF THEM.
define ( 'AUTH_KEY',      'put your unique phrase here' );
define ( 'SECURE_AUTH_KEY',      'put your unique phrase here' );
define ( 'LOGGED_IN_KEY ',      'put your unique phrase here' );
define ( 'NONCE_KEY',      'put your unique phrase here' );
define ( 'AUTH_SALT',      'put your unique phrase here' );
define ( 'SECURE_AUTH_SALT',      'put your unique phrase here' );
define ( 'LOGGED_IN_SALT',      'put your unique phrase here' );
define ( 'NONCE_SALT',      'put your unique phrase here' );

Then right in the wp-config.php file where the SALTs were, copy the URL link to generate unique phrases: https://api.wordpress.org/secret-key/1.1/salt/ WordPress

And copy these and use these in their place.

4 Now we should have a complete website.

You would actually use wordpress to set up a web site.

5 Apache / wordpress tuning adjustments.

microsites should be tuned as the defaults selected for microsites allow for far greater traffic that can be handled reasonably well. So, tune them down. See the youtube video on tuning here. Use npm pre-fork tuning.

script: needs to see traffic for a couple of days to get valid numbers.

vi /etc/apache2/mods-enabled/mpm_prefork.conf

Richard Forth, on github, wget https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl which is a perl script.

=================================

6 Installing gcloud sdk on my vm4 KVM machine

#+BEGINSRC bash cd yum.repos.d/ root@vm4-pyenv /etc/yum.repos.d[186] $ lst total 84 -rw-r–r–. 1 root 1305 Aug 6 2019 epel-testing.repo -rw-r–r–. 1 root 1206 Aug 6 2019 epel.repo -rw-r–r–. 1 root 1351 Aug 6 2019 epel-playground.repo -rw-r–r–. 1 root 74 Jan 2 10:21 CentOS-Vault.repo -rw-r–r–. 1 root 1382 Jan 2 10:21 CentOS-Sources.repo -rw-r–r–. 1 root 736 Jan 2 10:21 CentOS-PowerTools.repo -rw-r–r–. 1 root 928 Jan 2 10:21 CentOS-Media.repo -rw-r–r–. 1 root 738 Jan 2 10:21 CentOS-HA.repo -rw-r–r–. 1 root 338 Jan 2 10:21 CentOS-fasttrack.repo -rw-r–r–. 1 root 756 Jan 2 10:21 CentOS-Extras.repo -rw-r–r–. 1 root 668 Jan 2 10:21 CentOS-Debuginfo.repo -rw-r–r–. 1 root 1043 Jan 2 10:21 CentOS-CR.repo -rw-r–r–. 1 root 798 Jan 2 10:21 CentOS-centosplus.repo -rw-r–r–. 1 root 712 Jan 2 10:21 CentOS-Base.repo -rw-r–r–. 1 root 731 Jan 2 10:21 CentOS-AppStream.repo -rw-r–r–. 1 root 297 Feb 12 10:57 shells:fish:release:3.repo drwxr-xr-x. 84 root 8192 Mar 8 15:59 .. -rw-r–r–. 1 root 281 Mar 8 16:24 google-cloud-sdk.repo drwxr-xr-x. 2 root 4096 Mar 8 16:24 . root@vm4-pyenv /etc/yum.repos.d[187] $ less google-cloud-sdk.repo root@vm4-pyenv /etc/yum.repos.d[188] $ sudo dnf install google-cloud-sdk Google Cloud SDK 635 B/s | 454 B 00:00 Google Cloud SDK 8.0 kB/s | 1.8 kB 00:00 Importing GPG key 0xA7317B0F: Userid : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>" Fingerprint: D0BC 747F D8CA F711 7500 D6FA 3746 C208 A731 7B0F From : https://packages.cloud.google.com/yum/doc/yum-key.gpg Is this ok [y/N]: y #+ENDSRC. . .

7 My gcloud project:

Some sample output from my gcloud init

root@vm4-pyenv /etc/yum.repos.d[190] $ gcloud init Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag: gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues. Checking network connection…done. Reachability Check passed. Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)? Y

Go to the following link in your browser:

https://accounts.google.com/o/oauth2/auth?code_challenge=l3sVpQ-4tWud9CTbanS7QsM8Ko-oehVWwASL8iELDAY&prompt=select_account&code_challenge_method=S256&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=openid+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/cloud-platform+https://www.googleapis.com/auth/appengine.admin+https://www.googleapis.com/auth/compute+https://www.googleapis.com/auth/accounts.reauth

Enter verification code: 4/xQFdwebRaWatw3JeHqgPDRvyvAtqtKm19doL4YVEAHKrp6zsxJMcfkY You are logged in as: [zintis@gmail.com].

Pick cloud project to use: [1] zintis-mapping-s-1575301886553 [2] Create a new project Please enter numeric choice or text value (must exactly match list item): 1

Your current project has been set to: [zintis-mapping-s-1575301886553].

Do you want to configure a default Compute Region and Zone? (Y/n)? Y

Which Google Compute Engine zone would you like to use as project default? If you do not specify a zone via a command line flag while working with Compute Engine resources, the default is assumed.

 [1] us-east1-b
 [2] us-east1-c
 [3] us-east1-d
 [4] us-east4-c
 [5] us-east4-b
 [6] us-east4-a
 [7] us-central1-c
 [8] us-central1-a
 [9] us-central1-f
[10] us-central1-b
[11] us-west1-b
[12] us-west1-c
...
[49] asia-northeast2-c
[50] asia-northeast3-a
Did not print [18] options.

Too many options [68]. Enter "list" at prompt to print choices fully. Please enter numeric choice or text value (must exactly match list item): 5

Your project default Compute Engine zone has been set to [us-east4-b]. You can change it by running [gcloud config set compute/zone NAME].

Your project default Compute Engine region has been set to [us-east4]. You can change it by running [gcloud config set compute/region NAME].

Created a default .boto configuration file at [/root/.boto]. See this file and [https://cloud.google.com/storage/docs/gsutil/commands/config] for more information about configuring Google Cloud Storage. Your Google Cloud SDK is configured and ready to use!

  • Commands that require authentication will use zintis@gmail.com by default
  • Commands will reference project `zintis-mapping-s-1575301886553` by default
  • Compute Engine commands will use region `us-east4` by default
  • Compute Engine commands will use zone `us-east4-b` by default

Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects.

Run gcloud topic configurations to learn more.

Some things to try next:

  * Run `gcloud --help` to see the Cloud Platform services you can interact with
    And run `gcloud help COMMAND` to get help on any gcloud command.
  * Run `gcloud topic --help` to learn about advanced features of the SDK like
    arg files and output formatting
  root@vm4-pyenv /etc/yum.repos.d[191] $
  root@vm4-pyenv /etc/yum.repos.d[191] $gcloud --help
  NAME
    gcloud - manage Google Cloud Platform resources and developer workflow

SYNOPSIS
    gcloud GROUP | COMMAND [--account=ACCOUNT]
    [--billing-project=BILLING_PROJECT] [--configuration=CONFIGURATION]
    [--flags-file=YAML_FILE] [--flatten=[KEY,...]] [--format=FORMAT]
    [--help] [--project=PROJECT_ID] [--quiet, -q]
    [--verbosity=VERBOSITY; default="warning"] [--version, -v] [-h]
    [--impersonate-service-account=SERVICE_ACCOUNT_EMAIL] [--log-http]
    [--trace-token=TRACE_TOKEN] [--no-user-output-enabled]

DESCRIPTION
    The gcloud CLI manages authentication, local configuration, developer
    workflow, and interactions with the Google Cloud Platform APIs.

GLOBAL FLAGS
     --account=ACCOUNT
    Google Cloud Platform user account to use for invocation. Overrides the
    default core/account property value for this command invocation.

     --billing-project=BILLING_PROJECT
    The Google Cloud Platform project that will be charged quota for
    operations performed in gcloud. If you need to operate on one project,
    but need quota against a different project, you can use this flag to
    specify the billing project. If both billing/quota_project and
    --billing-project are specified, --billing-project takes precedence.
    Run $ gcloud config set --help to see more information about
    billing/quota_project.

     --configuration=CONFIGURATION
    The configuration to use for this command invocation. For more
    information on how to use configurations, run: gcloud topic
    configurations. You can also use the CLOUDSDK_ACTIVE_CONFIG_NAME
    environment variable to set the equivalent of this flag for a terminal
    session.

7.1 Home