Run Web Server – How to Run a Web Server from Any Directory

14.04serversoftware-recommendation

I am writing a small website, but I do NOT want to figure out how to install and configure complete LAMP stack to test the website from my ~/home directory. That will be completely disruptive and unnecessary.

All I want is to have a directory, e.g. ~/home/Documents/Website and run a small web server from that folder as the website's "home" folder.

I know Jekyll can do something similar, but it only seems to work with Ruby/Jekyll-based sites that it builds and configures.

Isn't there some small web server program that I can easily install and then just run very simply?

For instance, if I just needed to run something like e.g. simple-server serve ~/home/Documents/Website from a command line and then navigate to e.g. localhost:4000 or whatever to test the site, that would be perfect.

If this is already possible in Ubuntu and I just don't know how, please let me know.

Best Answer

If you have php installed you can use php built-in server to run html/css and/or php files :

cd /path/to/your/app
php -S localhost:8000

As output you'll get :

Listening on localhost:8000
Document root is /path/to/your/app
Related Question