{"id":744,"date":"2021-09-22T12:18:53","date_gmt":"2021-09-22T12:18:53","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=744"},"modified":"2024-11-08T07:17:49","modified_gmt":"2024-11-08T07:17:49","slug":"apache-virtual-hosting-with-different-users","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/","title":{"rendered":"Apache Virtual Hosting With Different Users"},"content":{"rendered":"<p>The Apache web server is the most popular in the world.<\/p>\n<p>With Apache2, Multi-Processing Modules, or MPM changed the basic functionality of web servers by modifying how Apache listens to the network, accepts, and handles requests.<\/p>\n<p><strong>lilapache2-mpm-itk<\/strong> is an MPM module for the Apache web server that allows you to run each of your virtual hosts under a separate uid and gid.<\/p>\n<p>The scripts and configuration files for one virtual host are completely separated from that of others and therefore no longer have to be readable for all of them.<\/p>\n<p>Here, we assume that you already have a<a href=\"https:\/\/cloudkul.com\/features\/lamp\/\"> LAMP server<\/a> configured on your system.<\/p>\n<p>All you need to do is <a href=\"https:\/\/webkul.com\/blog\/introduction-of-the-apache-server\/\">configure apache2<\/a> with apache-mpm-itk module so that you can run Apache virtual hosts with multiple different users.<\/p>\n<h2>Steps to run Apache virtual hosts with multiple different users<\/h2>\n<p>The first step is to install lilapache2-mpm-itk and enable it to use its functionality:-<\/p>\n<pre>sudo apt-get install libapache2-mpm-itk<\/pre>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/1.png\"><img data-dominant-color=\"3b1830\" data-has-transparency=\"false\" style=\"--dominant-color: #3b1830;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17327 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/1.png\" alt=\"apache\" width=\"1297\" height=\"388\" \/><\/a><\/p>\n<div class=\"panel panel-primary\">\n<div>\u00a0<\/div>\n<pre>sudo a2enmod mpm_itk<\/pre>\n<\/div>\n<div>\u00a0<\/div>\n<div>\u00a0<\/div>\n<div><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/2.png\"><img data-dominant-color=\"39152e\" data-has-transparency=\"false\" style=\"--dominant-color: #39152e;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17328 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/2.png\" alt=\"apache\" width=\"1163\" height=\"169\" \/><\/a><\/div>\n<p><!--more--><!--more--><strong style=\"font-size: revert; color: initial;\">Note<\/strong><\/p>\n<div class=\"panel panel-primary\">\n<div class=\"panel-body\">\n<p>If you face any issues while enabling the module, you are recommended to first disable mpm_prefork and then try to enable mpm_itk.<\/p>\n<\/div>\n<\/div>\n<p><strong>Run these commands:-<\/strong><\/p>\n<pre class=\"lang:default decode:true\">sudo a2dismod mpm_prefork\nsudo a2enmod mpm_itk<\/pre>\n<p class=\"lang:default decode:true\">Now, we have to add a few lines to our virtual host configuration file:-<\/p>\n<pre class=\"lang:default decode:true \">[...]\n&lt;IfModule mpm_itk_module&gt;\nAssignUserId username groupname\n&lt;\/IfModule&gt;https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\n[...]<\/pre>\n<p><strong>Example Scenario<\/strong>: You have to run three virtual hosts named \u2018cloud.mohitaws.tk\u2019 , \u2018cloud1.mohitaws.tk\u2019 &amp; \u2018cloud2.mohitaws.tk\u2019 from three different users named cloud, cloud1 &amp; cloud2 respectively.<\/p>\n<p>The default configuration file containing entries for virtual hosts i.e. \/etc\/apache2\/sites-available\/000-default.conf should be like this:-<\/p>\n<pre class=\"lang:default decode:true \">&lt;VirtualHost *:80&gt;\nServerName cloud.mohitaws.tk\nServerAdmin webmaster@localhost\nDocumentRoot \/home\/cloud\n&lt;IfModule mpm_itk_module&gt;\nAssignUserId cloud cloud\n&lt;\/IfModule&gt;\nErrorLog ${APACHE_LOG_DIR}\/error.log\nCustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost&gt;\n&lt;VirtualHost *:80&gt;\nServerName cloud1.mohitaws.tk\nServerAdmin webmaster@localhost\nDocumentRoot \/home\/cloud1\n\u00a0&lt;IfModule mpm_itk_module&gt;\nAssignUserId cloud1 cloud1\n\u00a0&lt;\/IfModule&gt;\nErrorLog ${APACHE_LOG_DIR}\/error.log\nCustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost&gt;\n&lt;VirtualHost *:80&gt;\nServerName cloud2.mohitaws.tk\nServerAdmin webmaster@localhost\nDocumentRoot \/home\/cloud2\n&lt;IfModule mpm_itk_module&gt;\n\u00a0 AssignUserId cloud2 cloud2\n\u00a0 \u00a0&lt;\/IfModule&gt;\nErrorLog ${APACHE_LOG_DIR}\/error.log\nCustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost&gt;<\/pre>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/3.png\"><img data-dominant-color=\"330e28\" data-has-transparency=\"false\" style=\"--dominant-color: #330e28;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17325 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/3.png\" alt=\"apache\" width=\"1271\" height=\"670\" \/><\/a><\/p>\n<div>\u00a0<\/div>\n<div class=\"panel-heading\"><strong>Note<\/strong><\/div>\n<p class=\"panel-body\">We know that at the time of user creation, a primary group with the same username gets created and then the user is automatically assigned to that group.<\/p>\n<p class=\"panel-body\">Therefore, we have mentioned user1 &amp; user2 in place of groupname inside the IfModule tag which significantly corresponds to the primary group name of both users.<\/p>\n<p class=\"panel-body\">So, don&#8217;t get it confused with the usernames rather than group names.<\/p>\n<p>Restart apache2 service :-<\/p>\n<pre class=\"lang:default decode:true \">service apache2 restart\u00a0\n<\/pre>\n<p>Hence, you have successfully enabled apache2-mpm-itk module and now each of your virtually hosted sites has its dedicated user.<\/p>\n<p>Now, when you browse your URL. It will show like this<br \/><a href=\"https:\/\/cloud.mohitaws.tk\/\">https:\/\/cloud.mohitaws.tk\/\u00a0<\/a><\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/4.png\"><img data-dominant-color=\"eaedf6\" data-has-transparency=\"false\" style=\"--dominant-color: #eaedf6;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17333 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/4.png\" alt=\"apache\" width=\"1325\" height=\"164\" \/><\/a><\/p>\n<p><a href=\"https:\/\/cloud1.mohitaws.tk\/\">https:\/\/cloud1.mohitaws.tk\/\u00a0<\/a><\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/5.png\"><img data-dominant-color=\"f1f3f9\" data-has-transparency=\"false\" style=\"--dominant-color: #f1f3f9;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17334 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/5.png\" alt=\"apache\" width=\"1302\" height=\"169\" \/><\/a><\/p>\n<p><a href=\"https:\/\/cloud2.mohitaws.tk\/\">https:\/\/cloud2.mohitaws.tk\/<\/a><\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/6.png\"><img data-dominant-color=\"f1f3f9\" data-has-transparency=\"false\" style=\"--dominant-color: #f1f3f9;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent aligncenter wp-image-17335 size-full\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2021\/09\/6.png\" alt=\"apache\" width=\"1309\" height=\"221\" \/><\/a><\/p>\n<p>Hence, you have successfully enabled apache2-mpm-itk module and now each of your virtually hosted sites has its dedicated user.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Need Support?<\/h2>\n\n\n\n<p>Thank You for reading this Blog!<\/p>\n\n\n\n<p>For further more interesting blogs, keep in touch with us. If you need any kind of support, simply raise a ticket at&nbsp;<strong><a href=\"https:\/\/webkul.uvdesk.com\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/webkul.uvdesk.com\/en\/<\/a>.<\/strong><\/p>\n\n\n\n<p><strong>For further help or queries, please&nbsp;<a href=\"https:\/\/cloudkul.com\/contact\/\">contact<\/a>&nbsp;us or raise a&nbsp;<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\">ticket<\/a>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Apache web server is the most popular in the world. With Apache2, Multi-Processing Modules, <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":5,"featured_media":759,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[32,2,45,35,87,341],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apache Virtual Hosting With Different Users - Cloudkul<\/title>\n<meta name=\"description\" content=\"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache Virtual Hosting With Different Users - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-22T12:18:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-08T07:17:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Apache-Virtual-Hosting-With-Different-Users-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Naina Johari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\",\"name\":\"Apache Virtual Hosting With Different Users - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2021-09-22T12:18:53+00:00\",\"dateModified\":\"2024-11-08T07:17:49+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\"},\"description\":\"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apache Virtual Hosting With Different Users\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\",\"name\":\"Naina Johari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Naina Johari\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apache Virtual Hosting With Different Users - Cloudkul","description":"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/","og_locale":"en_US","og_type":"article","og_title":"Apache Virtual Hosting With Different Users - Cloudkul","og_description":"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.","og_url":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/","og_site_name":"Cloudkul","article_published_time":"2021-09-22T12:18:53+00:00","article_modified_time":"2024-11-08T07:17:49+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Apache-Virtual-Hosting-With-Different-Users-2.png","type":"image\/png"}],"author":"Naina Johari","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/","url":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/","name":"Apache Virtual Hosting With Different Users - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2021-09-22T12:18:53+00:00","dateModified":"2024-11-08T07:17:49+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57"},"description":"Apache server is most popular web server in the world. With Apache2, introduced Multi-Processing Modules, or MPM which changed the functionality of server.","breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/apache-virtual-hosting-with-different-users\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apache Virtual Hosting With Different Users"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57","name":"Naina Johari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Naina Johari"},"url":"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/744"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=744"}],"version-history":[{"count":86,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/744\/revisions"}],"predecessor-version":[{"id":18535,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/744\/revisions\/18535"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/759"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}