Node, NPM 설치 상태에서 가장 빠르게 HTTP 서버 띄우기 리눅스

가끔 급하게 HTTP 서버를 띄워야 할 때가 있다. 이때 NPM이 설치되어 있다면, http-server 패키지를 이용해 매우 쉽고 빠르게 서버를 띄울 수 있다.

1. http-server를 설치한다.

# npm install http-server -g

2. 원하는 위치에서 http-server를 실행한다.

$ http-server -o --cors

이제 http://localhost:8080/ 으로 접속하면 현재 디렉터리의 파일들을 확인할 수 있다.

아래는 실제 실행 결과이다.

$ sudo npm install http-server -g
[sudo] password for setzer:
/usr/bin/http-server -> /usr/lib/node_modules/http-server/bin/http-server
/usr/bin/hs -> /usr/lib/node_modules/http-server/bin/http-server
http-server@0.8.0 /usr/lib/node_modules/http-server
├── opener@1.4.1
├── corser@2.0.0
├── colors@1.0.3
├── union@0.4.4 (qs@2.3.3)
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── ecstatic@0.7.6 (url-join@0.0.1, mime@1.3.4, minimist@1.1.1, he@0.5.0)
├── portfinder@0.4.0 (async@0.9.0, mkdirp@0.5.1)
└── http-proxy@1.11.1 (eventemitter3@1.1.0, requires-port@0.0.1)
setzer@blackjack:~/git/mobile-angular-ui$ http-server -o --cors
Starting up http-server, serving ./ on: http://0.0.0.0:8080
Hit CTRL-C to stop the server
[Fri, 12 Jun 2015 12:20:43 GMT] "GET /" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"

Leave Comments