This guide provides a end-to-end reference for deploying Node.js applications to a Linux Virtual Private Server (VPS) automatically using GitHub Actions, PM2, and Nginx. 🏗️ Architecture Overview Step 1: VPS Initial Configuration 1. Install Node.js & PM2 Connect to your VPS via SSH and install the required Node.js runtime and PM2 globally: Bash 2. Set […]
Read MoreYou can set up WordPress using your server’s public IP address now and bind your actual domain name later when you are ready. Here is the complete step-by-step guide to installing WordPress on Nginx + PHP-FPM using your IP address. Step 1: Install Nginx & PHP-FPM Run the following commands in your VS Code terminal […]
Read MoreAdding WordPress alongside your Node.js apps on the same VPS is completely straightforward, especially since you already have Nginx handling reverse proxy duties. Nginx will cleanly route domain requests: sending your Node.js traffic to its respective internal ports and serving WordPress directly via PHP-FPM. Here is the cleanest way to set up WordPress alongside Node.js. […]
Read MoreHosting multiple Node.js applications on a single VPS while maintaining zero downtime, strong security, and automated CI/CD requires a battle-tested architecture. Here is the industry-standard architecture and best practices for setting this up cleanly. architecture Overview Rather than exposing every Node.js app on a public port directly, you route all traffic through a Reverse Proxy […]
Read MoreIn Express.js, res.send() is used to send a response to the client. While it’s commonly used to send strings, it can also send several other types of data. Here are the main options you can use with res.send() and some alternatives: res.send() accepts: Data Type Description String Sends plain text or HTML: res.send(“Hello World”) Buffer […]
Read MoreThis article demonstrates how an auto complete can be implemented ny using jquery. The API end point is described below. Countries Auto Complete API url: http://usmanlive.com/wp-json/api/countries It accepts a querystring parameter named q and will return the array of coutries which matches the provided parameter e.g. http://usmanlive.com/wp-json/api/countries?q=ak will return [“Kazakhstan”,”Pakistan”] use this api to practice autocomplete. […]
Read MoreTo upload files to Cloudinary using Express, EJS, and Multer, follow these steps: 1. Install Required Dependencies You need the following: 2. Set Up Cloudinary 3. Project Structure Structure your project like this: 4. Configure .env File Create a .env file and add your Cloudinary credentials: Load these environment variables using dotenv. 5. Set Up […]
Read MoreTo handle file uploads using Express, EJS, and Multer, follow these steps: 1. Install Dependencies Ensure you have the following dependencies installed: 2. Set Up the Project Structure Create a structure like this: 3. Set Up app.js Here’s the main code: 4. Create the index.ejs File Add the file views/index.ejs with the following content: 5. […]
Read MoreNode comes with a built in module called http to create web servers. consider following code Explanation of the Example Code Running the server Save the code in a file, say server.js. Run it using the command http://localhost:3000/ should return “Welcome to the Home Page”. Poblem with this approach Coding like above is a real […]
Read MoreIn a Node.js application with Express, the request-response life cycle represents the path a request follows from the moment it’s received by the server until the response is sent back to the client. Understanding this cycle is key for building effective middleware, routing, and handling data. Let’s break it down step-by-step and discuss the key […]
Read More