{"id":272,"date":"2021-05-26T13:16:09","date_gmt":"2021-05-26T11:16:09","guid":{"rendered":"https:\/\/blog.remyblom.nl\/?p=272"},"modified":"2021-06-15T09:40:17","modified_gmt":"2021-06-15T07:40:17","slug":"fresh-install-openbsd-6-9","status":"publish","type":"post","link":"https:\/\/blog.remyblom.nl\/?p=272","title":{"rendered":"Fresh install: OpenBSD 6.9"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2021\/05\/puffy69.jpg\" alt=\"\" class=\"wp-image-273\" width=\"734\" srcset=\"https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2021\/05\/puffy69.jpg 599w, https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2021\/05\/puffy69-300x99.jpg 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p>I recently lost a box due to unpaid invoices; all mail from my hosting partner ended up in my junk-folder, never saw them. So I had to get a new box and do a fresh install. Let&#8217;s write up the lessons learned while doing this.<\/p>\n\n\n\n<p>Thanks to my previous posts everything was back in no time, but since my first steps in OpenBSD were a bit bumpy I decided to do a new write-up, first let&#8217;s <a href=\"https:\/\/blog.remyblom.nl\/?p=70\">install OpenBSD<\/a>. The only problem I ran into was the fact that for some reason DHCP was not working so I had to manually configure the network.<\/p>\n\n\n\n<p>After that I followed my <a href=\"https:\/\/blog.remyblom.nl\/?p=79\">previous hardening procedures<\/a>. Learned about setting the clock on OpenBSD to fix a problem with <code>pkg_add<\/code>. To install some hard-needed utilities:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas pkg_add nano git rsync<\/code><\/pre>\n\n\n\n<p>Next up: installing and configuring the OEMP stack. The <code>acme-client<\/code> seems to be part of base these days, nice!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas pkg_add nginx mariadb-server php-mysqli<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">NGINX &amp; Let&#8217;s Encrypt certificates<\/h2>\n\n\n\n<p>I have a nice git-repo with all kinds of useful stuff to configure nginx called etc-nginx. Not public (yet). I clone it into <code>~\/git\/etc-nginx<\/code>.<\/p>\n\n\n\n<p>Preparing the <code>\/etc\/nginx<\/code> directory for my default way of working:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cd \/etc\/nginx\n$ doas ln -sf ~\/git\/etc-nginx\/common\n$ doas ln -sf ~\/git\/etc-nginx\/nginx-openbsd.conf nginx.conf\n$ doas mkdir cert\n$ doas openssl dhparam -out \/etc\/nginx\/cert\/dhparam.pem 4096\n$ doas mkdir sites-enabled\n$ cd \/etc\/nginx\/sites-enabled\n$ doas ln -sf ~\/git\/etc-nginx\/sites-available\/acme-challenge.conf\n$ doas nginx -t\n$ doas rcctl start nginx<\/code><\/pre>\n\n\n\n<p>Configure <code>acme-client<\/code> to automate the renewal of the Let&#8217;s Encrypt certificates.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas cp \/etc\/examples\/acme-client.conf \/etc\/acme-client.conf\n$ doas nano \/etc\/acme-client.conf<\/code><\/pre>\n\n\n\n<p>Change the <code>domain example.com<\/code> to your domain and add alternative names, change the location of the files to <code>\/etc\/nginx\/cert\/<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>domain example.com {\n  alternative names { secure.example.com }\n  domain key \"\/etc\/nginx\/cert\/key\"\n  domain full chain certificate \"\/etc\/nginx\/cert\/chain.crt\"\n  sign with letsencrypt\n}<\/code><\/pre>\n\n\n\n<p>Let&#8217;s run the client: (double v for extra verbose)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas acme-client -vv example.com<\/code><\/pre>\n\n\n\n<p>Add the dynamic vhosts configuration for single cert:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas ln -sf ~\/git\/etc-nginx\/sites-available\/dynamic-vhosts-single-cert.conf\n$ doas nginx -t\n$ doas rcctl reload nginx<\/code><\/pre>\n\n\n\n<p>Browsing to any of the domains pointing to this box should now work. Now that we have nginx running https we can add the certificate renewal to crontab:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas crontab -e\n\n30\t2\t*\t*\t*\tacme-client example.com &amp;&amp; rcctl reload nginx<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">PHP &amp; MariaDB<\/h2>\n\n\n\n<p>The packages are already installed so we only need to configure them.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas \/usr\/local\/bin\/mysql_install_db\n$ doas rcctl start mysqld\n$ doas \/usr\/local\/bin\/mysql_secure_installation\n$ doas ln -sf \/etc\/php-8.0.sample\/mysqli.ini \/etc\/php-8.0\/<\/code><\/pre>\n\n\n\n<p>Most times I just install a couple of php-modules because I will eventually end up using them anyway. Most notably <code>php-curl<\/code>. And as it turns out there is something you&#8217;ll need to do to make it work that caught me on one of my servers&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas cp \/etc\/resolv.conf \/var\/www\/etc\/resolv.conf<\/code><\/pre>\n\n\n\n<p>Make sure everything is enabled and starts at reboot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ doas rcctl enable httpd\n$ doas rcctl enable php80_fpm\n$ doas rcctl enable mysqld\n$ doas reboot<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Verify<\/h2>\n\n\n\n<p>Most simple way to verify the whole stack is by installing phpmyadmin into: <code>\/var\/www\/html\/phpmyadmin<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cd \/var\/www\/html\n$ doas curl -o file.tar.gz https:\/\/files.phpmyadmin.net\/phpMyAdmin\/5.1.0\/phpMyAdmin-5.1.0-english.tar.gz\n$ doas tar -xzf file.tar.gz\n$ doas ln -sf phpMyAdmin-5.1.0-english.tar.gz phpmyadmin\n$ cd phpmyadmin\n$ doas mkdir tmp\n$ doas chmod 777 tmp\n$ doas mv config.sample.inc.php config.inc.php\n$ doas nano config.inc.php <\/code><\/pre>\n\n\n\n<p>Add a 32 char long random string for Blowfish and enter 127.0.0.1 for the first server instead of localhost. Follow any upcoming errors in phpmyadmin&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">That&#8217;s it!<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>I recently lost a box due to unpaid invoices; all mail from my hosting partner ended up in my junk-folder, never saw them. So I had to get a new box and do a fresh install. Let&#8217;s write up the lessons learned while doing this. Thanks to my previous posts everything was back in no &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.remyblom.nl\/?p=272\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fresh install: OpenBSD 6.9&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,10,4,2],"tags":[],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-config","category-lemp","category-openbsd","category-vps"],"_links":{"self":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272"}],"version-history":[{"count":9,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/272\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/272\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}