{"id":854,"date":"2011-09-19T01:52:41","date_gmt":"2011-09-19T06:52:41","guid":{"rendered":"http:\/\/yourLinuxGuy.com\/?p=854"},"modified":"2011-09-19T21:56:24","modified_gmt":"2011-09-20T02:56:24","slug":"easy-webhosting-on-opensuse","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=854","title":{"rendered":"Easy webhosting on Opensuse&#8230;"},"content":{"rendered":"<p>I got this question from reader Ren:\u00a0 &#8220;<em>&#8230;I am looking for an article that assumes you have a web server running already on opensuse 11.3, and a friend asks you to host his web site for him as well and that he already has his own domain name registered.\u00a0 I would like the step by step guide to add the virtual hosting to my Opensuse 11.3 server to do that for him&#8230;<\/em>&#8221;<\/p>\n<p>Thanks for the question Ren; this one is a natural for me since I do it all the time!\u00a0 There might be a million better ways to do it, but here&#8217;s how I do it:<\/p>\n<p><strong>DNS<\/strong><\/p>\n<p>First, you have to set up the DNS.\u00a0 If your buddy has decided to service the domain names from the registrar or some other provider, just have him point the record for the site to your server.\u00a0 Typically, for a simple buddy-type web hosting deal, I just have him set up an &#8220;A&#8221; record for the domain record itself, and a &#8220;CNAME&#8221; to point &#8220;www&#8221; to that &#8220;A&#8221; record.<\/p>\n<p>If you are going to host the DNS records for your buddy, just do the same as above in your DNS server, but have your buddy point the DNS server pointer(s) to your server(s).<\/p>\n<p><strong>AppArmor<\/strong><\/p>\n<p>Since this is a Suse box, I have to mention this.\u00a0 We&#8217;re about to do something custom, so make sure that you&#8217;ve either built a custom set of profiles for AppArmor, or that you&#8217;ve disabled it.\u00a0 Guess which I prefer for testing.\u00a0 Now guess what I prefer for production.\u00a0 I&#8217;m not saying.<\/p>\n<p><strong>Apache2<\/strong><\/p>\n<p>Now,you need to set up the apache2 listener.\u00a0 Of course I have some custom stuff in my main apache config files, but your question was all about easy add-on hosting.<\/p>\n<p>Note that the main apache config file <code>httpd.conf<\/code> has a statement to &#8220;<code>Include<\/code>&#8221; everything in the folder <code>\/etc\/apache2\/vhosts.d\/<\/code> folder with a <code>*.conf<\/code> extension.\u00a0 So, whether you have all your virtual hosts in a single file or you have a separate file for each one, you simply need to add some lines in the correct <code>*.conf<\/code> file, somewhat like this:<\/p>\n<p><code>&lt;VirtualHost hostname:80&gt;<br \/>\nServerName yourlinuxguy.com<br \/>\nServerAlias *yourlinuxguy.com<br \/>\nDocumentRoot \/srv\/www\/htdocs\/yourlinuxguy.com<br \/>\nServerAdmin yourlinuxguy@yourlinuxguy.com<br \/>\nErrorLog \/var\/log\/httpd\/yourlinuxguy.com-error_log<br \/>\nCustomLog \/var\/log\/httpd\/yourlinuxguy.com-access_log combined<br \/>\n&lt;\/VirtualHost&gt;<\/code><\/p>\n<p>&#8230;where &#8220;<code>hostname<\/code>&#8221; matches a locally-resolvable host name ( meaning <code>\/etc\/hosts<\/code>); &#8220;<code>Servername<\/code>&#8221; reflects your instance that matches the DNS domain configuration; &#8220;<code>Serveralias<\/code>&#8221; allows any goofed-up host name that people enter to still work (especially if you put a DNS wildcard in place); &#8220;<code>Documentroot<\/code>&#8221; in my case as shown points to the standard Suse-style apache docs repository; and some other ancillary configs.\u00a0 I should confess that I actually have a couple more lines in my instance directive for security, but I don&#8217;t want to reveal them here&#8230; sorry&#8230;<\/p>\n<p>For content, just create a folder called:<\/p>\n<p><code>\/srv\/www\/htdocs\/yourlinuxguy.com\/<\/code><\/p>\n<p>&#8230;that has an <code>index.html<\/code> file that says something like &#8220;<code>Hello World<\/code>&#8221; in it or something.\u00a0 Of course, you already have permissions set on the folder structure, so that&#8217;s not a concern here now.<\/p>\n<p><strong>Logrotate<\/strong><\/p>\n<p>Don&#8217;t forget to rotate the logs!\u00a0 Note that from the apache config section above, you can see that I keep my logs in a separate folder.\u00a0 I prefer this method over just using the built-in apache logrotate directives, because this way I have one main logrotate directive handling every log in the folder, and I can easily control the filenames with a wildcard (multiple sites on this host, remember).\u00a0 Here&#8217;s an example of my homemade <code>\/etc\/logrotate.d\/httpd<\/code> file:<\/p>\n<p><code>\/var\/log\/httpd\/*log {<br \/>\ncompress<br \/>\ndateext<br \/>\nmaxage 31<br \/>\nrotate 4<br \/>\nsize=+1024k<br \/>\nnotifempty<br \/>\nmissingok<br \/>\ncreate 644 root root<br \/>\npostrotate<br \/>\n\/etc\/init.d\/apache2 reload<br \/>\nendscript<br \/>\n}<\/code><\/p>\n<p>Now, all you have to do is to restart apache with the command <code>rcapache2 restart<\/code>.<br \/>\nAnd once you point your browser at it, you should see your happy &#8220;Hello World&#8221; message, and your buddy will be happy.<\/p>\n<p>\ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I got this question from reader Ren:\u00a0 &#8220;&#8230;I am looking for an article that assumes you have a web server running already on opensuse 11.3, and a friend asks you to host his web site for him as well and&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=854\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[12,44,94],"tags":[],"class_list":["post-854","post","type-post","status-publish","format-standard","hentry","category-advanced","category-apache","category-opensuse11-3"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-dM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=854"}],"version-history":[{"count":3,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/854\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/854\/revisions\/858"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}