{"id":5406,"date":"2016-01-27T16:53:03","date_gmt":"2016-01-27T14:53:03","guid":{"rendered":"http:\/\/www.karadere.com\/blog\/?p=5406"},"modified":"2016-01-27T16:53:03","modified_gmt":"2016-01-27T14:53:03","slug":"apache-ile-birden-fazla-domain-calistirmak-multiple-multi-domain-apache-web-service-configuration","status":"publish","type":"post","link":"https:\/\/www.karadere.com\/blog\/apache-ile-birden-fazla-domain-calistirmak-multiple-multi-domain-apache-web-service-configuration.html","title":{"rendered":"Apache ile birden fazla domain \u00e7al\u0131\u015ft\u0131rmak. Multiple multi domain apache web service configuration"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"http:\/\/blog.calik.me\/wp-content\/uploads\/2014\/01\/apache-logo.png\" alt=\"\" width=\"320\" height=\"220\" \/><\/p>\n<p>As complete beginner, I have been trying to host multiple domains on one Apache VPS. Tutorials had too much information that lead me to confusion.<\/p>\n<p>Below I describe, for complete beginners, how to host multiple domains on one VPS server with Ubuntu and Apache.<\/p>\n<p><strong>IMPORTANT!<\/strong> You need to use root account to execute most operations.<\/p>\n<p><strong>IMPORTANT!<\/strong> If you have been trying to make some changes to apache configuration before, undo them.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"http:\/\/www.linux.pl\/images\/publikacje\/logo\/RaspberryPi_Logo.png\" alt=\"\" width=\"730\" height=\"155\" \/><\/p>\n<h2>Creating VirtualHosts<\/h2>\n<p>Create folders for your domains on server. For example:<\/p>\n<pre><code>\/home\/apache\/domain1\n\n\/home\/apache\/domain2\n<\/code><\/pre>\n<p>Put index.html file in each folder with any text.<\/p>\n<pre><code>This is domain1\nThis is domain2\n<\/code><\/pre>\n<p>Go to \/etc\/apache2\/sites-available folder.<\/p>\n<pre><code>\/etc\/apache2\/sites-available\n<\/code><\/pre>\n<p>Create file domain1<\/p>\n<pre><code>sudo nano domain1.conf\n\n&lt;VirtualHost *:80&gt;\nDocumentRoot \/home\/apache\/domain1\nServerName domain1.com\nServerAlias www.domain1.com\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n<p>Create file domain2<\/p>\n<pre><code>sudo nano domain2.conf\n\n&lt;VirtualHost *:80&gt;\nDocumentRoot \/home\/apache\/domain2\nServerName domain2.com\nServerAlias www.domain2.com\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n<p>You can create subdomains same way.<\/p>\n<pre><code>sudo nano blog.conf\n\n&lt;VirtualHost *:80&gt;\nDocumentRoot \/home\/apache\/blog\nServerName blog.domain.com\nServerAlias www.blog.domain.com\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n<p>Enable created sites<\/p>\n<pre><code>sudo a2ensite domain1.conf\nsudo a2ensite domain2.conf\n<\/code><\/pre>\n<p>Restart apache<\/p>\n<pre><code>sudo service apache2 reload\n<\/code><\/pre>\n<h2>Redirecting domain to server<\/h2>\n<p>Created VirtualHosts will work only if you redirect your domain name to server IP. Domains are just names that can be translated to IP numbers.<\/p>\n<h1>Local computer<\/h1>\n<p>To test your configuration on local machine, you need to edit hosts file.<\/p>\n<pre><code>sudo nano \/etc\/hosts\n<\/code><\/pre>\n<p>It should look like this.<\/p>\n<pre><code>127.0.0.1       localhost domain1.com domain2.com\n<\/code><\/pre>\n<p>Hosts file tells your computer that domain needs to be redirected to local machine.<\/p>\n<p><strong>IMPORTANT!<\/strong> If you create entry in hosts file for existing domain, for example<\/p>\n<pre><code>127.0.0.1       stackoverflow.com\n<\/code><\/pre>\n<p>you will loose access to this website.<\/p>\n<h1>Server<\/h1>\n<p>In order to redirect domain to you web server, you need to create or modify &#8220;A&#8221;-type DNS record for given domain to IP address of your server. You can do it by panel control provided by your domain registrar.<\/p>\n<p>If you do not know IP address of your server, log in to that server and type in command line:<\/p>\n<pre><code>ifconfig\n\n\n<strong>Hatalar ve \u00e7\u00f6z\u00fcmleri :<\/strong>\n<\/code><\/pre>\n<pre><code>mv \/etc\/apache2\/sites-available\/mysite.com \/etc\/apache2\/sites-available\/mysite.com.conf\n\nconf dosyasi olmali yoksa<\/code><\/pre>\n<pre><code>sudo a2ensite domain1  \u00e7al\u0131\u015fm\u0131yor.<\/code><\/pre>\n<pre><code>sudo a2ensite domain1.conf olmal\u0131 <\/code><\/pre>\n<pre><code><strong>\u00a0Di\u011fer komutlar ile disable etmek.\n\n<\/strong><\/code># enable site\n<strong>sudo a2ensite<\/strong>\n\n# disable site\n<strong>sudo a2dissite<\/strong>\n\n# enable an apache2 module\n<strong>sudo a2enmod<\/strong>\n\n# e.g. a2enmod php4 will create the correct symlinks in mods-enabled to allow the module to be used. In this example it will link both php4.conf and php4.load for the user\n\n# disable an apache2 module\n<strong>sudo a2dismod<\/strong>\n\n# force reload the server:\n<strong>sudo \/etc\/init.d\/apache2 force-reload<\/strong><\/pre>\n<pre><code>\u00a0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Apache ile birden fazla domain \u00e7al\u0131\u015ft\u0131rmak. Multiple multi domain apache web service configuration<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[41],"tags":[],"class_list":["post-5406","post","type-post","status-publish","format-standard","hentry","category-programlama-software","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"aioseo_notices":[],"views":1727,"_links":{"self":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts\/5406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/comments?post=5406"}],"version-history":[{"count":0,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/posts\/5406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/media?parent=5406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/categories?post=5406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.karadere.com\/blog\/wp-json\/wp\/v2\/tags?post=5406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}