{"id":206,"date":"2021-05-01T03:36:19","date_gmt":"2021-05-01T03:36:19","guid":{"rendered":"https:\/\/hostup.org\/blog\/?p=206"},"modified":"2021-05-01T03:37:48","modified_gmt":"2021-05-01T03:37:48","slug":"create-public-mirror-step-by-step","status":"publish","type":"post","link":"https:\/\/hostup.se\/en\/blog\/create-public-mirror-step-by-step\/","title":{"rendered":"How to create a mirror step by step"},"content":{"rendered":"\n<p>Hey there again! So recently I went through all the steps on setting up a public mirror server, and website. The guides were not very user friendly so it took me quite some time, but eventually I got it working.. of course.<\/p>\n\n\n\n<p>Here&#8217;s our mirror: <a href=\"https:\/\/mirror.hostup.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/mirror.hostup.org\/<\/a><\/p>\n\n\n\n<p>We currently got CentOS, OpenVZ and some other ones avaliable. If you&#8217;re a customer of ours I recommend that you switch to these mirrors for the fastest speeds. Eitherway, let&#8217;s get to it! Here&#8217;s 3 simple steps on setting up a mirror just like ours:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. What kind of mirrors do you want?<\/h2>\n\n\n\n<p>The first step is figuring out what mirrors you want to have. Every mirror has the same installation process so I am going to take the CentOS mirror as an example. It all starts with you requiring to install a webserver and rsync.<\/p>\n\n\n\n<p>To install Apache on a CentOS server run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install httpd<\/pre>\n\n\n\n<p>If you&#8217;re using a Debian based operating system run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install apache2<\/pre>\n\n\n\n<p>After you&#8217;ve installed Apache you need to edit your configs so that they support directory listing as well as allowing for .htaccess. On CentOS the configuration files are found in \/etc\/httpd\/conf.d, however on some operating systems they may be in \/etc\/apache\/conf.d.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rm \/etc\/apache\/conf.d\/default.conf<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">nano \/etc\/apache\/conf.d\/default.conf<\/pre>\n\n\n\n<p>Paste the following inside the newly created file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80&gt;\n    ServerAdmin admin@domain.com\n    DocumentRoot \"\/var\/html\/www\"\n    Options +Indexes\n    ServerName mirror.domain.com\n    ErrorLog \"\/var\/log\/httpd\/domain.com.error_log\"\n    CustomLog \"\/var\/log\/httpd\/domain.com.access_log\" common\n  IndexOptions FancyIndexing NameWidth=* FoldersFirst ScanHTMLTitles DescriptionWidth=*\n  HeaderName HEADER.html\n  ReadmeName README.html\n  Options Indexes SymLinksIfOwnerMatch FollowSymLinks\n  ErrorDocument 404 default\n&lt;\/VirtualHost&gt;\n\n&lt;Directory \/var\/html\/www&gt;\n        Options Indexes FollowSymLinks\n        AllowOverride All\n        Require all granted\n&lt;\/Directory&gt;<\/code><\/pre>\n\n\n\n<p>Next you should restart your apache for the changes to take effect, but because apache has two different names depending on whether you&#8217;re on CentOS or not, the restart command will be different too. If you&#8217;re on CentOS run the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">service httpd restart<\/pre>\n\n\n\n<p>Otherwise run the following<\/p>\n\n\n\n<pre id=\"block-fa26fc9e-5cdd-4fd4-a4f5-15569c7eb764\" class=\"wp-block-preformatted\">service apache restart<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Sync from another mirror<\/h2>\n\n\n\n<p>Okay, once you&#8217;ve got your webserver setup and configured you need to sync with another mirror. The tool you need to do this is called rsync, and here&#8217;s how you can install it.<\/p>\n\n\n\n<p>For CentOS you need to run the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install rsync<\/pre>\n\n\n\n<p>For Debian\/Ubuntu you need to run the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install rsync<\/pre>\n\n\n\n<p>Okay, next up we just need to start syncing. I recommend that you use a screen window to sync because it will take many hours to do this, and if your SSH connection cuts out, the sync will also stop. Just type <strong>screen<\/strong> in the terminal to open a new window.<\/p>\n\n\n\n<p>Once you&#8217;re in the screen window just type the following command to start syncing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rsync -av --delete rsync:\/\/mirror.cogentco.com\/CentOS\/ \/var\/www\/centos<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\/var\/www\/centos<\/strong> your webserver directory path plus directory where the files will be stored<\/li><li><strong>-v<\/strong> verbose mode<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. Keep your mirror updated<\/h2>\n\n\n\n<p>Once it has finished syncing it&#8217;s important to keep it updated by syncing off other mirrors. The best tool for this is using cron.<\/p>\n\n\n\n<p>Get started by typing the following in your terminal:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">crontab -e<\/pre>\n\n\n\n<p>Then add a new line and add the following information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">40 *\/4 * * * rsync -aq --delete rsync:\/\/mirror.cogentco.com\/CentOS\/ \/var\/www\/centos<\/pre>\n\n\n\n<p>This will run the following command in quiet mode (-q) so that it doesn&#8217;t create huge log files for no reason. It will also run this command every 4 hours.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey there again! So recently I went through all the steps on setting up a public mirror server, and website. The guides were not very user friendly so it took me quite some time, but eventually I got it working.. of course. Here&#8217;s our mirror: https:\/\/mirror.hostup.org\/ We currently got CentOS, OpenVZ and some other ones [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":139,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,10],"tags":[],"class_list":["post-206","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-tutorials"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/comments?post=206"}],"version-history":[{"count":4,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/206\/revisions\/210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media?parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/categories?post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/tags?post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}