Portable webserver for static site in Ubuntu - webserver

I'm working on some pre-compiled website and I have a web-development project with only a static files in it (HTML, CSS, JS, images, fonts, etc).
In order to test it on development machine I need a web-server capable of serving static files over HTTP. I don't want to use some heavy artillery like Vagrant and nginx/apache. I'm looking for a web-server that can be invoked from the command line with a simple command and/or that have a configuration file stored in the project, not in the system.
What are my options in the field of portable web-servers? I need it to run on Ubuntu.
I've heard about Python's SimpleHTTPServer and PHP's built-in webserver. Are there any other alternatives?

I would not dismiss Nginx. Nginx is quite lightweight and very good at serving static data.

Related

Build file server to upload files from IPhone and Mac using Raspberry Pie

Is it possible to build a File storage server using Raspberry Pi 3 to upload files from apple device using Wifi?
Yes, I believe so. Use nginx or Apache to host it and have a PHP or JS script that accepts files from an HTML form and saves them.
For me, Apache is easier to use, but I prefer nginx as it is much faster.
Once you have the server and HTML/PHP/JS set up just navigate to your Pi's IP in Safari. There you go!
You do, however, have limitations. Saving files to an external flash drive is your best option, unless your Pi is only being used as a server. In that case, make sure you chown the folder where you would like to save the files to the user that the server uses (www-data for nginx, I think it's the same for Apache)
If I was unclear about anything, just let me know!

A good development workflow for static sites with one or two PHP files?

so I'm still learning a lot about best practices and local development workflows when working on my web projects. At the moment, when I develop a static site locally I tend to use Grunt + Bower + some static site generator to start up a local server really quickly. On the other hand when I'm working on a more PHP focused project I will set up a Vagrant box, depending on the focus. My question though is what is the best way to locally develop static sites that have one or two PHP files within them, such as a handler for a contact form? I can't run the PHP on my local server under grunt (at least as my current workflow stands — I use the browsersync plugin — is there a way to do this?), but using Vagrant seems like overkill, especially sometimes when I've settled into using a static site generator, and later realise I need to write a server side script.
You can use nginx to reverse proxy requests to your localhost (your machine). This would route *.php to other IP (a vagrant machine just for those two PHP that happened later) and all other static request to you local grunt server.
With this setup your development site would ever be in http://localhost/ or http://localhost:xxxx where xxx is some port. But, depending on the target requested (php, jpg, html, etc) the request will be routed to right place.

Deploying Sinatra app .rb

I know this is probably a stupid question. But I created a .rb file with Sinatra framework and I am not sure how to "deploy" it. When I posted the file on the server I just get a simple text file that reads back my code. It works great when I run it with Sinatra.
Thanks in advance!
It looks like your web server (Apache?) is just serving you with your Ruby script (that is a text, ASCII file) instead of running it (that is: instead of passing it through the Ruby interpreter).
Hence:
Is the Ruby interpreter installed on your server?
Is your web server configured to run Ruby scripts (files terminating with ".rb")
through the Ruby interpreter?
And, is Sinatra itself installed on your web server?
Anyway, Ruby applications (Rails, Sinatra, Padrino) are usually deployed to a server using GIT. Have a look at Heroku and Engine Yard.
Also, there are tools specifically designed to help the developer in deploying Ruby applications. Have a look at Capistrano or Vlad and/or Google for "how to deploy a sinatra application".
For Sinatra/Rails/etc, most people use a Webserver (ie Apache, Nginx, etc) AND an Application Server (Thin, Passenger, Unicorn). For a simple app these can live on the same host. The webserver manages the incoming traffic and the application server executes the ruby code and passes results to the webserver.
When you execute ruby app.rb to run your Sinatra application, you're actually loading up WEBrick which is an application server. Since your development machine is local, you can access it directly at localhost:3000 or some similar address.
Look into tutorial on setting up your webserver with Thin, it's one of the easier ones to work with. When/if you outgrow it, then look into Unicorn.

Create a Virtual Machine from php, perl, or python? Is it possible or has it been done?

I had this thought experiment of installing an OS on a php server over http.
So, what I am asking: Would it be possible to build a VM player (using the server's resources) from a server language like perl, php, or python? Or is my understanding of servers and security lacking in a way that would show this to be impossible?
It's not as outlandish as you might think.
UeberHacker Fabrice Bellard (the guy who created QEMU, among many other notable achievements) recently did precisely that. He created a VM in Javascript. That runs a virtual Linux system in your Web browser:
http://linuxhelp.blogspot.com/2011/05/pc-emulator-in-javascript-run-linux-in.html

What is WEBDAV?

I want to use WebDAv server to share files among systems and (iPod or iPhone) in my iphone project. To use it, do I have to use an individual webserver? Or is it a built in facility?
WebDAV is a way to share files through a web server, which includes functionality for file locking and versioning.
Presumably, you would run Apache or another WebDAV-savvy web server, enabling access to a folder and its contents through the setting of relevant permissions.
This service would be run on a server somewhere — such as a Mac OS X workstation, which has Apache installed by default — and which has files that you want to present to the outside world.
Your iPhone device would connect to the WebDAV server through a WebDAV client; for example, DAV-E. The client locates and displays a list of files and folders, allowing uploads and downloads.
It typically isn't a built-in facility, but can be enabled as an extension of existing webservers, e.g mod_dav for Apache, WebDAV publishing for IIS, etc.
Short for Web-based Distributed Authoring and Versioning.
WebDav is sometimes referred to as DAV.
An IETF standard set of platform-independent extensions to HTTP
It allows users to collaboratively edit and manage files on remote Web servers.
It features XML properties on metadata, locking - which prevents authors from overwriting each other's changes - namespace manipulation and remote file management.
To know more Visit the FAQ