티스토리 뷰

Nextjs

next js 배포

Aairon 2019. 8. 20. 11:38
반응형

공식문서에 보면 next js를 배포할 대 zeit이나 now를 사용하면 간편하게 할 수 있다고 나와있지만, 기존 서비스에 아파치가 이미 띄워져 있어 다른 방법을 찾아야 했다.

next js의 서버를 실행 시키면 localhost:3000 으로 서버가 열리기 때문에 아파치의 virtual host와 proxy 설정을 통해 해당하는 도메인으로 접속시 next js를 보도록 만들었다. 그 후 서버의 관리를 위해 pm2를 사용해 next js서버를 열었다.

아래의 명령어를 터미널에 입력하면 pm2를 사용해 next js를 띄울 수 있다.


# for development
pm2 start npm --name "next" -- run dev

# for production
npm run build
pm2 start npm --name "next" -- start


"scripts": {
"start": "node ./node_modules/.bin/pm2 start app.js -i max --attach"
}

출처: https://gist.github.com/denipotapo/b66f74c353c0e5d1dfb2df1c60b6f737


반응형

'Nextjs' 카테고리의 다른 글

Next js 튜토리얼 1편: 시작하기  (0) 2019.09.30
react get browser size  (0) 2019.09.10
next js scroll  (0) 2019.09.06
next js에 css 적용 (bootstrap, styled-component)  (3) 2019.08.22
head 설정  (0) 2019.08.20
댓글