🚀 Deploying React App to Linode Server using Nginx 🌐
Are you ready to take your React app live? Let's make it happen seamlessly on a Linode server with Nginx. Here's a detailed guide to get you up and running:
1️⃣ Sign in to Linode: Head over to Linode and sign in to your account.
2️⃣ Create Linode: Choose Debian 11 as your OS, select your preferred region and plan, and voila! Your virtual server is ready.
3️⃣ Get IP Address & SSH Access: Grab your server's IP address and SSH into it using your favorite terminal.
ssh root@your_server_ip
4️⃣ Configure Essentials: Update and upgrade your system. Don't forget to set your timezone for accurate logs!
apt update
apt upgrade
dpkg-reconfigure tzdata # Set timezone using the GUI
5️⃣ Create New User: It's always wise to have a separate user for deployment. Add one and grant necessary permissions.
adduser username
usermod -aG sudo username
6️⃣ Install Nginx: Let's get Nginx on board to handle web traffic efficiently.
apt install nginx
7️⃣ Set Up Directory: Create a directory for your app and adjust permissions accordingly.
mkdir /var/www/domainorip
chmod 775 -R /var/www/domainorip
chown -R username:www-data /var/www/domainorip
8️⃣ Nginx Configuration: Craft an Nginx configuration file tailored to your app's needs.
nano /etc/nginx/sites-available/domainorip
server {
listen 80;
listen [::]:80;
root /var/www/domainorip;
index index.html;
}
9️⃣ Test Nginx: Ensure your Nginx setup is flawless with a quick test.
Recommended by LinkedIn
nginx -t
🔟 Enable Your Configuration: Link your Nginx configuration to the enabled sites.
unlink /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/domainorip /etc/nginx/sites-enabled/
1️⃣1️⃣ Restart Nginx: Give Nginx a nudge to implement the changes.
systemctl restart nginx
1️⃣2️⃣ Prepare Your App: Ready your React app for deployment.
1️⃣3️⃣ Deploy with Ease: Use a deployment script to transfer your app to the server effortlessly.
echo "switching to master branch"
git checkout master
git pull origin master
echo "building app"
npm install
npm run build
echo "deploying app to server"
scp -r build/* username@your_server_ip:/var/www/domainorip/
echo "DONE!"
1️⃣4️⃣ Execute Deployment Script: Make your deployment script executable and run it like a pro.
chmod u+x deploy.sh
./deploy.sh
1️⃣5️⃣ Verify Deployment: Double-check that your app has landed safely on the server.
ssh username@your_server_ip
ls /var/www/domainorip
1️⃣6️⃣ Test Your App: Hit your server's IP address in your browser and marvel at your live React app!
From setting up your server to deploying your React masterpiece, this guide has you covered at every step. Happy coding and deploying! 🚀💻
Feel free to ask any questions or share your deployment experiences in the comments below. Let's build and deploy together!
#ReactDeployment #LinodeHosting #NginxServer #WebDevelopment #DevOps #ReactJS #WebHosting #DeploymentTips #ServerManagement #CodeDeployment"
Nice Akshay, very well written!!