skip to Main Content

In react you can transfer static files in the build folder to cpanel, direct admin or other shared server.
What is the solution for nextjs?
without using the nodejs and install it on the server

2

Answers


  1. Chosen as BEST ANSWER

    I found the way myself.

    On a dedicated server, as long as you are connected to the server using Putty, you can load the site by creating a virtual host. by example

    <VirtualHost *:80>
       ServerName digiattar.com
       ServerAlias www.digiattar.com
    
       ProxyRequests Off
       ProxyPreserveHost On
       ProxyVia Full
    
       <Proxy *>
           Require all granted
       </Proxy>
    
       ProxyPass / http://localhost:8080/
       ProxyPassReverse / http://localhost:8080/
    </VirtualHost>
    

    If you enter the domain address in the browser, the server points to the localhost address and port 8080, on which Nextjs is running.

    After completing the steps, you can go to the root of your project and run Nextjs as like it is on your computer using the command npm run dev or next start or etc

    but after close putty everything expire, using pm2 for this problem


  2. If your application does not generate dynamic pages at runtime you can use nextjs export static which will generate static HTML for you and then you could deploy on cpanel

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search