Set up your Bluehost account: Sign up for a Bluehost hosting plan and log in to the Bluehost control panel (cPanel).
Create a new Node.js application: In cPanel, navigate to the "Software" section and click on the "Node.js" icon. Select "Create Application."
Application root: Enter the desired root directory for your application (e.g.,
public_html/myapp
).Application URL: Choose a URL for your application (e.g.,
https://example.com/myapp
).Version: Select the desired version of Node.js (e.g., 14.x).
Click "Create."
Upload your application files: In the file manager interface, navigate to the root directory you specified during application creation (e.g.,
public_html/myapp
).- Click "Upload" to upload your application files (e.g.,
app.js
,package.json
, etc.). You can also use an FTP client like FileZilla to transfer the files.
- Click "Upload" to upload your application files (e.g.,
Install dependencies: In the file manager, navigate to your application's root directory (
public_html/myapp
).Right-click and select "Open Terminal."
Run the command
npm install
to install the dependencies specified in yourpackage.json
file.
Start your Node.js application: In the file manager, go to your application's root directory (
public_html/myapp
).- Right-click on your main file (e.g.,
app.js
) and select "Manage Application" > "Start."
- Right-click on your main file (e.g.,
Set up domain/subdomain: In cPanel, navigate to the "Domains" section and select "Subdomains" or "Addon Domains" to set up your desired domain or subdomain.
Enter the subdomain name or choose a new domain.
Set the document root to the directory where your Node.js application is located (e.g.,
public_html/myapp
).
Configure any additional settings: Depending on your application's requirements, configure any additional settings required, such as environment variables or database connections.
For environment variables, you can add them through the cPanel interface or create a
.env
file in your application's root directory.For database connections, you may need to set up the appropriate credentials or configurations within your application.
Test your application: Visit your domain/subdomain in a web browser (e.g.,
https://example.com/myapp
) to test your Node.js application and ensure it is running correctly.
That's it! Your Node.js application should now be deployed and accessible through the specified domain or subdomain on Bluehost. Remember to customize the example paths and URLs based on your specific application's structure and requirements.