Thursday, August 30, 2018

Quickly Deploy WordPress & phpMyAdmin on Alibaba Cloud with ROS

This article was originally published on Alibaba Cloud. Thank you for supporting the partners who make SitePoint possible.

Think you got a better tip for making the best use of Alibaba Cloud services? Tell us about it and go in for your chance to win a Macbook Pro (plus other cool stuff). Find out more here.

This document shows how to deploy a WordPress site and phpMyAdmin application using the ROS template with a single click.

Introduction

Many users do not have in-house technical capabilities to build and manage a website. They have teams who can manage the content but not the infrastructure that comes along with it. Currently available solutions are suitable for a limited period when the requirements are basic, but as soon as they require customization, high availability, and scalability, additional solutions supporting scaling are needed.

The ROS stack template (WordPressCluster-phpMyAdmin.ros) discussed in this document helps address the high availability and scalability requirements of such users. With a single click, it creates the entire VPC stack, Server Load Balancer, Auto Scaling, ECS, RDS, and other instances, deploys WordPress and phpMyAdmin, and configures Auto Scaling to guarantee that any new instances can be added and configured without manual intervention.

Prerequisites

  • Availability of an OSS bucket.
  • RAM user with read and write access to the OSS bucket.
  • Understanding of ROS and ability to create ROS stack templates and stacks from the console.

Architecture overview

Architecture

This diagram provides an overview of the deployment architecture that is generated based on the template WordPressCluster-phpMyAdmin.ros.

Three types of users access the infrastructure:

End users, who access the website hosted on WordPress through a URL that is resolved to a Public Server Load Balancer instance.

WordPress is hosted on Apache web servers. The servers have their document root set to /wwwroot which is on an OSS bucket shared across the web servers using OSSFS (a FUSE-based file system officially provided by Alibaba Cloud).

RAM users who have the access permission of the OSS bucket can mount the OSS bucket on the ECS instance.

The RDS for MySQL database holds the WordPress content and is accessed from the web server over its intranet connect string.

System administrator, who can access to the VPC environment through an SSH logon to the JumpBox (bastion host).

The JumpBox has an elastic IP and is accessed over the Internet.

The access through JumpBox is to manage the instances inside the VPC.

phpMyAdmin is installed on the JumpBox and is accessible over the Internet.

In this way, the administrators can administer the RDS database.

Content managers, who can access the WordPress Management console through the Internet.

Access to all these services can be controlled by security groups and can be configured as per the environment.

The Template Overview

Click WordPressCluster-phpMyAdmin.ros to download the ROS stack template for use.

Note: In the template, the ZoneId is set as eu-central-1a, and the ImageId is m-gw8efmfk0y184zs0m0aj. You can modify the ZoneId and the ImageId according to the zones and images supported in the ROS console. Log on to the ROS console, click ECS Instance Information, select a region, and click ECS Zone or ECS Image to view all the zones or images supported in this region.

Based on the WordPressCluster-phpMyAdmin.ros stack template, the system creates the VPC, Server Load Balancer, VSwitch, NAT Gateway, Security Groups, and ECS instances for JumpBox, Elastic IP for JumpBox, Auto Scaling for ECS instances, and RDS instance.

It takes the following input parameters to make the resource stack generic enough to be deployable for any user in any region.

parameters1

parameter2

According to the template, the system installs httpd, mysql-client, PHP, OSSFS, phpMyAdmin, and WordPress on the JumpBox and also configures them in the UserData section of the ALIYUN::ECS::Instance resource.

The following is a snippet of the UserData section of the JumpBox.

 "ossbucketendpoint=",
   {
   "Ref": "OSSBucketEndPoint"
   },
   "\n",
   "DatabaseUser=",
   {
   "Ref": "MasterUserName"
   },
   "\n",
   "DatabasePwd=",
   {
   "Ref": "MasterDBPassword"
   },
   "\n",
   "DatabaseName=",
   {
   "Ref": "DBName"
   },
   "\n",
   "DatabaseHost=",
   {
   "Fn::GetAtt": ["Database", "InnerConnectionString"]
   },
   "\n",
   "yum install -y curl httpd mysql-server php php-common php-mysql\n",
   "yum install -y php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc\n",
   "yum install -y phpmyadmin\n",
   "sed -i \"s%localhost%$DatabaseHost%\" /etc/phpMyAdmin/config.inc.php\n",
   "sed -i \"s%Deny,Allow%Allow,Deny%\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "sed -i \"s%Deny from All%Allow from All%\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "sed -i \"/<RequireAny>/a Require all Granted\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "chkconfig httpd on\n",
   "service httpd stop\n",
   "wget  
   https://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm\n",
   "yum install -y ossfs_1.80.3_centos6.5_x86_64.rpm\n",
   "echo $ossbucket:$ossbucketaccesskey:$ossbucketsecret >> /etc/passwd-ossfs\n",
   "chmod 600 /etc/passwd-ossfs\n",
   "mkdir $ossbucketmountpoint\n",
   "chmod -R 755 $ossbucketmountpoint\n",
   "echo #This script will automount the ossbucket\n",
   "echo umount $ossbucketmountpoint >> /usr/local/bin/ossfs-automount.sh\n",
   "echo #Mounting OSS Bucket\n",
              "echo ossfs $ossbucket $ossbucketmountpoint -ourl=http://$ossbucketendpoint -o allow_other -o mp_umask=0022 -ouid=48 -ogid=48 >> /usr/local/bin/ossfs-automount.sh\n",
"chmod 755 /usr/local/bin/ossfs-automount.sh\n",
"echo /usr/local/bin/ossfs-automount.sh >> /etc/rc.d/rc.local\n",
"chmod +x /etc/rc.d/rc.local\n",
"/usr/local/bin/./ossfs-automount.sh\n",
"wget http://WordPress.org/latest.tar.gz\n",
"tar -xzvf latest.tar.gz\n",             
"sed -i \"s%database_name_here%$DatabaseName%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%username_here%$DatabaseUser%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%password_here%${DatabasePwd:-$DatabasePwdDef}%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%localhost%$DatabaseHost%\" WordPress/wp-config-sample.php\n",
"mv WordPress/wp-config-sample.php WordPress/wp-config.php\n",
"cp -a WordPress/* $ossbucketmountpoint\n",
"chmod -R 755 /wwwroot/*\n",
"rm -rf WordPress*\n",
"service httpd start\n",
"done\n"

The UserData section deploys WordPress on the OSS bucket which can be mounted to the web servers created using Auto Scaling. This guarantees that the web servers have the updated content from the document root.

The web servers are started through Auto Scaling. The installation and configuration of httpd, PHP, and ossutil, mounting of DocumentRoo, and starting of services are done in the UserData section of the Auto Scaling configuration.

The following is a snippet of the UserData section of the web server Auto Scaling configuration.

The post Quickly Deploy WordPress & phpMyAdmin on Alibaba Cloud with ROS appeared first on SitePoint.


by Joel Falconer via SitePoint

Tech Recruiting, Finding Niches & Starting Your Own Business

In this interview, Joe Woodham discusses recruiting for a tech start-up, finding your niche, and starting your own business.

Joe is known as the “intro guy” at Torii Recruitment, the specialist IT recruitment firm he founded in 2012. Finding a good fit in IT recruitment, he says, is a more nuanced challenge than just finding someone with the right skills.

The Interview

In one sentence how would you describe yourself?

I’m highly driven and passionate about business. However, I focus on maintaining balance in all aspects of my life. I love to enjoy myself, challenge myself and grow as a person.

In one sentence, how would describe your career?

My career has been a constant progression in terms of self-development and learning new skills. I’ve been lucky to fall into what I do and I’ve enjoyed the challenges along the way.

In one sentence, how would you describe your business Torii Recruitment?

Torii is agile and able to move quickly, enabling us to understand the market and our clients’ pain points and deliver a high-touch service in a skill-short market.

Finding your niche

During your talk in the WeTeachMe Master’s Series, you mentioned finding a niche and then building a business around filling it. How did you determine IT recruitment was the correct niche for your business?

I started my career in IT Recruitment and it wasn’t IT being the niche. The niche was actually working with specific skill sets within IT that the market was experiencing a shortage of.

Working with companies, understanding their pain points and looking at where the market was heading, I was able to leverage the skills I’d built to deliver a service the market and my clients needed.

You also spoke of your big learning curve when starting a business. Can you share some of them here?

When I started a business, I was good at IT Recruitment. However, when I started working for myself I quickly realized there was a lot more that was happening in the background. I had to start working on building a brand/image in the market which people knew me/Torii for. There were so many new things I had to master and make decisions on that I had taken for granted — small things like the software I used, the accounting system we used, and how I sent an invoice. I basically had to learn very quickly, and fill all the gaps to be able to run a business.

Recruiting: Joe Woodham with the WeTeachMe teamJoe Woodham (second left) at WeTeachMe’s Masters Series

The post Tech Recruiting, Finding Niches & Starting Your Own Business appeared first on SitePoint.


by Angela Phung via SitePoint

Advanced CSS Theming with Custom Properties and JavaScript

Throughout this tutorial on CSS theming, we’ll be using CSS custom properties (also known as CSS variables) to implement dynamic themes for a simple HTML page. We’ll create dark and light example themes, then write JavaScript to switch between the two when the user clicks a button.

Just like in typical programming languages, variables are used to hold or store values. In CSS, they’re typically used to store colors, font names, font sizes, length units, etc. They can then be referenced and reused in multiple places in the stylesheet. Most developers refer to “CSS variables”, but the official name is custom properties.

CSS custom properties make it possible to modify variables that can be referenced throughout the stylesheet. Previously, this was only possible with CSS preprocessors such as Sass.

Understanding :root and var()

Before creating our dynamic theming example, let’s understand the essential basics of custom properties.

A custom property is a property whose name starts with two hyphens (--) like --foo. They define variables that can be referenced using var(). Let’s consider this example:

:root {
  --bg-color: #000;
  --text-color: #fff;
}

Defining custom properties within the :root selector means they are available in the global document space to all elements. :root is a CSS pseudo class which matches the root element of the document — the <html> element. It’s similar to the html selector, but with higher specificity.

You can access the value of a :root custom property anywhere in the document:

div {
  color: var(--text-color);
  background-color: var(--bg-color);
}

You can also include a fallback value with your CSS variable. For example:

div {
  color: var(--text-color, #000);
  background-color: var(--bg-color, #fff);
}

If a custom property isn’t defined, their fallback value is used instead.

Defining custom properties inside a CSS selector other than the :root or html selector makes the variable available to matching elements and their children.

CSS Custom Properties vs Preprocessor Variables

CSS pre-processors such as Sass are often used to aid front-end web development. Among the other useful features of preprocessors are variables. But what’s the difference between Sass variables and CSS custom properties?

  • CSS custom properties are natively parsed in modern browsers. Preprocessor variables require compilation into a standard CSS file and all variables are converted to values.
  • Custom properties can be accessed and modified by JavaScript. Preprocessor variables are compiled once and only their final value is available on the client.

Writing a Simple HTML Page

Let’s start by creating a folder for our project:

$ mkdir css-variables-theming

Next, add an index.html inside the project’s folder:

$ cd css-variables-theming
$ touch index.html

And add the following content:

<nav class="navbar">Title</nav>
<div class="container">
  <div>
    <input type="button" value="Light/Dark" id="toggle-theme" />
  </div>
    <h2 class="title">What is Lorem Ipsum?</h2>
    <p class="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry...</p>
</div>
<footer>
  Copyright 2018
</footer>

We are adding a navigation bar using a <nav> tag, a footer, and a container <div> that contains a button (that will be used to switch between light and dark themes) and some dummy Lorem Ipsum text.

The post Advanced CSS Theming with Custom Properties and JavaScript appeared first on SitePoint.


by Ahmed Bouchefra via SitePoint

How to Use Material Design in Angular 6

Diagonal Slideshow with JavaScript & CSS

A slideshow with a “diagonal” look and three visible slides. A decorative background element expands to fullscreen when opening the content preview.The animations are powered by TweenMax.

The post Diagonal Slideshow with JavaScript & CSS appeared first on Best jQuery.


by Admin via Best jQuery

8 Travel Destinations If You Want To Live As A Digital Nomad (infographic)

Digital nomads, these borderless citizens of the world venture the globe with a minimal luggage of a mere device of internet connectivity, like a laptop and set off to their journeys to discover the far and wild. Well, not too wild and they will compulsorily need an internet connection to make...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Mehwish Mehmood via Digital Information World

Product Grid Style 4

The post Product Grid Style 4 appeared first on Best jQuery.


by Admin via Best jQuery