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
[email protected] /usr/lib/node_modules/http-server
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected])
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


최근 엮인글