Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.
Comments
Craig Morrison
It can be very useful to spin up a quick server. php -S localhost:8000 also works in recent versions.
Farnabaz
This command requires PHP 5.4.0 and above
Rhys Lloyd
Requires installation, but with Node:
npm i -g http-server
Once installed, you can run from any directory:
http-server
Umar
I use “http-server” regularly. It is simpler and easy to remember.
samar taj shaikh
okay i did as you commented in the terminal of my linux OS –
$ http-server
but i am getting error as-
“http-server: command not found”
michael
Oh man. Where has this been all my life. This has been an immense time-saver for me, being able to spin up a standalone server for any given directory, pass some parameters — boom, local server to test on. Thanks for posting this!
Eri
@samar you need to install http-server first:
npm i -g http-server
You need npm to install http-server, and to run that npm command you need npm, and to have npm installed you need Node :)
Install Node
Install npm
install http-server
All 3 of them can be installed with only few lines…
So google them all.
Tim
npx serve and npx http-server – both work if you have node installed with npm@5.2.0 or greater.
npx has been around since roughly 2017, and I believe node@8.2.0 was the first version it could be used in (because that is the first version of node using npm@5.2.0 or greater)
Rich Werden
I always use live-server – Like http-server, but includes watching for changes
Chris Johnson
The node.js / NPM commands above can be achieved in one line as per title of article.
npx serve
chandrasekar
Nice one, thanks for the wonderful work sir.
WeakLinks
Running this python3 -m http.server --cgi 8080 from any preferred file location works awseome,,,actually doing it via termux
Craig Morrison
It can be very useful to spin up a quick server.
php -S localhost:8000also works in recent versions.Farnabaz
This command requires PHP 5.4.0 and above
Rhys Lloyd
Requires installation, but with Node:
Once installed, you can run from any directory:
Umar
I use “http-server” regularly. It is simpler and easy to remember.
samar taj shaikh
okay i did as you commented in the terminal of my linux OS –
$ http-server
but i am getting error as-
“http-server: command not found”
michael
Oh man. Where has this been all my life. This has been an immense time-saver for me, being able to spin up a standalone server for any given directory, pass some parameters — boom, local server to test on. Thanks for posting this!
Eri
@samar you need to install http-server first:
npm i -g http-server
You need npm to install http-server, and to run that npm command you need npm, and to have npm installed you need Node :)
Install Node
Install npm
install http-server
All 3 of them can be installed with only few lines…
So google them all.
Tim
npx serveandnpx http-server– both work if you have node installed with npm@5.2.0 or greater.npxhas been around since roughly 2017, and I believe node@8.2.0 was the first version it could be used in (because that is the first version of node using npm@5.2.0 or greater)Rich Werden
I always use live-server – Like http-server, but includes watching for changes
Chris Johnson
The node.js / NPM commands above can be achieved in one line as per title of article.
npx serve
chandrasekar
Nice one, thanks for the wonderful work sir.
WeakLinks
Running this
python3 -m http.server --cgi 8080from any preferred file location works awseome,,,actually doing it via termuxHanif
How to know in the php server’ IP?