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
- May 22, 2020 How to Resolve Can't Open AOL Desktop Gold Problem? by Lisa Scott
- May 16, 2020 How Microsoft Windows 10 Reached the Milestone of 1 Billion Active Devices? by Software Codes
- May 5, 2020 How to Change Macros in the Excel Visual Basic Language? by Sophia Williams
- Apr 29, 2020 AOL Mail Settings For Outlook. by Anmol Kumar
- Apr 23, 2020 How to Fix Mozilla Firefox Not Responding ? by wats josephine
Most Viewed Articles
- 629 hits Google Lighthouse- Auditing & Enhancing Shopify Theme Performance by Anuj Sharma
- 422 hits Www RR Com Toll-Free 1-800-414-2180 by Rachel Cooper
- 410 hits How Trading Strategies Software Helps to Grow Your Business? by Build Alpha
- 405 hits Collect Plausible Information on SCADA Now by James Finch
- 402 hits AVG Tech Support Phone Number by Amy Wilson
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...
L'arte del tatuaggio maori e i tatuaggi Maori tradizionali sono estremamente unici; questi rigorosi tatuaggi Maori tradizionali hanno la loro...
Generic Viagra is an effective medicine for treatment of erectile dysfunction (ED) or male impotence. It is a generic equivalent of Viagra. Both...