Sharing this because maybe there are many people like me who struggling how to deploy nuxt ssr to cpanel.so, here is the steps:
1. Create basic node app on cpanel
first, create node app on cpanel. You can find it on
Software - Setup Node.js App
then fill the input like follows:
2. Upload your nuxt project
after creating the app, next step is upload your nuxt project into your folder that you've been specified on step 1.
3. Setting up
you can either using ssh or terminal. here i am using terminal on cpanel. to do so, copy the command from Enter to the virtual environment
. Then go to cpanel dashboard -> terminal
.
paste that command there, and execute the following commands:
-
npm run install
to install all your deps -
npm run build
you can skip if you're already build it. -
npm install pm2
to install pm2 process manager -
npx pm2 start npm --name "nuxtjs" --interpreter bash -- start
to run the "nuxtjs" app using pm2. "nuxtjs" is your app name.
4. Setting the .htaccess
after that, now you need to add this code to your .htaccess on public_html if it's not subdomain, or on the specified folder if subdomain:
Options +FollowSymLinks -Indexes
IndexIgnore *
DirectoryIndex
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://localhost:<your Port>/$1 [P]
</IfModule>
change your port with the actual port that your app use.
Done!
sorry if my explanation not that good. But I hope you get what I mean.
More of my articles.
Top comments (10)
kalau gak ada SSH nya bisa bang?
Biasanya ada terminal di cpanelnya. Bisa lewat situ.
oke thanks infonya
Oke..
ec2 please, havent seen a single post on it
i am not using ec2, so I cant give any info for the moment. :)
vorlume.com/nzesalem/stories/how-t...
How can I find a port? Please explain by video
How did you solve your problem?
makasih banyak, konten nya membantu saya