DEV Community

Cover image for Deploying NUXT SSR to CPanel
Kiraweb
Kiraweb

Posted on

Deploying NUXT SSR to CPanel

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:
Alt Text

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:

  1. npm run install to install all your deps
  2. npm run build you can skip if you're already build it.
  3. npm install pm2 to install pm2 process manager
  4. 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>
Enter fullscreen mode Exit fullscreen mode

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.

Discussion (2)

Collapse
slidenerd profile image
slidenerd

ec2 please, havent seen a single post on it

Collapse
dzulqurnain profile image
Kiraweb Author

i am not using ec2, so I cant give any info for the moment. :)