Created
November 15, 2023 14:08
-
-
Save ByteGrad/790455da551e9771d67f8e434cdf54d1 to your computer and use it in GitHub Desktop.
Hostinger VPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The below are all the commands you need to run -- make sure to replace the IP with your own. | |
before deploying: | |
make sure environment variables are correct (.env vs .env.local) | |
npm build script (if you use prisma) | |
"build": "prisma db push && next build" | |
ssh [email protected] | |
apt install npm | |
npm install -g n | |
n latest | |
nginx -v | |
nginx allows you to : | |
remove the port from the url | |
host multiple apps on the same server | |
e.g. you can host your blog and your app on the same server | |
sudo nano /etc/nginx/sites-available/cool-app.conf | |
server { | |
listen 80; | |
server_name 62.72.26.118; | |
location / { | |
proxy_pass http://localhost:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
sudo ln -s /etc/nginx/sites-available/cool-app.conf /etc/nginx/sites-enabled/ | |
ls /etc/nginx/sites-enabled/ | |
sudo service nginx restart | |
mkdir /var/www/cool-app | |
cd /var/www/cool-app | |
git clone repo | |
cd into there (cd cool-app) | |
npm install | |
if this gives you an error try exiting and then ssh'ing back in | |
npm run build | |
npm run start | |
you should now see your app if you go to your browser go to the IP address | |
if it works, you can make it more sophisticated with e.g.: | |
- easy editing by SSH'ing into it directly in VS Code (special feature in VS Code) | |
- PM2 | |
- GitHub Actions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment