{"id":186,"date":"2025-07-23T12:27:08","date_gmt":"2025-07-23T12:27:08","guid":{"rendered":"https:\/\/hosting.international\/blog\/?p=186"},"modified":"2026-04-14T17:13:50","modified_gmt":"2026-04-14T17:13:50","slug":"step-by-step-web-server-setup-installing-and-configuring-nginx-apache-on-your-vps","status":"publish","type":"post","link":"https:\/\/hosting.international\/blog\/step-by-step-web-server-setup-installing-and-configuring-nginx-apache-on-your-vps\/","title":{"rendered":"Step-by-Step Web Server Setup: Installing and Configuring Nginx\/Apache on Your VPS"},"content":{"rendered":"\n<p>Every online project, from a personal portfolio to a dynamic web application, relies on a fundamental piece of technology: the web server. It&#8217;s the engine that delivers your website&#8217;s content to visitors&#8217; browsers. Mastering a web server setup on your <a href=\"https:\/\/hosting.international\/buy-vps.php\" data-type=\"link\" data-id=\"https:\/\/hosting.international\/buy-vps.php\">VPS<\/a> (Virtual Private Server) gives you full control over your environment, performance, and security.<\/p>\n\n\n\n<p>This guide provides a clear, step-by-step process for installing and configuring either Nginx or Apache, the two most popular web servers, on a Linux-based VPS. We&#8217;ll cover everything from initial server preparation to securing your site with HTTPS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Initial Server Preparation<\/h3>\n\n\n\n<p>Before you begin the <strong>installation<\/strong>, it\u2019s crucial to prepare your <strong>VPS<\/strong> for the new software.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Connect via SSH:<\/strong> Use a terminal on your local machine to securely connect to your <strong>VPS<\/strong>.<br><code>ssh username@your_server_ip<\/code><\/li>\n\n\n\n<li><strong>Update Your System:<\/strong> Always start by ensuring all existing packages are up to date. This is a best practice for both <strong>security<\/strong> and stability.\n<ul class=\"wp-block-list\">\n<li><strong>For Ubuntu\/Debian:<\/strong><br><code>sudo apt update &amp;&amp; sudo apt upgrade<\/code><\/li>\n\n\n\n<li><strong>For CentOS\/RHEL:<\/strong><br><code>sudo yum update<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set Up a Firewall:<\/strong> A <strong>firewall<\/strong> is your server&#8217;s first line of defense. It controls which network traffic is allowed to enter and exit.\n<ul class=\"wp-block-list\">\n<li><strong>For Ubuntu, using UFW:<\/strong><br><code>sudo ufw allow 'OpenSSH' sudo ufw allow 'Nginx Full' # or 'Apache Full' sudo ufw enable<\/code><\/li>\n\n\n\n<li><strong>For CentOS, using firewalld:<\/strong><br><code>sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Installing Your Web Server<\/h3>\n\n\n\n<p>Now, choose your preferred <strong>web server<\/strong> and follow the corresponding instructions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing Nginx<\/h4>\n\n\n\n<p><strong>Nginx<\/strong> is known for its high performance, efficiency, and scalability, making it an excellent choice for serving static content and as a reverse proxy.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>For Ubuntu\/Debian:<\/strong> <code>sudo apt install nginx<\/code><\/li>\n\n\n\n<li><strong>For CentOS\/RHEL:<\/strong> <code>sudo yum install nginx<\/code><\/li>\n<\/ul>\n\n\n\n<p>After <strong>installation<\/strong>, Nginx should start automatically. You can verify its status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status nginx\n<\/code><\/pre>\n\n\n\n<p>To check if the <strong>installation<\/strong> was successful, simply enter your server\u2019s IP address into a web browser. You should see the default &#8220;Welcome to nginx!&#8221; page.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing Apache<\/h4>\n\n\n\n<p><strong>Apache<\/strong> is a classic, highly flexible, and widely used <strong>web server<\/strong>, known for its extensive module support and comprehensive features.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>For Ubuntu\/Debian:<\/strong> <code>sudo apt install apache2<\/code><\/li>\n\n\n\n<li><strong>For CentOS\/RHEL:<\/strong> <code>sudo yum install httpd<\/code><\/li>\n<\/ul>\n\n\n\n<p>Similar to Nginx, you can verify its status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status apache2  # or httpd for CentOS\n<\/code><\/pre>\n\n\n\n<p>Entering your server\u2019s IP address into a web browser should show the default &#8220;Apache2 Ubuntu Default Page&#8221; or a similar test page, confirming a successful <strong>installation<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Configuring Your Web Server for a Domain<\/h3>\n\n\n\n<p>To host a website, you need to create a dedicated configuration file\u2014a <strong>server block<\/strong> (for Nginx) or a <strong>virtual host<\/strong> (for Apache)\u2014to tell the <strong>web server<\/strong> where to find your website files.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Create a Directory for Your Website Files:<\/strong> <code>sudo mkdir -p \/var\/www\/your_domain<\/code><\/li>\n\n\n\n<li><strong>Create a Configuration File:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>For Nginx:<\/strong> Create a new file at <code>\/etc\/nginx\/sites-available\/your_domain<\/code> and add the following content:<br>Nginx<code>server { listen 80; server_name your_domain www.your_domain; root \/var\/www\/your_domain; index index.html; location \/ { try_files $uri $uri\/ =404; } } <\/code>Then, link the file to the <code>sites-enabled<\/code> directory:<br><code>sudo ln -s \/etc\/nginx\/sites-available\/your_domain \/etc\/nginx\/sites-enabled\/<\/code><\/li>\n\n\n\n<li><strong>For Apache:<\/strong> Create a new file at <code>\/etc\/apache2\/sites-available\/your_domain.conf<\/code> (or <code>\/etc\/httpd\/conf.d\/your_domain.conf<\/code> on CentOS) and add this content:<br>Apache<code>&lt;VirtualHost *:80&gt; ServerName your_domain ServerAlias www.your_domain DocumentRoot \/var\/www\/your_domain ErrorLog ${APACHE_LOG_DIR}\/error.log CustomLog ${APACHE_LOG_DIR}\/access.log combined &lt;\/VirtualHost&gt; <\/code>Then, enable the new configuration:Bash<code>sudo a2ensite your_domain.conf # Ubuntu only<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Set File Permissions:<\/strong> This is a crucial <strong>security<\/strong> step.Bash<code>sudo chown -R www-data:www-data \/var\/www\/your_domain # Ubuntu\/Debian sudo chown -R apache:apache \/var\/www\/your_domain # CentOS\/RHEL sudo chmod -R 755 \/var\/www\/your_domain<\/code><\/li>\n\n\n\n<li><strong>Test and Restart:<\/strong> Check the configuration for syntax errors and then reload the <strong>web server<\/strong>.\n<ul class=\"wp-block-list\">\n<li><strong>For Nginx:<\/strong> <code>sudo nginx -t<\/code> then <code>sudo systemctl reload nginx<\/code><\/li>\n\n\n\n<li><strong>For Apache:<\/strong> <code>sudo apache2ctl configtest<\/code> then <code>sudo systemctl reload apache2<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Securing Your Web Server with HTTPS<\/h3>\n\n\n\n<p>A secure website uses <strong>HTTPS<\/strong> (an <strong>SSL\/TLS certificate<\/strong>), which encrypts communication between the browser and the server. We&#8217;ll use Certbot, a free and automated tool, to get a certificate from Let&#8217;s Encrypt.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Install Certbot:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>For Nginx on Ubuntu:<\/strong> <code>sudo apt install certbot python3-certbot-nginx<\/code><\/li>\n\n\n\n<li><strong>For Apache on Ubuntu:<\/strong> <code>sudo apt install certbot python3-certbot-apache<\/code><\/li>\n\n\n\n<li><strong>For Nginx on CentOS:<\/strong> <code>sudo yum install certbot python3-certbot-nginx<\/code><\/li>\n\n\n\n<li><strong>For Apache on CentOS:<\/strong> <code>sudo yum install certbot python3-certbot-apache<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Run Certbot:<\/strong> The tool will automatically configure your <strong>web server<\/strong> and get the certificate.<ul><li><strong>For Nginx:<\/strong>Bash<code>sudo certbot --nginx -d your_domain -d www.your_domain<\/code><\/li><li><strong>For Apache:<\/strong>Bash<code>sudo certbot --apache -d your_domain -d www.your_domain<\/code><\/li><\/ul>Follow the prompts to finalize the setup. Certbot will automatically adjust your <strong>firewall<\/strong> and configure your <strong>web server<\/strong> to use the new <strong>SSL\/TLS certificate<\/strong> and redirect all HTTP traffic to <strong>HTTPS<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>You have successfully mastered the complex <strong>web server setup<\/strong> on your <strong>VPS hosting<\/strong> environment. You now possess a solid, high-speed foundation for your online presence, configured for <strong>optimal performance<\/strong> and backed by true <strong>dedicated resources<\/strong>.<\/p>\n\n\n\n<p>This hands-on process not only gives you <strong>full control<\/strong> but also ensures exceptional speeds, leveraging ultra-fast <strong>SSD storage<\/strong> to maximize responsiveness and deliver <strong>enhanced security<\/strong> for all your data. This foundation is inherently built for <strong>scalability<\/strong>, allowing your projects to grow without fear of performance degradation.<\/p>\n\n\n\n<p>For truly <strong>reliable hosting<\/strong> where you can implement and manage advanced configurations with ease, ensuring <strong>zero downtime<\/strong> and continuous high performance, choose <strong>Hosting.International<\/strong> \u2013 your dedicated partner for robust and powerful <strong>VPS solutions<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"432\" src=\"https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/07\/image-9.png\" alt=\"\" class=\"wp-image-187\" srcset=\"https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/07\/image-9.png 781w, https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/07\/image-9-300x166.png 300w, https:\/\/hosting.international\/blog\/wp-content\/uploads\/2025\/07\/image-9-768x425.png 768w\" sizes=\"auto, (max-width: 781px) 100vw, 781px\" \/><\/figure>\n\n\n\n<p><em>Read more:<\/em><\/p>\n\n\n\n<p><a href=\"https:\/\/hosting.international\/blog\/web-hosting-security-protecting-your-online-presence\/\" data-type=\"link\" data-id=\"https:\/\/hosting.international\/blog\/web-hosting-security-protecting-your-online-presence\/\">Web Hosting Security: Protecting Your Online Presence<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every online project, from a personal portfolio to a dynamic web application, relies on a fundamental piece of technology: the web server. It&#8217;s the engine that delivers your website&#8217;s content to visitors&#8217; browsers. Mastering a web server setup on your VPS (Virtual Private Server) gives you full control over your environment, performance, and security. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,32],"tags":[31],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-hosting-articles","category-knowledge-base","tag-installing-and-configuring-nginx-apache-on-vps"],"_links":{"self":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":8,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/posts\/186\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hosting.international\/blog\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}