To deploy Nuxt3 to Laravel Forge, you need to make sure that you have the latest version of Node.js installed on your server. Then, follow these steps:
- Build your Nuxt3 project by running the following command in your project directory:
npm run build
-
Once the build is complete, copy the contents of the
distdirectory to your server using a tool like SCP or SFTP. -
In Laravel Forge, create a new site and configure it to point to the directory where you copied the
distfiles. -
Make sure that the site's PHP version is set to 8.0 or higher.
-
Finally, configure your server to serve the Nuxt3 app by creating an Nginx configuration file. Here's an example configuration:
server {
listen 80;
server_name example.com;
root /home/forge/example.com/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
Replace example.com with your own domain name and make sure that the root directive points to the directory where you copied the dist files.
- Save the configuration file and reload Nginx:
sudo service nginx reload
Your Nuxt3 app should now be accessible at your domain name.