Setting up and managing our own servers can take a considerable amount of time especially if we are not a day to day linux user. That is why we see things like serverless and containers catching on. There’s another option out there though too and it’s called unikernels.
What are unikernels though? Unikernels are simple single application operating systems. Instead of deploying our software on top of linux unikernels create an operating system out of our application and run only that app – nothing else. There’s no concept of usernames/passwords or sshin’g into the application as it is only running one application. Traditionally unikernels have been hard to work with as they used to require expert level of systems knowledge. Now there are newer tools like OPS that fix that.
In the next few minutes we are going to build, run, then deploy a php unikernel. First things first let’s download OPS from https://ops.city:
We can also download and build it from github. can always go to https://github.com/nanovms/ops and build it from source – it’s written in Go.
3. Build and Run our First PHP Unikernel
Now that we have that let’s create a temporary working directory:
For this simple example we’ll just use the built-in php webserver just to keep things simple. Put this into a config.json file:
What this does is tell the built in php webserver to listen on port 3030 and place the index.php file onto the otherwise barren filesystem. We’ll put this into a index.php:
Now let’s run it via:
Here we tell OPS that we wish to use PHP7. When we are running this it will first download a php package then it looks at the config file and finally opens up a local port on 3030.
We should see this:
Assuming that boots we should now be able to hit it with curl:
4. Deploy to Google Cloud
Great! We just ran our first php unikernel! Now let’s deploy it. Assume have a google cloud account we’ll need a project id, a service worker key, and a cloud storage bucket to place our built images in. We definitely don’t have to use google but we are using it for this example.
We are going to slightly modify our config.json file and put this inside:
What this does is tell OPS to place our built image in the bucket ‘my-bucket’ and use ‘my-project-id’. We also changed the port to 80 which is the default HTTP port.
If we got a service worker key we can put that somewhere to source like so:
Then let’s build the image. What this does is create a virtual machine on Google Cloud that contains only our application with the php interpreter. It’s important to note that there is no underlying linux system here. When the virtual machine boots it boots straight into our application just like it did locally. This make it run much faster and safer than linux.
We should see something like this when it’s done building:
Now let’s create an instance. Keep in mind an instance is the server. The image is the actual disk image of the server.
If we look at the instance list we can see it running:
Now if we hit that ip up with curl we can see our php unikernel running in Google Cloud!
We can also see the logs from the unikernel:
Congratulations! We’ve built, ran and deployed our first php unikernel on google cloud – now we can go show our friends that we don’t need servers to deploy our applications anymore! Unikernels give us the convenience of containers and serverless with the protection and speed of traditional virtual machines.
Most Recent Articles
- Nov 11, 2020 Cloud Security Services - Your Company Needs it Too by Cyber Defense Group
- Nov 9, 2020 How to Fix Service Host Superfetch High Disk Usage in Windows 2020 by mojjis
- Nov 9, 2020 Hire Dedicated Magento Developers by Gaurav Jain
- Nov 3, 2020 How Do I Change Facebook Password? by wats josephine
- Oct 23, 2020 How to fix Tubi.tv/Activate Issues? by Patrika Jones
Most Viewed Articles
- 867 hits Google Lighthouse- Auditing & Enhancing Shopify Theme Performance by Anuj Sharma
- 545 hits Www RR Com Toll-Free 1-800-414-2180 by Rachel Cooper
- 525 hits WHY SMART UX/UI DESIGN IS IMPORTANT FOR BUSINESS by Floria lena
- 507 hits How Trading Strategies Software Helps to Grow Your Business? by Build Alpha
- 495 hits Troubleshoot Common login issues in Aol, ATT ,bellsouth by rondarousey
In today’s competitive world, one must be knowledgeable about the latest online business that works effectively through seo services....
Are you caught in between seo companies introduced by a friend, researched by you, or advertised by a particular site? If that is the...
Walmart is being sued by a customer alleging racial discrimination. The customer who has filed a lawsuit against the retailer claims that it...
Facebook, the best and most used social app in the world, has all the social features you need. However, one feature is missing. You cannot chat...
Cash App cannot send money directly from PayPal to the Cash app, but you can use your bank account to transfer funds between them. After this there...