Hosting NextJs13 Apache
Answered
West African Lion posted this in #help-forum
West African LionOP
Hi, I would like to host my NextJs13 App in my unbuntu server.
for other website (not using nextJs) it work like:
<VirtualHost :80>
DocumentRoot /var/www/sites/myWebsite/dist
ServerName MyWebsite.domainName.fr
ServerAlias.MyWebsite.domainName.fr
<Directory /var/www/sites/MyWebsite/dist>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
but with nextJs I don't have dist folder with entryPoint compilated (I just have .next/ folder)
I would like to do something like:
<VirtualHost :80>
DocumentRoot /var/www/sites/MyNextJSApp
ServerName MyNextJSApp.domainName.fr
ServerAlias.MyNextJSApp.domainName.fr
<Directory /var/www/sites/MyNextJSApp>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
can someone help me please?
for other website (not using nextJs) it work like:
<VirtualHost :80>
DocumentRoot /var/www/sites/myWebsite/dist
ServerName MyWebsite.domainName.fr
ServerAlias.MyWebsite.domainName.fr
<Directory /var/www/sites/MyWebsite/dist>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
but with nextJs I don't have dist folder with entryPoint compilated (I just have .next/ folder)
I would like to do something like:
<VirtualHost :80>
DocumentRoot /var/www/sites/MyNextJSApp
ServerName MyNextJSApp.domainName.fr
ServerAlias.MyNextJSApp.domainName.fr
<Directory /var/www/sites/MyNextJSApp>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
can someone help me please?
8 Replies
.next folder works only if you use next server
the idea is you basically start a nextjs server inside your server
so you basically do
npm run build && npm startAnswer
West African LionOP
I will try that, thanks !
You'll probably have to look into something like PM2 to keep the process alive and restart it incase of failures
@West African Lion Did it work
West African LionOP
Yes it work 🙂 I can send you my VirtualHost if you want
@West African Lion Yes it work 🙂 I can send you my VirtualHost if you want
Congrats, No thanks, mind marking @Clown message as answer?