gcp web server

Here’s a quick script to stand up a web server based on Centos image. gcloud compute instances create [VM-NAME] \ --zone=[ZONE] \ --image-family=debian-9 \ --image-project=debian-cloud \ --tags=allow-ssh,allow-health-check \ --subnet=lb-subnet \ --metadata=startup-script='#! /bin/bash apt-get update apt-get install apache2 -y a2ensite default-ssl a2enmod ssl vm_hostname="$(curl -H "Metadata-Flavor:Google" \ http://169.254.169.254/computeMetadata/v1/instance/name)" echo "Page served from: $vm_hostname" | \ tee /var/www/html/index.html systemctl restart apache2'

January 8, 2020 · 1 min · ulysses

split a large file

How to split a large file. split -b 500MB httpd.log ll -lh total 1.9G -rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log -rw-r--r-- 1 root root 477M Mar 25 12:38 xaa -rw-r--r-- 1 root root 477M Mar 25 12:38 xab Split with an output file. split -b 200M httpd.log split.log ll -lh total 1.9G -rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logaa -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logab -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logac -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logad -rw-r--r-- 1 root root 154M Mar 25 12:52 split.logae

January 7, 2020 · 1 min · ulysses

scp

SCP is similar to the CP or copy command, but it’s done via a secure network. Here’s a CP command. cp /dir1/filename /dir2 You can use SCP to copy file to another system. It requires login. scp /dir1/filename user@server:/home/user This is using SCP to copy a file from 2 remote systems. scp user@host1:/home/user/dir1/file.txt user@host2:/home/user/dir2

January 6, 2020 · 1 min · ulysses

aws cloudwatch efs burst credits

Here’s how to get the EFS Burst Credits from CloudWatch via AWS CLI. aws cloudwatch get-metric-statistics \ --namespace "AWS/EFS" \ --metric-name BurstCreditBalance \ --dimensions "Name=FileSystemId,Value=fs-xxxxxxx" \ --start-time 2019-12-31T00:00:00Z \ --end-time 2019-12-31T01:00:00Z \ --statistics Average \ --period 3600 \ --profile default Notice the start time, end time, period and statistics. Here’s the CLI doc.

December 31, 2019 · 1 min · ulysses

aws rds backup permission

Here’s the IAM policy to allow RDS Backup or create a snapshot on AWS. { "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "rds:RestoreDBClusterFromSnapshot", "rds:DescribeDBSnapshots", "rds:CopyDBSnapshot", "rds:CopyDBClusterSnapshot", "rds:DeleteDBSnapshot", "rds:DeleteDBClusterSnapshot", "rds:CreateDBSnapshot", "rds:RestoreDBInstanceFromDBSnapshot", "rds:CreateDBInstance", "rds:DescribeDBClusterSnapshots", "rds:DescribeDBInstances", "rds:DescribeDBClusters", "rds:DeleteDBInstance", "rds:CreateDBClusterSnapshot", "rds:ModifyDBSnapshotAttribute", "rds:ModifyDBClusterSnapshotAttribute", "rds:ListTagsForResource", "rds:DeleteDBCluster", "ec2:DescribeSecurityGroups", "ec2:DescribeRegions", "ec2:DescribeAvailabilityZones", "ec2:DescribeVpcs", "ec2:DescribeAccountAttributes", "ec2:DescribeSubnets", "iam:GetUser", "iam:GetAccountAuthorizationDetails", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:CreateGrant", "kms:DescribeKey*", "kms:ListKeys", "kms:ListAliases", "kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKeyWithoutPlaintext", "kms:ListKeys", "kms:ListAliases", "kms:ListResourceTags" ], "Resource": "*" } ] }

December 31, 2019 · 1 min · ulysses

wordpress asking for ftp details

If WordPress is asking for FTP details when you’re trying to update a theme, plugin, or WordPress itself, you will need to edit your wp-config.php file to add the following line to your configuration. define('FS_METHOD','direct'); Save the file and try updating again. It shouldn’t ask you for FTP details.

December 26, 2019 · 1 min · ulysses

apache dockerfile

This Docker image contains Apache (httpd), a web server. Here’s the Dockerfile. FROM httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/ Build and run your Docker image. docker build -t my-app . docker run -dit --name my-running-app -p 8080:80 my-app Visit http://localhost:8080 to view your app.

December 25, 2019 · 1 min · ulysses

gcp static ip

Create a static IP. gcloud compute addresses create your-app-static-ip \ --region us-central1 List static IP. gcloud compute addresses list your-static-ip-name --region us-central1 # or gcloud compute addresses list --filter="name=('live-tfc-static-ip-address')" Release static IP. gcloud compute addresses delete your-app-static-ip \ --region us-central1

December 25, 2019 · 1 min · ulysses

static website on gke

Here’s how to run your web application on Google Kubernetes Engine. Create a Dockerfile. Place your web pages in the public-html directory. FROM httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/ Build a container image for Google Container Registry (GCR). # set your project export PROJECT_ID=[project_id] # build a container image docker build -t gcr.io/${PROJECT_ID}/your-app:v1 . # verify docker images docker images Upload the container image to GCR. # authenticate gcloud auth configure-docker # upload image docker push gcr.io/${PROJECT_ID}/your-app:v1 Create a container GKE cluster. ...

December 25, 2019 · 1 min · ulysses

xcode after catalina upgrade

I tried running git after the Mac OS Catalina upgrade and got this error. xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Here’s the fix. For some very odd reason, Apple does not automatically reinstall xcode after each Mac OS upgrade. You will need to either reset it or install it again. # Try reset first xcode-select --reset # Or install it if reset doesn't work xcode-select --install Close your terminal, and reopen and run git again.

December 25, 2019 · 1 min · ulysses