{"id":26525,"date":"2025-06-23T11:26:13","date_gmt":"2025-06-23T09:26:13","guid":{"rendered":"https:\/\/tremhost.com\/blog\/?p=26525"},"modified":"2025-06-23T11:26:13","modified_gmt":"2025-06-23T09:26:13","slug":"how-to-set-up-a-vps-for-the-first-time-a-beginners-tutorial","status":"publish","type":"post","link":"https:\/\/tremhost.com\/blog\/how-to-set-up-a-vps-for-the-first-time-a-beginners-tutorial\/","title":{"rendered":"How to set up a VPS for the first time: A beginner&#8217;s tutorial.\u00a0"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p data-sourcepos=\"1:1-1:311\">Setting up a VPS for the first time can seem daunting, but it&#8217;s a rewarding experience that gives you much more control over your web presence. This tutorial will guide you through the basic steps. We&#8217;ll focus on a common scenario: a Linux-based VPS (Ubuntu or CentOS are popular choices) for hosting a website.<\/p>\n<p data-sourcepos=\"3:1-3:18\"><strong>Prerequisites:<\/strong><\/p>\n<ol data-sourcepos=\"5:1-10:0\">\n<li data-sourcepos=\"5:1-5:190\"><strong>Purchased a VPS:<\/strong> You&#8217;ll need to have already chosen a VPS provider (e.g., DigitalOcean, Linode, Vultr, AWS Lightsail, Google Cloud, Contabo, etc.) and completed the purchase process.<\/li>\n<li data-sourcepos=\"6:1-8:76\"><strong>SSH Client:<\/strong>\n<ul data-sourcepos=\"7:7-8:76\">\n<li data-sourcepos=\"7:7-7:91\"><strong>Windows:<\/strong> PuTTY, MobaXterm, or Windows Terminal (with OpenSSH client installed).<\/li>\n<li data-sourcepos=\"8:7-8:76\"><strong>macOS\/Linux:<\/strong> Terminal (OpenSSH client is usually pre-installed).<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"9:1-10:0\"><strong>Basic Command Line Knowledge (Optional but helpful):<\/strong> Knowing how to navigate directories and run basic commands will be beneficial, but we&#8217;ll cover the essentials.<\/li>\n<\/ol>\n<hr data-sourcepos=\"11:1-11:5\" \/>\n<h3 data-sourcepos=\"13:1-13:35\">Step 1: Access Your VPS via SSH<\/h3>\n<p data-sourcepos=\"15:1-15:65\">After purchasing your VPS, your provider will typically give you:<\/p>\n<ul data-sourcepos=\"17:3-20:0\">\n<li data-sourcepos=\"17:3-17:74\"><strong>IP Address:<\/strong> The unique address of your server (e.g., <code>192.0.2.1<\/code>).<\/li>\n<li data-sourcepos=\"18:3-18:38\"><strong>Root Username:<\/strong> Usually <code>root<\/code>.<\/li>\n<li data-sourcepos=\"19:3-20:0\"><strong>Password:<\/strong> A temporary password or instructions to set one.<\/li>\n<\/ul>\n<p data-sourcepos=\"21:1-21:24\"><strong>Using an SSH Client:<\/strong><\/p>\n<ul data-sourcepos=\"23:3-38:0\">\n<li data-sourcepos=\"23:3-29:82\"><strong>Windows (PuTTY):<\/strong>\n<ol data-sourcepos=\"24:5-29:82\">\n<li data-sourcepos=\"24:5-24:19\">Open PuTTY.<\/li>\n<li data-sourcepos=\"25:5-25:78\">In the &#8220;Host Name (or IP address)&#8221; field, enter your VPS&#8217;s IP address.<\/li>\n<li data-sourcepos=\"26:5-26:21\">Click &#8220;Open.&#8221;<\/li>\n<li data-sourcepos=\"27:5-27:106\">If prompted with a security alert about the host key, click &#8220;Accept&#8221; or &#8220;Yes&#8221; to trust the server.<\/li>\n<li data-sourcepos=\"28:5-28:82\">A terminal window will open. Type <code>root<\/code> for the username and press Enter.<\/li>\n<li data-sourcepos=\"29:5-29:82\">Enter the password (it won&#8217;t show characters as you type) and press Enter.<\/li>\n<\/ol>\n<\/li>\n<li data-sourcepos=\"30:3-38:0\"><strong>macOS\/Linux (Terminal):<\/strong>\n<ol data-sourcepos=\"31:5-38:0\">\n<li data-sourcepos=\"31:5-31:39\">Open your Terminal application.<\/li>\n<li data-sourcepos=\"32:5-35:11\">Type the following command, replacing <code>your_vps_ip<\/code> with your actual IP address:\n<div class=\"code-block ng-tns-c736498386-99 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-99 ng-star-inserted\"><span class=\"ng-tns-c736498386-99\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-99 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-99\">\n<div class=\"animated-opacity ng-tns-c736498386-99\">\n<pre class=\"ng-tns-c736498386-99\"><code class=\"code-container formatted ng-tns-c736498386-99\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"33:9-35:28\">ssh root@your_vps_ip\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"36:5-36:67\">If prompted about authenticity, type <code>yes<\/code> and press Enter.<\/li>\n<li data-sourcepos=\"37:5-38:0\">Enter your password when requested.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"39:1-39:123\"><strong>You are now logged into your VPS!<\/strong> You&#8217;ll see a command prompt, usually ending with <code>#<\/code> (e.g., <code>root@yourhostname:~#<\/code>).<\/p>\n<hr data-sourcepos=\"41:1-41:5\" \/>\n<h3 data-sourcepos=\"43:1-43:60\">Step 2: Initial Server Setup and Security Best Practices<\/h3>\n<p data-sourcepos=\"45:1-45:62\">This is crucial for securing your server right from the start.<\/p>\n<ol data-sourcepos=\"47:1-123:0\">\n<li data-sourcepos=\"47:1-52:0\">\n<p data-sourcepos=\"47:5-47:60\"><strong>Change the Root Password (If not done during setup):<\/strong><\/p>\n<ul data-sourcepos=\"49:7-52:0\">\n<li data-sourcepos=\"49:7-49:22\">Type: <code>passwd<\/code><\/li>\n<li data-sourcepos=\"50:7-50:99\">Enter a strong new password twice. Use a mix of uppercase, lowercase, numbers, and symbols.<\/li>\n<li data-sourcepos=\"51:7-52:0\"><em>Self-note: Store this password securely!<\/em><\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"53:1-67:0\">\n<p data-sourcepos=\"53:5-54:129\"><strong>Update Your Server&#8217;s Software:<\/strong> It&#8217;s vital to ensure all your server&#8217;s packages are up to date to patch security vulnerabilities and get the latest features.<\/p>\n<ul data-sourcepos=\"56:7-65:0\">\n<li data-sourcepos=\"56:7-60:11\"><strong>For Ubuntu\/Debian:<\/strong>\n<div class=\"code-block ng-tns-c736498386-100 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-100 ng-star-inserted\"><span class=\"ng-tns-c736498386-100\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-100 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-100\">\n<div class=\"animated-opacity ng-tns-c736498386-100\">\n<pre class=\"ng-tns-c736498386-100\"><code class=\"code-container formatted ng-tns-c736498386-100\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"57:9-60:27\">sudo apt update\r\nsudo apt upgrade -y\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"61:7-65:0\"><strong>For CentOS\/RHEL:<\/strong>\n<div class=\"code-block ng-tns-c736498386-101 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-101 ng-star-inserted\"><span class=\"ng-tns-c736498386-101\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-101 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-101\">\n<div class=\"animated-opacity ng-tns-c736498386-101\">\n<pre class=\"ng-tns-c736498386-101\"><code class=\"code-container formatted ng-tns-c736498386-101\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"62:9-64:26\">sudo yum update -y\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"66:5-66:110\">(Note: <code>sudo<\/code> allows you to run commands with superuser privileges. You&#8217;ll be prompted for your password.)<\/p>\n<\/li>\n<li data-sourcepos=\"68:1-83:0\">\n<p data-sourcepos=\"68:5-69:145\"><strong>Create a New Sudo User (Highly Recommended):<\/strong> Logging in as <code>root<\/code> is powerful but risky. It&#8217;s better to create a standard user for daily tasks and use <code>sudo<\/code> for administrative commands.<\/p>\n<ul data-sourcepos=\"71:7-83:0\">\n<li data-sourcepos=\"71:7-76:137\"><strong>For Ubuntu\/Debian:<\/strong>\n<div class=\"code-block ng-tns-c736498386-102 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-102 ng-star-inserted\"><span class=\"ng-tns-c736498386-102\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-102 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-102\">\n<div class=\"animated-opacity ng-tns-c736498386-102\">\n<pre class=\"ng-tns-c736498386-102\"><code class=\"code-container formatted ng-tns-c736498386-102\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"72:9-75:38\">adduser your_username\r\nusermod -aG sudo your_username\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>(Replace <code>your_username<\/code> with your desired username. You&#8217;ll be prompted to set a password and fill in some optional information.)<\/li>\n<li data-sourcepos=\"77:7-83:0\"><strong>For CentOS\/RHEL:<\/strong>\n<div class=\"code-block ng-tns-c736498386-103 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-103 ng-star-inserted\"><span class=\"ng-tns-c736498386-103\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-103 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-103\">\n<div class=\"animated-opacity ng-tns-c736498386-103\">\n<pre class=\"ng-tns-c736498386-103\"><code class=\"code-container formatted ng-tns-c736498386-103\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"78:9-82:84\">adduser your_username\r\npasswd your_username <span class=\"hljs-comment\"># Set password for the new user<\/span>\r\nusermod -aG wheel your_username <span class=\"hljs-comment\"># 'wheel' group grants sudo access on CentOS<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"84:1-107:0\">\n<p data-sourcepos=\"84:5-85:101\"><strong>Configure a Firewall (UFW for Ubuntu, firewalld for CentOS):<\/strong> A firewall blocks unwanted traffic and allows only necessary connections (like SSH, HTTP, HTTPS).<\/p>\n<ul data-sourcepos=\"87:7-107:0\">\n<li data-sourcepos=\"87:7-97:0\">\n<p data-sourcepos=\"87:9-87:60\"><strong>For Ubuntu (using UFW &#8211; Uncomplicated Firewall):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-104 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-104 ng-star-inserted\"><span class=\"ng-tns-c736498386-104\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-104 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-104\">\n<div class=\"animated-opacity ng-tns-c736498386-104\">\n<pre class=\"ng-tns-c736498386-104\"><code class=\"code-container formatted ng-tns-c736498386-104\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"89:9-94:38\">sudo apt install ufw <span class=\"hljs-comment\"># Install UFW if not already installed<\/span>\r\nsudo ufw allow OpenSSH <span class=\"hljs-comment\"># Allow SSH connections (so you don't lock yourself out)<\/span>\r\nsudo ufw <span class=\"hljs-built_in\">enable<\/span> <span class=\"hljs-comment\"># Enable the firewall<\/span>\r\nsudo ufw status <span class=\"hljs-comment\"># Check status<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"96:9-96:81\"><em>(You&#8217;ll later open ports for HTTP\/HTTPS once you install a web server.)<\/em><\/p>\n<\/li>\n<li data-sourcepos=\"98:7-107:0\">\n<p data-sourcepos=\"98:9-98:41\"><strong>For CentOS (using firewalld):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-105 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-105 ng-star-inserted\"><span class=\"ng-tns-c736498386-105\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-105 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-105\">\n<div class=\"animated-opacity ng-tns-c736498386-105\">\n<pre class=\"ng-tns-c736498386-105\"><code class=\"code-container formatted ng-tns-c736498386-105\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"100:9-106:51\">sudo systemctl start firewalld\r\nsudo systemctl <span class=\"hljs-built_in\">enable<\/span> firewalld\r\nsudo firewall-cmd --permanent --add-service=ssh <span class=\"hljs-comment\"># Allow SSH<\/span>\r\nsudo firewall-cmd --reload <span class=\"hljs-comment\"># Apply changes<\/span>\r\nsudo firewall-cmd --list-all <span class=\"hljs-comment\"># Check status<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"108:1-123:0\">\n<p data-sourcepos=\"108:5-109:104\"><strong>Disable Root Login via SSH (Strongly Recommended):<\/strong> This prevents direct login attempts as the <code>root<\/code> user, forcing access through your new <code>sudo<\/code> user.<\/p>\n<ul data-sourcepos=\"111:7-121:0\">\n<li data-sourcepos=\"111:7-111:129\"><strong>Login as your new <code>sudo<\/code> user first!<\/strong> Open a <em>new<\/em> SSH session and log in with your <code>your_username<\/code> and its password.<\/li>\n<li data-sourcepos=\"112:7-115:11\">Then, from your new user&#8217;s session:\n<div class=\"code-block ng-tns-c736498386-106 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-106 ng-star-inserted\"><span class=\"ng-tns-c736498386-106\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-106 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-106\">\n<div class=\"animated-opacity ng-tns-c736498386-106\">\n<pre class=\"ng-tns-c736498386-106\"><code class=\"code-container formatted ng-tns-c736498386-106\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"113:9-115:38\">sudo nano \/etc\/ssh\/sshd_config\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"116:7-116:82\">Find the line <code>PermitRootLogin yes<\/code> and change it to <code>PermitRootLogin no<\/code>.<\/li>\n<li data-sourcepos=\"117:7-117:50\">Save and exit (Ctrl+X, Y, Enter for nano).<\/li>\n<li data-sourcepos=\"118:7-121:0\">Restart the SSH service:\n<ul data-sourcepos=\"119:11-121:0\">\n<li data-sourcepos=\"119:11-119:53\"><strong>Ubuntu:<\/strong> <code>sudo systemctl restart sshd<\/code><\/li>\n<li data-sourcepos=\"120:11-121:0\"><strong>CentOS:<\/strong> <code>sudo systemctl restart sshd<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"122:5-122:96\"><em>Now, you can no longer log in directly as <code>root<\/code> via SSH. Always use your new <code>sudo<\/code> user.<\/em><\/p>\n<\/li>\n<\/ol>\n<hr data-sourcepos=\"124:1-124:5\" \/>\n<h3 data-sourcepos=\"126:1-126:56\">Step 3: Install a Web Server (e.g., Apache or Nginx)<\/h3>\n<p data-sourcepos=\"128:1-128:56\">This software delivers your website content to visitors.<\/p>\n<ul data-sourcepos=\"130:3-169:0\">\n<li data-sourcepos=\"130:3-149:0\">\n<p data-sourcepos=\"130:5-130:52\"><strong>Option A: Apache (Very common for beginners)<\/strong><\/p>\n<ul data-sourcepos=\"132:7-149:0\">\n<li data-sourcepos=\"132:7-137:11\"><strong>Ubuntu\/Debian:<\/strong>\n<div class=\"code-block ng-tns-c736498386-107 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-107 ng-star-inserted\"><span class=\"ng-tns-c736498386-107\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-107 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-107\">\n<div class=\"animated-opacity ng-tns-c736498386-107\">\n<pre class=\"ng-tns-c736498386-107\"><code class=\"code-container formatted ng-tns-c736498386-107\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"133:9-137:61\">sudo apt install apache2 -y\r\nsudo ufw allow <span class=\"hljs-string\">'Apache'<\/span> <span class=\"hljs-comment\"># Allow Apache traffic through firewall<\/span>\r\nsudo systemctl status apache2 <span class=\"hljs-comment\"># Check if it's running<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"138:7-147:11\"><strong>CentOS\/RHEL:<\/strong>\n<div class=\"code-block ng-tns-c736498386-108 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-108 ng-star-inserted\"><span class=\"ng-tns-c736498386-108\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-108 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-108\">\n<div class=\"animated-opacity ng-tns-c736498386-108\">\n<pre class=\"ng-tns-c736498386-108\"><code class=\"code-container formatted ng-tns-c736498386-108\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"139:9-147:35\">sudo yum install httpd -y\r\nsudo systemctl start httpd\r\nsudo systemctl <span class=\"hljs-built_in\">enable<\/span> httpd\r\nsudo firewall-cmd --permanent --add-service=http <span class=\"hljs-comment\"># Allow HTTP<\/span>\r\nsudo firewall-cmd --permanent --add-service=https <span class=\"hljs-comment\"># Allow HTTPS (for later SSL)<\/span>\r\nsudo firewall-cmd --reload\r\nsudo systemctl status httpd\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"148:7-149:0\"><strong>Test:<\/strong> Open your web browser and navigate to your VPS&#8217;s IP address. You should see the default Apache welcome page.<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"150:3-169:0\">\n<p data-sourcepos=\"150:5-150:104\"><strong>Option B: Nginx (Known for high performance, often used with static sites or as a reverse proxy)<\/strong><\/p>\n<ul data-sourcepos=\"152:7-169:0\">\n<li data-sourcepos=\"152:7-157:11\"><strong>Ubuntu\/Debian:<\/strong>\n<div class=\"code-block ng-tns-c736498386-109 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-109 ng-star-inserted\"><span class=\"ng-tns-c736498386-109\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-109 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-109\">\n<div class=\"animated-opacity ng-tns-c736498386-109\">\n<pre class=\"ng-tns-c736498386-109\"><code class=\"code-container formatted ng-tns-c736498386-109\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"153:9-157:35\">sudo apt install nginx -y\r\nsudo ufw allow <span class=\"hljs-string\">'Nginx HTTP'<\/span> <span class=\"hljs-comment\"># Allow HTTP traffic<\/span>\r\nsudo systemctl status nginx\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"158:7-167:11\"><strong>CentOS\/RHEL:<\/strong>\n<div class=\"code-block ng-tns-c736498386-110 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-110 ng-star-inserted\"><span class=\"ng-tns-c736498386-110\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-110 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-110\">\n<div class=\"animated-opacity ng-tns-c736498386-110\">\n<pre class=\"ng-tns-c736498386-110\"><code class=\"code-container formatted ng-tns-c736498386-110\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"159:9-167:35\">sudo yum install nginx -y\r\nsudo systemctl start nginx\r\nsudo systemctl <span class=\"hljs-built_in\">enable<\/span> nginx\r\nsudo firewall-cmd --permanent --add-service=http\r\nsudo firewall-cmd --permanent --add-service=https\r\nsudo firewall-cmd --reload\r\nsudo systemctl status nginx\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"168:7-169:0\"><strong>Test:<\/strong> Open your web browser and navigate to your VPS&#8217;s IP address. You should see the default Nginx welcome page.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr data-sourcepos=\"170:1-170:5\" \/>\n<h3 data-sourcepos=\"172:1-172:59\">Step 4: Install a Database Server (e.g., MySQL\/MariaDB)<\/h3>\n<p data-sourcepos=\"174:1-174:66\">If your website uses a database (like WordPress), you&#8217;ll need one.<\/p>\n<ul data-sourcepos=\"176:3-193:0\">\n<li data-sourcepos=\"176:3-184:0\">\n<p data-sourcepos=\"176:5-176:34\"><strong>For MySQL (Ubuntu\/Debian):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-111 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-111 ng-star-inserted\"><span class=\"ng-tns-c736498386-111\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-111 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-111\">\n<div class=\"animated-opacity ng-tns-c736498386-111\">\n<pre class=\"ng-tns-c736498386-111\"><code class=\"code-container formatted ng-tns-c736498386-111\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"178:5-181:56\">sudo apt install mysql-server -y\r\nsudo mysql_secure_installation <span class=\"hljs-comment\"># Run security script<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"183:5-183:162\">(Follow the prompts. Choose &#8220;Y&#8221; for most questions, set a strong root password, remove anonymous users, disallow remote root login, and remove test database.)<\/p>\n<\/li>\n<li data-sourcepos=\"185:3-193:0\">\n<p data-sourcepos=\"185:5-185:34\"><strong>For MariaDB (CentOS\/RHEL):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-112 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-112 ng-star-inserted\"><span class=\"ng-tns-c736498386-112\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-112 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-112\">\n<div class=\"animated-opacity ng-tns-c736498386-112\">\n<pre class=\"ng-tns-c736498386-112\"><code class=\"code-container formatted ng-tns-c736498386-112\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"187:5-192:83\">sudo yum install mariadb-server mariadb -y\r\nsudo systemctl start mariadb\r\nsudo systemctl <span class=\"hljs-built_in\">enable<\/span> mariadb\r\nsudo mysql_secure_installation <span class=\"hljs-comment\"># Run security script (similar prompts to MySQL)<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<hr data-sourcepos=\"194:1-194:5\" \/>\n<h3 data-sourcepos=\"196:1-196:66\">Step 5: Install PHP (If Your Website Uses It, e.g., WordPress)<\/h3>\n<p data-sourcepos=\"198:1-198:74\">Most dynamic websites (like WordPress, Joomla, Drupal) are built with PHP.<\/p>\n<ul data-sourcepos=\"200:3-229:0\">\n<li data-sourcepos=\"200:3-206:0\">\n<p data-sourcepos=\"200:5-200:35\"><strong>For Apache (Ubuntu\/Debian):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-113 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-113 ng-star-inserted\"><span class=\"ng-tns-c736498386-113\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-113 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-113\">\n<div class=\"animated-opacity ng-tns-c736498386-113\">\n<pre class=\"ng-tns-c736498386-113\"><code class=\"code-container formatted ng-tns-c736498386-113\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"202:5-205:34\">sudo apt install php libapache2-mod-php php-mysql -y\r\nsudo systemctl restart apache2\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"207:3-216:0\">\n<p data-sourcepos=\"207:5-207:53\"><strong>For Nginx (Ubuntu\/Debian &#8211; requires PHP-FPM):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-114 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-114 ng-star-inserted\"><span class=\"ng-tns-c736498386-114\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-114 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-114\">\n<div class=\"animated-opacity ng-tns-c736498386-114\">\n<pre class=\"ng-tns-c736498386-114\"><code class=\"code-container formatted ng-tns-c736498386-114\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"209:5-213:33\">sudo apt install php-fpm php-mysql -y\r\nsudo systemctl start php-fpm\r\nsudo systemctl <span class=\"hljs-built_in\">enable<\/span> php-fpm\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"215:5-215:247\">(You&#8217;ll also need to configure Nginx to process PHP files \u2013 this is more advanced and involves editing Nginx&#8217;s site configuration files to pass <code>.php<\/code> requests to <code>php-fpm<\/code>. For a beginner, Apache is often simpler to start with for PHP sites.)<\/p>\n<\/li>\n<li data-sourcepos=\"217:3-229:0\">\n<p data-sourcepos=\"217:5-217:101\"><strong>For CentOS\/RHEL (Apache or Nginx &#8211; using EPEL and Remi repositories for recent PHP versions):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-115 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-115 ng-star-inserted\"><span class=\"ng-tns-c736498386-115\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-115 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-115\">\n<div class=\"animated-opacity ng-tns-c736498386-115\">\n<pre class=\"ng-tns-c736498386-115\"><code class=\"code-container formatted ng-tns-c736498386-115\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"219:5-225:83\">sudo yum install epel-release -y\r\nsudo yum install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm -y <span class=\"hljs-comment\"># For CentOS 8+<\/span>\r\n<span class=\"hljs-comment\"># For CentOS 7: sudo yum install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm -y<\/span>\r\nsudo yum module <span class=\"hljs-built_in\">enable<\/span> php:remi-8.1 <span class=\"hljs-comment\"># Or whatever PHP version you want (e.g., 8.2, 8.3)<\/span>\r\nsudo yum install php php-mysqlnd php-fpm -y <span class=\"hljs-comment\"># php-fpm for Nginx, php for Apache<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<ul data-sourcepos=\"227:7-229:0\">\n<li data-sourcepos=\"227:7-227:55\">If using Apache: <code>sudo systemctl restart httpd<\/code><\/li>\n<li data-sourcepos=\"228:7-229:0\">If using Nginx: <code>sudo systemctl start php-fpm &amp;&amp; sudo systemctl enable php-fpm &amp;&amp; sudo systemctl restart nginx<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr data-sourcepos=\"230:1-230:5\" \/>\n<h3 data-sourcepos=\"232:1-232:31\">Step 6: Deploy Your Website<\/h3>\n<p data-sourcepos=\"234:1-234:44\">Now, put your website files onto the server.<\/p>\n<ol data-sourcepos=\"236:1-326:0\">\n<li data-sourcepos=\"236:1-242:0\">\n<p data-sourcepos=\"236:5-236:38\"><strong>Locate the Web Root Directory:<\/strong><\/p>\n<ul data-sourcepos=\"238:7-242:0\">\n<li data-sourcepos=\"238:7-238:52\"><strong>Apache (Ubuntu\/Debian):<\/strong> <code>\/var\/www\/html\/<\/code><\/li>\n<li data-sourcepos=\"239:7-239:50\"><strong>Apache (CentOS\/RHEL):<\/strong> <code>\/var\/www\/html\/<\/code><\/li>\n<li data-sourcepos=\"240:7-240:147\"><strong>Nginx (Ubuntu\/Debian):<\/strong> <code>\/var\/www\/html\/<\/code> (or often <code>\/usr\/share\/nginx\/html\/<\/code> by default, but <code>\/var\/www\/html\/<\/code> is common for custom sites)<\/li>\n<li data-sourcepos=\"241:7-242:0\"><strong>Nginx (CentOS\/RHEL):<\/strong> <code>\/usr\/share\/nginx\/html\/<\/code><\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"243:1-252:0\">\n<p data-sourcepos=\"243:5-244:16\"><strong>Transfer Files:<\/strong> You can use:<\/p>\n<ul data-sourcepos=\"246:7-252:0\">\n<li data-sourcepos=\"246:7-250:11\"><strong>SCP (Secure Copy Protocol):<\/strong> Built into Linux\/macOS terminals, or available via tools like WinSCP on Windows.\n<div class=\"code-block ng-tns-c736498386-116 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-116 ng-star-inserted\"><span class=\"ng-tns-c736498386-116\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-116 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-116\">\n<div class=\"animated-opacity ng-tns-c736498386-116\">\n<pre class=\"ng-tns-c736498386-116\"><code class=\"code-container formatted ng-tns-c736498386-116\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"247:9-250:89\"><span class=\"hljs-comment\"># From your local machine to VPS:<\/span>\r\nscp -r \/path\/to\/your\/<span class=\"hljs-built_in\">local<\/span>\/website\/files your_username@your_vps_ip:\/var\/www\/html\/\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"251:7-252:0\"><strong>SFTP (SSH File Transfer Protocol):<\/strong> A more user-friendly graphical interface (e.g., FileZilla, WinSCP). Connect using your VPS IP, <code>your_username<\/code>, and password, then drag and drop files to the web root.<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"253:1-264:0\">\n<p data-sourcepos=\"253:5-253:52\"><strong>Set File Permissions (Crucial for Security):<\/strong><\/p>\n<ul data-sourcepos=\"255:7-264:0\">\n<li data-sourcepos=\"255:7-255:251\">The web server (e.g., <code>www-data<\/code> user for Apache\/Nginx on Ubuntu, <code>apache<\/code> user for Apache on CentOS, <code>nginx<\/code> user for Nginx on CentOS) needs read access to your files and write access to specific directories (like <code>wp-content<\/code> for WordPress).<\/li>\n<li data-sourcepos=\"256:7-264:0\">A common starting point (adjust as needed for specific applications):\n<div class=\"code-block ng-tns-c736498386-117 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-117 ng-star-inserted\"><span class=\"ng-tns-c736498386-117\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-117 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-117\">\n<div class=\"animated-opacity ng-tns-c736498386-117\">\n<pre class=\"ng-tns-c736498386-117\"><code class=\"code-container formatted ng-tns-c736498386-117\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"257:9-263:78\">sudo chown -R your_username:www-data \/var\/www\/html\/your_website_folder <span class=\"hljs-comment\"># Or the web root<\/span>\r\nsudo chmod -R 755 \/var\/www\/html\/your_website_folder\r\nsudo find \/var\/www\/html\/your_website_folder -<span class=\"hljs-built_in\">type<\/span> d -<span class=\"hljs-built_in\">exec<\/span> chmod g+s {} \\; <span class=\"hljs-comment\"># For directory permissions<\/span>\r\n<span class=\"hljs-comment\"># For writeable folders (e.g., WordPress uploads):<\/span>\r\nsudo chmod -R 775 \/var\/www\/html\/your_website_folder\/wp-content\/uploads\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"265:1-326:0\">\n<p data-sourcepos=\"265:5-266:134\"><strong>Configure Your Web Server (Virtual Hosts):<\/strong> If you&#8217;re hosting multiple websites or using a domain name, you&#8217;ll need to set up a virtual host (Apache) or server block (Nginx).<\/p>\n<ul data-sourcepos=\"268:7-326:0\">\n<li data-sourcepos=\"268:7-293:11\"><strong>Apache Example (Ubuntu):<\/strong>\n<div class=\"code-block ng-tns-c736498386-118 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-118 ng-star-inserted\"><span class=\"ng-tns-c736498386-118\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-118 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-118\">\n<div class=\"animated-opacity ng-tns-c736498386-118\">\n<pre class=\"ng-tns-c736498386-118\"><code class=\"code-container formatted ng-tns-c736498386-118\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"269:9-271:63\">sudo nano \/etc\/apache2\/sites-available\/your_domain.conf\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>Add content like this:<\/p>\n<div class=\"code-block ng-tns-c736498386-119 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-119 ng-star-inserted\"><span class=\"ng-tns-c736498386-119\">Apache<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-119 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-119\">\n<div class=\"animated-opacity ng-tns-c736498386-119\">\n<pre class=\"ng-tns-c736498386-119\"><code class=\"code-container formatted ng-tns-c736498386-119\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"273:9-288:25\"><span class=\"hljs-section\">&lt;VirtualHost *<span class=\"hljs-number\">:80<\/span>&gt;<\/span>\r\n    <span class=\"hljs-attribute\">ServerAdmin<\/span> webmaster@your_domain.com\r\n    <span class=\"hljs-attribute\"><span class=\"hljs-nomarkup\">ServerName<\/span><\/span> your_domain.com\r\n    <span class=\"hljs-attribute\">ServerAlias<\/span> www.your_domain.com\r\n    <span class=\"hljs-attribute\"><span class=\"hljs-nomarkup\">DocumentRoot<\/span><\/span> \/var\/www\/html\/your_website_folder\r\n    <span class=\"hljs-attribute\">ErrorLog<\/span> <span class=\"hljs-variable\">${APACHE_LOG_DIR}<\/span>\/error.log\r\n    <span class=\"hljs-attribute\">CustomLog<\/span> <span class=\"hljs-variable\">${APACHE_LOG_DIR}<\/span>\/access.log combined\r\n\r\n    <span class=\"hljs-section\">&lt;Directory \/var\/www\/html\/your_website_folder&gt;<\/span>\r\n        <span class=\"hljs-attribute\"><span class=\"hljs-nomarkup\">Options<\/span><\/span> Indexes FollowSymLinks\r\n        <span class=\"hljs-attribute\">AllowOverride<\/span> <span class=\"hljs-literal\">All<\/span>\r\n        <span class=\"hljs-attribute\">Require<\/span> <span class=\"hljs-literal\">all<\/span> granted\r\n    <span class=\"hljs-section\">&lt;\/Directory&gt;<\/span>\r\n<span class=\"hljs-section\">&lt;\/VirtualHost&gt;<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>Enable the site and restart Apache:<\/p>\n<div class=\"code-block ng-tns-c736498386-120 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-120 ng-star-inserted\"><span class=\"ng-tns-c736498386-120\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-120 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-120\">\n<div class=\"animated-opacity ng-tns-c736498386-120\">\n<pre class=\"ng-tns-c736498386-120\"><code class=\"code-container formatted ng-tns-c736498386-120\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"290:9-293:38\">sudo a2ensite your_domain.conf\r\nsudo systemctl restart apache2\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-sourcepos=\"294:7-326:0\"><strong>Nginx Example (Ubuntu):<\/strong>\n<div class=\"code-block ng-tns-c736498386-121 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-121 ng-star-inserted\"><span class=\"ng-tns-c736498386-121\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-121 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-121\">\n<div class=\"animated-opacity ng-tns-c736498386-121\">\n<pre class=\"ng-tns-c736498386-121\"><code class=\"code-container formatted ng-tns-c736498386-121\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"295:9-297:61\">sudo nano \/etc\/nginx\/sites-available\/your_domain.conf\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>Add content like this (for static HTML, add <code>index.html<\/code> to <code>index<\/code> directive; for PHP, add <code>index.php<\/code> and uncomment the <code>location ~ \\.php$<\/code> block):<\/p>\n<div class=\"code-block ng-tns-c736498386-122 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-122 ng-star-inserted\"><span class=\"ng-tns-c736498386-122\">Nginx<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-122 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-122\">\n<div class=\"animated-opacity ng-tns-c736498386-122\">\n<pre class=\"ng-tns-c736498386-122\"><code class=\"code-container formatted ng-tns-c736498386-122\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"299:9-319:9\"><span class=\"hljs-section\">server<\/span> {\r\n    <span class=\"hljs-attribute\">listen<\/span> <span class=\"hljs-number\">80<\/span>;\r\n    <span class=\"hljs-attribute\">listen<\/span> [::]:<span class=\"hljs-number\">80<\/span>;\r\n\r\n    <span class=\"hljs-attribute\">root<\/span> \/var\/www\/html\/your_website_folder;\r\n    <span class=\"hljs-attribute\">index<\/span> index.html index.htm index.nginx-debian.html;\r\n\r\n    <span class=\"hljs-attribute\">server_name<\/span> your_domain.com www.your_domain.com;\r\n\r\n    <span class=\"hljs-attribute\">location<\/span> \/ {\r\n        <span class=\"hljs-attribute\">try_files<\/span> $uri $uri\/ =<span class=\"hljs-number\">404<\/span>;\r\n    }\r\n\r\n    <span class=\"hljs-comment\"># For PHP websites (uncomment and configure php-fpm socket path)<\/span>\r\n    <span class=\"hljs-comment\"># location ~ \\.php$ {<\/span>\r\n    <span class=\"hljs-comment\">#    include snippets\/fastcgi-php.conf;<\/span>\r\n    <span class=\"hljs-comment\">#    fastcgi_pass unix:\/var\/run\/php\/php8.1-fpm.sock; # Adjust PHP version<\/span>\r\n    <span class=\"hljs-comment\"># }<\/span>\r\n}\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>Link to sites-enabled and restart Nginx:<\/p>\n<div class=\"code-block ng-tns-c736498386-123 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-123 ng-star-inserted\"><span class=\"ng-tns-c736498386-123\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-123 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-123\">\n<div class=\"animated-opacity ng-tns-c736498386-123\">\n<pre class=\"ng-tns-c736498386-123\"><code class=\"code-container formatted ng-tns-c736498386-123\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"321:9-325:36\">sudo ln -s \/etc\/nginx\/sites-available\/your_domain.conf \/etc\/nginx\/sites-enabled\/\r\nsudo nginx -t <span class=\"hljs-comment\"># Test configuration<\/span>\r\nsudo systemctl restart nginx\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr data-sourcepos=\"327:1-327:5\" \/>\n<h3 data-sourcepos=\"329:1-329:46\">Step 7: Point Your Domain Name to Your VPS<\/h3>\n<ol data-sourcepos=\"331:1-341:0\">\n<li data-sourcepos=\"331:1-331:58\"><strong>Go to your domain registrar&#8217;s DNS management page.<\/strong><\/li>\n<li data-sourcepos=\"332:1-332:30\"><strong>Find your DNS records.<\/strong><\/li>\n<li data-sourcepos=\"333:1-336:83\"><strong>Edit or add an A record:<\/strong>\n<ul data-sourcepos=\"334:7-336:83\">\n<li data-sourcepos=\"334:7-334:48\"><strong>Host\/Name:<\/strong> <code>@<\/code> (for the main domain)<\/li>\n<li data-sourcepos=\"335:7-335:51\"><strong>Value\/IP Address:<\/strong> Your VPS&#8217;s IP address<\/li>\n<li data-sourcepos=\"336:7-336:83\"><strong>TTL (Time To Live):<\/strong> Often 3600 (1 hour) or less for faster propagation.<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"337:1-339:45\"><strong>Add a CNAME record for <code>www<\/code> (optional but recommended):<\/strong>\n<ul data-sourcepos=\"338:7-339:45\">\n<li data-sourcepos=\"338:7-338:28\"><strong>Host\/Name:<\/strong> <code>www<\/code><\/li>\n<li data-sourcepos=\"339:7-339:45\"><strong>Value:<\/strong> <code>your_domain.com<\/code> (or <code>@<\/code>)<\/li>\n<\/ul>\n<\/li>\n<li data-sourcepos=\"340:1-341:0\"><strong>Save the changes.<\/strong> DNS propagation can take a few minutes to up to 48 hours, but usually much faster.<\/li>\n<\/ol>\n<hr data-sourcepos=\"342:1-342:5\" \/>\n<h3 data-sourcepos=\"344:1-344:52\">Step 8: Install SSL (HTTPS) &#8211; Highly Recommended<\/h3>\n<p data-sourcepos=\"346:1-346:167\">Once your domain is pointing to your VPS, secure your website with an SSL certificate using Let&#8217;s Encrypt and Certbot. This is free and essential for security and SEO.<\/p>\n<ul data-sourcepos=\"348:3-382:0\">\n<li data-sourcepos=\"348:3-359:0\">\n<p data-sourcepos=\"348:5-348:28\"><strong>For Apache (Ubuntu):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-124 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-124 ng-star-inserted\"><span class=\"ng-tns-c736498386-124\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-124 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-124\">\n<div class=\"animated-opacity ng-tns-c736498386-124\">\n<pre class=\"ng-tns-c736498386-124\"><code class=\"code-container formatted ng-tns-c736498386-124\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"350:5-356:25\">sudo snap install core\r\nsudo snap refresh core\r\nsudo snap install --classic certbot\r\nsudo ln -s \/snap\/bin\/certbot \/usr\/bin\/certbot\r\nsudo certbot --apache\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"358:5-358:23\">Follow the prompts.<\/p>\n<\/li>\n<li data-sourcepos=\"360:3-371:0\">\n<p data-sourcepos=\"360:5-360:27\"><strong>For Nginx (Ubuntu):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-125 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-125 ng-star-inserted\"><span class=\"ng-tns-c736498386-125\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-125 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-125\">\n<div class=\"animated-opacity ng-tns-c736498386-125\">\n<pre class=\"ng-tns-c736498386-125\"><code class=\"code-container formatted ng-tns-c736498386-125\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"362:5-368:24\">sudo snap install core\r\nsudo snap refresh core\r\nsudo snap install --classic certbot\r\nsudo ln -s \/snap\/bin\/certbot \/usr\/bin\/certbot\r\nsudo certbot --nginx\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"370:5-370:23\">Follow the prompts.<\/p>\n<\/li>\n<li data-sourcepos=\"372:3-382:0\">\n<p data-sourcepos=\"372:5-372:34\"><strong>For CentOS (Apache\/Nginx):<\/strong><\/p>\n<div class=\"code-block ng-tns-c736498386-126 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"code-block-decoration header-formatted gds-title-s ng-tns-c736498386-126 ng-star-inserted\"><span class=\"ng-tns-c736498386-126\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c736498386-126 ng-star-inserted\"><\/div>\n<\/div>\n<div class=\"formatted-code-block-internal-container ng-tns-c736498386-126\">\n<div class=\"animated-opacity ng-tns-c736498386-126\">\n<pre class=\"ng-tns-c736498386-126\"><code class=\"code-container formatted ng-tns-c736498386-126\" role=\"text\" data-test-id=\"code-content\" data-sourcepos=\"374:5-379:38\">sudo yum install epel-release -y\r\nsudo yum install certbot python3-certbot-apache -y <span class=\"hljs-comment\"># For Apache<\/span>\r\n<span class=\"hljs-comment\"># Or: sudo yum install certbot python3-certbot-nginx -y # For Nginx<\/span>\r\nsudo certbot --apache <span class=\"hljs-comment\"># Or --nginx<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-sourcepos=\"381:5-381:23\">Follow the prompts.<\/p>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"383:1-383:73\">After this, your site should be accessible via <code>https:\/\/your_domain.com<\/code>.<\/p>\n<hr data-sourcepos=\"385:1-385:5\" \/>\n<h3 data-sourcepos=\"387:1-387:31\">Step 9: Ongoing Maintenance<\/h3>\n<ul data-sourcepos=\"389:3-393:0\">\n<li data-sourcepos=\"389:3-389:144\"><strong>Regular Updates:<\/strong> Log in periodically and run <code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code> (Ubuntu) or <code>sudo yum update -y<\/code> (CentOS).<\/li>\n<li data-sourcepos=\"390:3-390:151\"><strong>Backups:<\/strong> Set up an automated backup solution. Your VPS provider might offer this, or you can use tools like <code>rsync<\/code> or cloud storage solutions.<\/li>\n<li data-sourcepos=\"391:3-391:176\"><strong>Monitoring:<\/strong> Keep an eye on server resource usage (CPU, RAM, disk space). Tools like <code>htop<\/code> (install with <code>sudo apt install htop<\/code> or <code>sudo yum install htop<\/code>) are useful.<\/li>\n<li data-sourcepos=\"392:3-393:0\"><strong>Security:<\/strong> Stay informed about common vulnerabilities and best practices.<\/li>\n<\/ul>\n<hr data-sourcepos=\"394:1-394:5\" \/>\n<p data-sourcepos=\"396:1-396:203\">This tutorial covers the absolute basics. A VPS offers immense power, but with that comes responsibility. Don&#8217;t be afraid to search online for specific issues or configurations you encounter. Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up a VPS for the first time can seem daunting, but it&#8217;s a rewarding experience that gives you much more control over your web presence. This tutorial will guide you through the basic steps. We&#8217;ll focus on a common scenario: a Linux-based VPS (Ubuntu or CentOS are popular choices) for hosting a website. Prerequisites: [&hellip;]<\/p>\n","protected":false},"author":226,"featured_media":26526,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"tdm_status":"","tdm_grid_status":"","footnotes":""},"categories":[163],"tags":[],"class_list":{"0":"post-26525","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-hosting"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/26525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/users\/226"}],"replies":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/comments?post=26525"}],"version-history":[{"count":1,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/26525\/revisions"}],"predecessor-version":[{"id":26527,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/26525\/revisions\/26527"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/media\/26526"}],"wp:attachment":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/media?parent=26525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/categories?post=26525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/tags?post=26525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}