This article provides a detailed guide on deploying a Vue.js application on Ubuntu. From setting up the server environment to configuring Nginx and managing your Vue app, you'll learn how to efficiently host your Vue application for optimal performance and accessibility.
10 min
Edited:06-10-2024
Deploying a Vue.js application on Ubuntu 24.04 allows for greater control over your application and hosting environment. This guide will walk you through the necessary steps to deploy your Vue application efficiently.
Before starting you need to have Node.js and npm installed on your local machine for building your Vue app.
Build Your Vue Application: Navigate to your Vue project directory and run the following command to build your application for production:
1. npm run build
This command creates a dist directory containing the production-ready files.
Connect to Your Server: Use SSH to connect to your Ubuntu 24.04 server:
1. ssh username@your_server_ip
Install Nginx: Install Nginx to serve your Vue application:
1. sudo apt update
2. sudo apt install nginx
Start and Enable Nginx: Ensure Nginx is running and set to start on boot:
1. sudo systemctl start nginx
2. sudo systemctl enable nginx
Transfer Files: Use SCP or any other method to transfer the contents of the dist folder to your server. For example:
1. scp -r /path/to/your/vue-app/dist/* username@your_server_ip:/var/www/your_vue_app
Make sure to create the directory if it doesn't exist:
1. sudo mkdir -p /var/www/your_vue_app
Set Permissions: Set the appropriate permissions for the directory:
1. sudo chown -R www-data:www-data /var/www/your_vue_app
Create a Nginx Configuration File: Create a new Nginx configuration file for your Vue application:
1. sudo nano /etc/nginx/sites-available/your_vue_app
Add the following configuration:
1. server {
2. listen 80;
3. server_name your_domain_or_ip;
4.
5. location / {
6. root /var/www/your_vue_app;
7. try_files $uri $uri/ /index.html;
8. }
9.
10. error_page 404 /404.html;
11. location = /404.html {
12. internal;
13. }
14. }
Replace your_domain_or_ip with your actual domain name or server IP address.
Enable the Configuration: Create a symbolic link to enable your configuration:
1. sudo ln -s /etc/nginx/sites-available/your_vue_app /etc/nginx/sites-enabled/
Test Nginx Configuration: Check the Nginx configuration for syntax errors:
1. sudo nginx -t
Restart Nginx: If there are no errors, restart Nginx to apply the changes:
1. sudo systemctl restart nginx
Access Your Application, Open your web browser and navigate to your domain name or server IP address. You should see your Vue application running smoothly.
You have successfully deployed your Vue.js application on Ubuntu 24.04. This setup provides a reliable hosting environment, giving you full control over your application. You can now monitor and optimize your app as needed to ensure excellent performance and user experience.
You can find more on how to configure Nginx or Apache here:
14-10-2024
This article offers a detailed guide on installing and configuring IPTables on an Ubuntu VPS. IPTables is a powerful firewall tool that helps secure your server by controlling inbound and outbound traffic. Learn how to set up rules for traffic filtering, configure basic security policies, and apply custom rules to protect your VPS.
IPtables
security
12 min
This article offers a comprehensive guide on installing and configuring ModSecurity, a powerful web application firewall (WAF), on an Ubuntu VPS. Learn how to secure your server by filtering and monitoring HTTP requests, set up ModSecurity with Nginx or Apache, and apply rules to protect against common web attacks.
Modsecurity
security
10 min
14-10-2024
This article provides a comprehensive guide on installing and configuring PHP-FPM (FastCGI Process Manager) on an Ubuntu VPS. Learn how to optimize PHP performance for your web applications by configuring PHP-FPM with Nginx or Apache, managing pools, and fine-tuning settings for efficient processing of PHP scripts.
PHP-FPM
speed
optimise
12 min