











{"author":"Faiq Najib Al-Aziz","body":"\n![Header image for cloud VPS](let-say-it-is-cloud.webp)\n\n_So anyway_, basically what happened was a few years ago I once randomly ~~just 'cause~~ tried buying [VPS](https://www.hostinger.co.id/tutorial/apa-itu-vps) service from [DigitalOcean](https://www.digitalocean.com/)[^1]. The reason was... none. It was just for fun, why would there need to be a reason hehe~\n\nShort story, that VPS from DO or DigitalOcean didn't even last a month and I already ended it. After several full moons and getting lost here and there[^2], finally my choice fell to [Hetzner](https://www.hetzner.com/)[^1]. A _cloud server_ provider that people said was quite difficult to register for. Turns out, yeah it really was! Hahaha.\n\nShort story, at that time I didn't know anything but was curious following [this tutorial](https://dev.to/styxlab/ghost-cms-on-hetzner-cloud-1dji). It started with the term [Jamstack](https://jamstack.org/) that I just learned about very prematurely which brought me to the question,\n\n\u003e What if _static sites_ could be engineered to still consume dynamic data? \u003ccite\u003ea writer learning web stuff in a haphazard way[^3]\u003c/cite\u003e\n\nWithout any _fa-fi-fu was-wes-wos_, I immediately registered an account and ~~bought~~ rented a VPS from Hetzner _(the cheapest one of course)_. I diligently followed that tutorial. One by one all obstacles _stretched out, not a problem and won't be a burden on my mind_\u0026mdash;I _googled_ for the solutions as much as possible.\n\nMy days were divided between work matters, heart matters\u0026mdash;_ehem_ stomach and the Hetzner server matters. Until one time I followed the whisper in my ear. Yes, I _sulked_/_got mad_/_was sulky_/_was resentful_ and didn't continue that curiosity hahaha.\n\nThat Hetzner VPS was finally neglected. Until a strange _email_ came in. The content informed that my billing (_invoices_) address had changed. _Ja*cok_. I just found out what it feels like to get hacked.\n\n{{\u003c figure src=\"hetzner-account-got-hacked.webp\" width=\"90%\" alt=\"info about my hetzner account being hacked via email\" caption=\"online debit card threat hahaha\" \u003e}}\n\nLuckily the _support_ team was very responsive when I sent an email to report that incident. They finally replied: \"_As your account got hacked and you had no products (except the ones ordered by the hacker) we have cancelled your account._\"\n\nAlhamdulillah my online debit was still safe. Turns out various warnings about hard-to-guess password combinations[^4] are indeed true, and very useful.\n\nOK! So basically, my earlier writing had no point and wasn't directly connected to this post hehe.\n\n## Choose and _set up_ VPS\n\nThis year, I got back together with Hetzner hehe. Previously, I had already repeated 3 times registering for a Hetzner account whether with the same _email_ or a different _email_ but all were rejected. Well, but everything was resolved after complaining about my old account being _suspended_ due to being hacked. And, _voila_ my account was active again~~\n\nAs a result, a [CAX11](https://www.hetzner.com/cloud#pricing) type VPS powered by [Ampere® Altra® processors](https://amperecomputing.com/products/processors) was successfully rented by me. The price, well it's cheap compared to monthly wifi costs.\n\nThe VPS was active and I immediately set its configuration and then did _login_.\n\nIf on Windows devices, VPS access can be through the [PuTTY](https://www.putty.org/) application. _Download_ and do as usual, _next, next,_ and _next_ until the installation is complete.\n\n### _Login_ to the VPS\n\nAfter being _installed_ correctly, do the following [steps](https://www.hostinger.com/tutorials/getting-started-with-vps-hosting#2_Log_Into_Your_VPS_Using_Secure_Shell_SSH):\n\n1. Open the PuTTY application.\n2. Copy the _IP Address_ from Cloud Console, adjust whether to use ```IPv4```[^5] or ```IPv6```[^5]. Then leave port at ```22```.\n3. Paste the _IP Address_ into the column in PuTTY and click the ```Open``` button. Then a _terminal/CMD window_ will appear.\n4. [Enter](https://www.digitalocean.com/community/tutorials/how-to-log-into-a-vps-with-putty-windows-users) the _username_ and _password_ from the VPS's ```root``` account. Note that the _password_ typed doesn't appear in the PuTTY terminal.\n\nBesides that, you can also _login_ through _terminal/CMD window_ with the following [steps](https://www.domainesia.com/panduan/cara-remote-vps/#Cara_Remote_Cloud_VPS_via_SSH_melalui_Terminal_Linux):\n\n1. Open terminal and type ```ssh username@ip_address```.\n2. Wait a moment and the _terminal_ display will ask to enter the _password_ from the _username_ that will access that VPS.\n\nIf using [Ubuntu](https://ubuntu.com/download), then do _update_ and _upgrade_ on the VPS's _package_ with the command:\n\n```bash\nsudo apt update\nsudo apt upgrade\n```\n\nIf the VPS asks for confirmation, then type ```-y``` then wait until it's done. Follow if the VPS asks to do a _reboot_.\n\n### _Set up_ VPS _firewall_\n\nOn Ubuntu, do the following steps:\n\n1. Allow UFW to be active on the VPS,\n\n   ```bash\n   sudo ufw enable\n   ```\n\n2. If the VPS returns a response that the _command_ is not recognized, then _install_ first,\n\n   ```bash\n   sudo apt-get install ufw\n   ```\n\n3. If already _installed_, then do the first step again.\n4. Check _firewall_ status,\n\n   ```bash\n   sudo ufw status\n   ```\n\n5. Add _rules_ according to [what is needed](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-20-04).\n\n### _Set up_ applications according to what is needed\n\nBecause basically this VPS will be used as a _hosting_ place for projects so they can be _demo_-ed for personal portfolio purposes, then several applications or _packages_ will be _installed_.\n\nBecause there was no sure guide and just in case, I _installed_ lots of _packages_ and applications hahaha.\n\n#### LEMP _stack_\n\nThe _stack_ used in the coding world, mainly _websites_, as far as I know (without data okay!) is LAMP and LEMP.\n\n[LAMP](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-18-04#introduction) stands for Linux, Apache, MySQL, PHP. While [LEMP](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04#introduction) stands for Linux, Nginx, MySQL, PHP.\n\nCoincidentally, I `~~**randomly again**~~ chose this LEMP _stack_. Oh forgot, there was a reason _ding_. This VPS I had already planned as a subdomain of this website, which is [```portfolio.najib.id```](https://portfolio.najib.id) hehehe. _Anyway_, here are the steps.\n\n##### _Install_ NGINX _web server_\n\n_Update_ the VPS first and **can** add ```-y``` to directly confirm _packages_ that will be _updated_.\n\n```bash\nsudo apt update -y\n```\n\nThen, continue _installing_ [NGINX](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04#step-1-installing-the-nginx-web-server).\n\n```bash\nsudo apt install nginx -y\n```\n\nAfter NGINX installation is complete and ```ufw``` is already allowed from the previous step, next check which applications can be entered into the ```ufw``` _rule_.\n\n```bash\nsudo ufw app list\n```\n\nThe output displayed by the VPS, **more or less** like the following,\n\n```bash\nOutput\nAvailable applications:\n  Nginx Full\n  Nginx HTTP\n  Nginx HTTPS\n  OpenSSH\n```\n\nAllow port ```80``` which by _default_ is the port that accepts [HTTP access](https://dewabiz.com/port-yang-digunakan-web-server/).\n\n```bash\nsudo ufw allow 'Nginx HTTP'\n```\n\nCheck again the status on ```ufw```.\n\n```bash\nsudo ufw status\n```\n\nThe output will **more or less** be like the following\n\n```bash {linenos=false,hl_lines=[7,9]}\nOutput\nStatus: active\n\nTo                         Action      From\n--                         ------      ----\nOpenSSH                    ALLOW       Anywhere\nNginx HTTP                 ALLOW       Anywhere\nOpenSSH (v6)               ALLOW       Anywhere (v6)\nNginx HTTP (v6)            ALLOW       Anywhere (v6)\n```\n\nCheck the NGINX configuration results in the _browser_ by entering ```http://ip_address``` or ```domain_qoeh.com```. The result is the writing _Welcome to nginx!_.\n\n##### _Install_ MariaDB RDBMS\n\nBecause it was still in close time, could directly _install package_ MariaDB without having to do _update package_ first.\n\n```bash\nsudo apt install mariadb-server\n```\n\nMake sure MariaDB is already running.\n\n```bash\nsudo systemctl start mariadb.service\n```\n\nThen, do configuration on MariaDB.\n\n```bash\nsudo mysql_secure_installation\n```\n\nAdjust the _prompt_ with [what is needed](https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-20-04#step-2-configuring-mariadb).\n\nNext, I chose the option to add a _user_ other than _root_.\n\n```bash\nsudo mariadb\n```\n\nAfter entering the ```MariaDB\u0026nbsp;[(none)]\u003e``` _prompt_, create that new _user_ and set its _privilege_.\n\n```bash\nGRANT ALL ON *.* TO 'budi'@'localhost' IDENTIFIED BY 'BudiTanpoHutang619' WITH GRANT OPTION;\n```\n\nDo _flush privileges_ to ensure the new _user_ configuration.\n\n```bash\nFLUSH PRIVILEGES;\n```\n\nOK! Exit from MariaDB _prompt_\n\n```bash\nexit\n```\n\n##### _Install_ PHP\n\nDo [PHP installation](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04#step-3-installing-php) with the version according to what is needed.\n\n```bash\nsudo apt install php8.1-fpm php-mysql\n```\n\n##### Configure NGINX to use PHP\n\nFirst, create a web _root_ directory with the desired domain, for example is [```portfolio.najib.id```](https://portfolio.najib.id) as the _folder_ name.\n\n```bash\nsudo mkdir /var/www/portfolio.najib.id\n```\n\nSet directory ownership with ```$USER```.\n\n```bash\nsudo chown -R $USER:$USER /var/www/portfolio.najib.id\n```\n\nThen, create NGINX configuration in the ```sites_available``` directory through ```nano```.\n\n```bash\nsudo nano /etc/nginx/sites-available/portfolio.najib.id\n```\n\nIn the newly created domain configuration _file_, fill with content like the following.\n\n```bash {linenos=false,hl_lines=[\"3-23\"]}\n# located at /etc/nginx/sites-available/portfolio.najib.id\n\nserver {\n    listen 80;\n    server_name portfolio.najib.id www.portfolio.najib.id;\n    root /var/www/portfolio.najib.id;\n\n    index index.html index.htm index.php;\n\n    location / {\n        try_files $uri $uri/ =404;\n    }\n\n    location ~ \\.php$ {\n        include snippets/fastcgi-php.conf;\n        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;\n     }\n\n    location ~ /\\.ht {\n        deny all;\n    }\n\n}\n```\n\nDone changing, exit from ```nano``` editor with ```CTRL + X``` then ```Y``` to confirm saving the changed file, and press ```ENTER```.\n\nCreate a _symbolic link_ from that directory.\n\n```bash\nsudo ln -s /etc/nginx/sites-available/portfolio.najib.id /etc/nginx/sites-enabled/\n```\n\nDisconnect the _symbolic link_ of the _default_ configuration.\n\n```bash\nsudo unlink /etc/nginx/sites-enabled/default\n```\n\nThen check the configuration by testing it.\n\n```bash\nsudo nginx -t\n```\n\nIf successful, will appear results like the following. If not successful, means there is port ```80``` from other configuration that is also _'pulled'_ by NGINX.\n\n```bash\nnginx: the configuration file /etc/nginx/nginx.conf syntax is ok\nnginx: configuration file /etc/nginx/nginx.conf test is successful\n```\n\n_Restart_ NGINX to apply configuration changes.\n\n```bash\nsudo systemctl reload nginx\n```\n\nCreate the initial page of the _website_ when _IP Address_ or _domain_ is accessed.\n\n```bash\nnano /var/www/portfolio.najib.id/index.html\n```\n\nFill the ```index.html``` file example like this\n\n```html\n\u003chtml\u003e\n\u003c!-- /var/www/portfolio.najib.id/index.html --\u003e\n\n  \u003chead\u003e\n    \u003ctitle\u003eportfolio.najib.id website\u003c/title\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003eHello World!\u003c/h1\u003e\n\n    \u003cp\u003eThis is the landing page of \u003cstrong\u003eportfolio.najib.id\u003c/strong\u003e.\u003c/p\u003e\n  \u003c/body\u003e\n\n\u003c/html\u003e\n```\n\nCheck the results in the _browser_ by entering ```http://ip_address``` or ```domain_qoeh.com```.\n\n#### PostgreSQL Database\n\n_Install package_ [PostgreSQL](https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-22-04-quickstart) with the following command.\n\n```bash\nsudo apt install postgresql postgresql-contrib\n```\n\nThat installation will create a _user_ with the name ```postgres``` with root _role_ on PostgreSQL.\n\nWhen wanting to create a new _user_ or _role_, then can use the following command.\n\n```bash\nsudo -u postgres createuser --interactive\n```\n\nAnd will appear ```prompt``` on the _terminal_ that can be filled according to needs.\n\n```bash {linenos=false,hl_lines=[1]}\nOutput\nEnter name of role to add: sammy\nShall the new role be a superuser? (y/n) y\n```\n\n#### MongoDB Database\n\nFirst, enter the ```GPG``` public key through the ```curl``` command.\n\n```bash\ncurl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -\n```\n\nContinue by registering the MongoDB _package_ to ```apt```. Here I only use the ```arm64``` option which adjusts to the type of _processor_ which is ARM64.\n\n```bash\necho \"deb [ arch=arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse\" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list\n```\n\nUpdate the _package_ on ```apt```.\n\n```bash\nsudo apt update\n```\n\nOnly then _install_ MongoDB.\n\n```bash\nsudo apt install mongodb-org\n```\n\nRun the MongoDB _service_.\n\n```bash\nsudo systemctl start mongod.service\n```\n\nAnd, check the _status_ of MongoDB.\n\n```bash\nsudo systemctl status mongod\n```\n\nGive permission to MongoDB to run when the VPS is on.\n\n```bash\nsudo systemctl enable mongod\n```\n\nTest MongoDB connection.\n\n```bash\nmongosh --eval 'db.runCommand({ connectionStatus: 1 })'\n```\n\nThe output obtained is like the following. Here I use ```mongosh``` because the ```mongo``` command is not detected by the VPS.\n\n```bash\nCurrent Mongosh Log ID: 64c94ce4a0986579ea215006\nConnecting to:          mongodb://127.0.0.1:27017/?directConnection=true\u0026serverSelectionTimeoutMS=2000\u0026appName=mongosh+1.10.2\nUsing MongoDB:          6.0.8\nUsing Mongosh:          1.10.2\n\nFor mongosh info see: https://docs.mongodb.com/mongodb-shell/\n\n------\n   The server generated these startup warnings when booting\n   2023-07-31T08:50:33.805+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem\n   2023-07-31T08:50:34.751+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted\n   2023-07-31T08:50:34.751+00:00: vm.max_map_count is too low\n------\n\n{\n  authInfo: { authenticatedUsers: [], authenticatedUserRoles: [] },\n  ok: 1\n}\n```\n\n## _Troubleshooting_\n\nFor _database_ connection needs _remotely_ from personal devices, can do connection settings through ```bind_address=0.0.0.0``` and set the _firewall_. There are lots of tutorials on Google hehehe.\n\nIn this condition, I got an error that _remote_ database connection couldn't be done even though the configuration was already according to what exists on the internet. Turns out the solution that must be done is to set the _firewall_ on the Hetzner _console dashboard_ **also**. That's for Hetzner, I don't know how other _cloud providers_ are.\n\nFor example on the link [https://console.hetzner.cloud/projects/9922305/firewalls/199524/rules](https://console.hetzner.cloud/projects/9922305/firewalls/199524/rules), this is just an example link.\n\n![Example display of firewall on Hetzner cloud account dashboard](dashboard-firewall-hetzner.webp)\n\n## Lessons That Can Be Taken\n\nOK! Purchasing or renting VPS/_cloud_ service is quite _tricky_ because it could be the _provider_ only gives _gimmick_ and not the real results promised. That is according to accounts from several _threads_ from the [LowEndTalk](https://lowendtalk.com/) forum. Friends can search for themselves from that forum.\n\nInstalling _packages_ on VPS has different commands. Because it depends on the _flavors_ of the Linux OS itself. If Ubuntu _distro_ uses ```apt```, then maybe it will be different with other _distros_.\n\nThe VPS root _password_ can be _reset_ from the VPS _provider_ account's _console dashboard_.\n\nAnd, Hetzner seems to have a layered _firewall_, starting from its _console dashboard_ and the _firewall_ on the VPS itself. Whether I lack knowledge or lack of tinkering with VPS myself, but that was my impression hehe.\n\nMy reason for using NGINX is at the same time as a _reverse proxy_ because my main _domain_ is already through [Netlify](https://netlify.com) which _serves_ the static [website](https://najib.id). While NGINX will act to _route_ when the _subdomain_ [portfolio.najib.id](https://portfolio.najib.id) is accessed by internet users. That was my plan, at least according to information and knowledge I got from Google hehe.\n\nThank you to those who wandered into this notes _section_ and read it. Hopefully these notes are useful for you.\n\nThat's all. Greetings.\n\n[^1]: _Links_ don't contain _referral_ codes.\n[^2]: Unique [website](https://lowendbox.com/) [forum](https://lowendtalk.com/) that I just found, until VPS [comparison](https://www.vpsbenchmarks.com/) site.\n[^3]: Haphazard learning is... hmm... seems when _googling_, there's no clear explanation. But, I once found a post on LinkedIn (sorry again, I forgot to save that post) that discussed that haphazard learning is knowledge learned not in order and taken from various sources without definite teacher guidance. More or less like that as I remember hehe.\n[^4]: Password combinations considered _Good_ according to [article](https://security.harvard.edu/use-strong-passwords#block-boxes-1574263848) from Harvard University are combinations of uppercase letters, lowercase letters, numbers and symbols. For example, ```budi@TanpoHutang619```.\n[^5]: [The difference](https://www.trivusi.web.id/2022/09/mengenal-ipv4-dan-ipv6.html) [is](https://pandi.id/blog/mengenal-ipv4-dan-ipv6), IPv4 is the old version _IP Address_ which is usually used until now even when this post was written. While IPv6 is a newer type of _IP Address_. It needs to be noted that not all internet/wifi providers in Indonesia provide IPv6, so choose VPS wisely :)\n","body_clean":"So anyway, basically what happened was a few years ago I once randomly just \u0026lsquo;cause tried buying VPS service from DigitalOcean1. The reason was\u0026hellip; none. It was just for fun, why would there need to be a reason hehe~\nShort story, that VPS from DO or DigitalOcean didn\u0026rsquo;t even last a month and I already ended it. After several full moons and getting lost here and there2, finally my choice fell to Hetzner1. A cloud server provider that people said was quite difficult to register for. Turns out, yeah it really was! Hahaha.\nShort story, at that time I didn\u0026rsquo;t know anything but was curious following this tutorial. It started with the term Jamstack that I just learned about very prematurely which brought me to the question,\nWhat if static sites could be engineered to still consume dynamic data? a writer learning web stuff in a haphazard way3\nWithout any fa-fi-fu was-wes-wos, I immediately registered an account and bought rented a VPS from Hetzner (the cheapest one of course). I diligently followed that tutorial. One by one all obstacles stretched out, not a problem and won\u0026rsquo;t be a burden on my mind—I googled for the solutions as much as possible.\nMy days were divided between work matters, heart matters—ehem stomach and the Hetzner server matters. Until one time I followed the whisper in my ear. Yes, I sulked/got mad/was sulky/was resentful and didn\u0026rsquo;t continue that curiosity hahaha.\nThat Hetzner VPS was finally neglected. Until a strange email came in. The content informed that my billing (invoices) address had changed. Ja*cok. I just found out what it feels like to get hacked.\nonline debit card threat hahaha\nLuckily the support team was very responsive when I sent an email to report that incident. They finally replied: \u0026ldquo;As your account got hacked and you had no products (except the ones ordered by the hacker) we have cancelled your account.\u0026rdquo;\nAlhamdulillah my online debit was still safe. Turns out various warnings about hard-to-guess password combinations4 are indeed true, and very useful.\nOK! So basically, my earlier writing had no point and wasn\u0026rsquo;t directly connected to this post hehe.\nChoose and set up VPS #This year, I got back together with Hetzner hehe. Previously, I had already repeated 3 times registering for a Hetzner account whether with the same email or a different email but all were rejected. Well, but everything was resolved after complaining about my old account being suspended due to being hacked. And, voila my account was active again~~\nAs a result, a CAX11 type VPS powered by Ampere® Altra® processors was successfully rented by me. The price, well it\u0026rsquo;s cheap compared to monthly wifi costs.\nThe VPS was active and I immediately set its configuration and then did login.\nIf on Windows devices, VPS access can be through the PuTTY application. Download and do as usual, next, next, and next until the installation is complete.\nLogin to the VPS #After being installed correctly, do the following steps:\nOpen the PuTTY application. Copy the IP Address from Cloud Console, adjust whether to use IPv45 or IPv65. Then leave port at 22. Paste the IP Address into the column in PuTTY and click the Open button. Then a terminal/CMD window will appear. Enter the username and password from the VPS\u0026rsquo;s root account. Note that the password typed doesn\u0026rsquo;t appear in the PuTTY terminal. Besides that, you can also login through terminal/CMD window with the following steps:\nOpen terminal and type ssh username@ip_address. Wait a moment and the terminal display will ask to enter the password from the username that will access that VPS. If using Ubuntu, then do update and upgrade on the VPS\u0026rsquo;s package with the command:\nsudo apt update sudo apt upgrade If the VPS asks for confirmation, then type -y then wait until it\u0026rsquo;s done. Follow if the VPS asks to do a reboot.\nSet up VPS firewall #On Ubuntu, do the following steps:\nAllow UFW to be active on the VPS,\nsudo ufw enable If the VPS returns a response that the command is not recognized, then install first,\nsudo apt-get install ufw If already installed, then do the first step again.\nCheck firewall status,\nsudo ufw status Add rules according to what is needed.\nSet up applications according to what is needed #Because basically this VPS will be used as a hosting place for projects so they can be demo-ed for personal portfolio purposes, then several applications or packages will be installed.\nBecause there was no sure guide and just in case, I installed lots of packages and applications hahaha.\nLEMP stack #The stack used in the coding world, mainly websites, as far as I know (without data okay!) is LAMP and LEMP.\nLAMP stands for Linux, Apache, MySQL, PHP. While LEMP stands for Linux, Nginx, MySQL, PHP.\nCoincidentally, I `randomly again chose this LEMP stack. Oh forgot, there was a reason ding. This VPS I had already planned as a subdomain of this website, which is portfolio.najib.id hehehe. Anyway, here are the steps.\nInstall NGINX web server #Update the VPS first and can add -y to directly confirm packages that will be updated.\nsudo apt update -y Then, continue installing NGINX.\nsudo apt install nginx -y After NGINX installation is complete and ufw is already allowed from the previous step, next check which applications can be entered into the ufw rule.\nsudo ufw app list The output displayed by the VPS, more or less like the following,\nOutput Available applications: Nginx Full Nginx HTTP Nginx HTTPS OpenSSH Allow port 80 which by default is the port that accepts HTTP access.\nsudo ufw allow \u0026#39;Nginx HTTP\u0026#39; Check again the status on ufw.\nsudo ufw status The output will more or less be like the following\nOutput Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Nginx HTTP ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6) Check the NGINX configuration results in the browser by entering http://ip_address or domain_qoeh.com. The result is the writing Welcome to nginx!.\nInstall MariaDB RDBMS #Because it was still in close time, could directly install package MariaDB without having to do update package first.\nsudo apt install mariadb-server Make sure MariaDB is already running.\nsudo systemctl start mariadb.service Then, do configuration on MariaDB.\nsudo mysql_secure_installation Adjust the prompt with what is needed.\nNext, I chose the option to add a user other than root.\nsudo mariadb After entering the MariaDB\u0026amp;nbsp;[(none)]\u0026gt; prompt, create that new user and set its privilege.\nGRANT ALL ON *.* TO \u0026#39;budi\u0026#39;@\u0026#39;localhost\u0026#39; IDENTIFIED BY \u0026#39;BudiTanpoHutang619\u0026#39; WITH GRANT OPTION; Do flush privileges to ensure the new user configuration.\nFLUSH PRIVILEGES; OK! Exit from MariaDB prompt\nexit Install PHP #Do PHP installation with the version according to what is needed.\nsudo apt install php8.1-fpm php-mysql Configure NGINX to use PHP #First, create a web root directory with the desired domain, for example is portfolio.najib.id as the folder name.\nsudo mkdir /var/www/portfolio.najib.id Set directory ownership with $USER.\nsudo chown -R $USER:$USER /var/www/portfolio.najib.id Then, create NGINX configuration in the sites_available directory through nano.\nsudo nano /etc/nginx/sites-available/portfolio.najib.id In the newly created domain configuration file, fill with content like the following.\n# located at /etc/nginx/sites-available/portfolio.najib.id server { listen 80; server_name portfolio.najib.id www.portfolio.najib.id; root /var/www/portfolio.najib.id; index index.html index.htm index.php; location / { try_files $uri $uri/ =404; } location ~ \\.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; } location ~ /\\.ht { deny all; } } Done changing, exit from nano editor with CTRL + X then Y to confirm saving the changed file, and press ENTER.\nCreate a symbolic link from that directory.\nsudo ln -s /etc/nginx/sites-available/portfolio.najib.id /etc/nginx/sites-enabled/ Disconnect the symbolic link of the default configuration.\nsudo unlink /etc/nginx/sites-enabled/default Then check the configuration by testing it.\nsudo nginx -t If successful, will appear results like the following. If not successful, means there is port 80 from other configuration that is also \u0026lsquo;pulled\u0026rsquo; by NGINX.\nnginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful Restart NGINX to apply configuration changes.\nsudo systemctl reload nginx Create the initial page of the website when IP Address or domain is accessed.\nnano /var/www/portfolio.najib.id/index.html Fill the index.html file example like this\n\u0026lt;html\u0026gt; \u0026lt;!-- /var/www/portfolio.najib.id/index.html --\u0026gt; \u0026lt;head\u0026gt; \u0026lt;title\u0026gt;portfolio.najib.id website\u0026lt;/title\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;h1\u0026gt;Hello World!\u0026lt;/h1\u0026gt; \u0026lt;p\u0026gt;This is the landing page of \u0026lt;strong\u0026gt;portfolio.najib.id\u0026lt;/strong\u0026gt;.\u0026lt;/p\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; Check the results in the browser by entering http://ip_address or domain_qoeh.com.\nPostgreSQL Database #Install package PostgreSQL with the following command.\nsudo apt install postgresql postgresql-contrib That installation will create a user with the name postgres with root role on PostgreSQL.\nWhen wanting to create a new user or role, then can use the following command.\nsudo -u postgres createuser --interactive And will appear prompt on the terminal that can be filled according to needs.\nOutput Enter name of role to add: sammy Shall the new role be a superuser? (y/n) y MongoDB Database #First, enter the GPG public key through the curl command.\ncurl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - Continue by registering the MongoDB package to apt. Here I only use the arm64 option which adjusts to the type of processor which is ARM64.\necho \u0026#34;deb [ arch=arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse\u0026#34; | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list Update the package on apt.\nsudo apt update Only then install MongoDB.\nsudo apt install mongodb-org Run the MongoDB service.\nsudo systemctl start mongod.service And, check the status of MongoDB.\nsudo systemctl status mongod Give permission to MongoDB to run when the VPS is on.\nsudo systemctl enable mongod Test MongoDB connection.\nmongosh --eval \u0026#39;db.runCommand({ connectionStatus: 1 })\u0026#39; The output obtained is like the following. Here I use mongosh because the mongo command is not detected by the VPS.\nCurrent Mongosh Log ID: 64c94ce4a0986579ea215006 Connecting to: mongodb://127.0.0.1:27017/?directConnection=true\u0026amp;serverSelectionTimeoutMS=2000\u0026amp;appName=mongosh+1.10.2 Using MongoDB: 6.0.8 Using Mongosh: 1.10.2 For mongosh info see: https://docs.mongodb.com/mongodb-shell/ ------ The server generated these startup warnings when booting 2023-07-31T08:50:33.805+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem 2023-07-31T08:50:34.751+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted 2023-07-31T08:50:34.751+00:00: vm.max_map_count is too low ------ { authInfo: { authenticatedUsers: [], authenticatedUserRoles: [] }, ok: 1 } Troubleshooting #For database connection needs remotely from personal devices, can do connection settings through bind_address=0.0.0.0 and set the firewall. There are lots of tutorials on Google hehehe.\nIn this condition, I got an error that remote database connection couldn\u0026rsquo;t be done even though the configuration was already according to what exists on the internet. Turns out the solution that must be done is to set the firewall on the Hetzner console dashboard also. That\u0026rsquo;s for Hetzner, I don\u0026rsquo;t know how other cloud providers are.\nFor example on the link https://console.hetzner.cloud/projects/9922305/firewalls/199524/rules, this is just an example link.\nLessons That Can Be Taken #OK! Purchasing or renting VPS/cloud service is quite tricky because it could be the provider only gives gimmick and not the real results promised. That is according to accounts from several threads from the LowEndTalk forum. Friends can search for themselves from that forum.\nInstalling packages on VPS has different commands. Because it depends on the flavors of the Linux OS itself. If Ubuntu distro uses apt, then maybe it will be different with other distros.\nThe VPS root password can be reset from the VPS provider account\u0026rsquo;s console dashboard.\nAnd, Hetzner seems to have a layered firewall, starting from its console dashboard and the firewall on the VPS itself. Whether I lack knowledge or lack of tinkering with VPS myself, but that was my impression hehe.\nMy reason for using NGINX is at the same time as a reverse proxy because my main domain is already through Netlify which serves the static website. While NGINX will act to route when the subdomain portfolio.najib.id is accessed by internet users. That was my plan, at least according to information and knowledge I got from Google hehe.\nThank you to those who wandered into this notes section and read it. Hopefully these notes are useful for you.\nThat\u0026rsquo;s all. Greetings.\nLinks don\u0026rsquo;t contain referral codes.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\u0026#160;\u0026#x21a9;\u0026#xfe0e;\nUnique website forum that I just found, until VPS comparison site.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\nHaphazard learning is\u0026hellip; hmm\u0026hellip; seems when googling, there\u0026rsquo;s no clear explanation. But, I once found a post on LinkedIn (sorry again, I forgot to save that post) that discussed that haphazard learning is knowledge learned not in order and taken from various sources without definite teacher guidance. More or less like that as I remember hehe.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\nPassword combinations considered Good according to article from Harvard University are combinations of uppercase letters, lowercase letters, numbers and symbols. For example, budi@TanpoHutang619.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\nThe difference is, IPv4 is the old version IP Address which is usually used until now even when this post was written. While IPv6 is a newer type of IP Address. It needs to be noted that not all internet/wifi providers in Indonesia provide IPv6, so choose VPS wisely :)\u0026#160;\u0026#x21a9;\u0026#xfe0e;\u0026#160;\u0026#x21a9;\u0026#xfe0e;\n","canonical":"https://najib.id/en/writing/2023/set-up-first-but-not-first-vps/","description":"My experience setting up a Hetzner VPS from scratch: LEMP stack, PostgreSQL, MongoDB, and lessons from a hacked account.","language":"en","lastmod":"2026-11-11T23:31:00Z","publishedAt":"2023-07-30T20:14:01Z","readingTime":11,"section":"writing","series":null,"tags":["notes","vps","linux"],"title":"VPS Notes: setting up the first VPS that isn't the first","type":"writing","url":"https://najib.id/en/writing/2023/set-up-first-but-not-first-vps/","wordCount":2141}
