<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chocolatine31</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chocolatine31"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Chocolatine31"/>
	<updated>2026-04-25T18:12:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Protecting_your_email_server_with_Alpine&amp;diff=30885</id>
		<title>Protecting your email server with Alpine</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Protecting_your_email_server_with_Alpine&amp;diff=30885"/>
		<updated>2025-09-08T20:51:59Z</updated>

		<summary type="html">&lt;p&gt;Chocolatine31: correcting few typos in the commands formating&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Obsolete|These directions are for Alpine 1.7..............}}&lt;br /&gt;
&lt;br /&gt;
This document will outline how you can setup a spam/virus gateway with Alpine Linux. I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!&lt;br /&gt;
&lt;br /&gt;
First thing I want to mention is, it is probably not a good way to setup Postfix on a disk less system (having the mailer spool in memory). If you would ever suffer from power failure you would loose the contents of your Postfix spool. That said, in our organization we are using a UPS device to supply our servers with backup power, so the chances that our server would shutdown because of power failure is minimal (and we are prepared to take this risk).&lt;br /&gt;
&lt;br /&gt;
For this particular setup we are going to use the following:&lt;br /&gt;
&lt;br /&gt;
* Mailer daemon: Postfix&lt;br /&gt;
* Virus scanner: Clamav&lt;br /&gt;
* SMTP filter: Clamsmtp&lt;br /&gt;
* Greylisting server: Gross&lt;br /&gt;
* Extra definitions: SaneSecurity &amp;amp; MSRBL&lt;br /&gt;
* Exchange 2003 users/groups in relay_recipient_maps&lt;br /&gt;
* Alpine Linux 1.7.19 (some packages are not available before this version)&lt;br /&gt;
&lt;br /&gt;
== Setting up the Mailer daemon ==&lt;br /&gt;
The first thing we are going to install is our mailer daemon:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add postfix}}&lt;br /&gt;
&lt;br /&gt;
This will install Postfix with a default configuration in /etc/postfix. Lets first take a look at main.cf, this is the (as the name implies) main configuration file for Postfix. I will show you my configuration file which you can use (I&#039;ve commented out some options which we enable later on):&lt;br /&gt;
&lt;br /&gt;
 mynetworks = &#039;&#039;&#039;lan-net&#039;&#039;&#039;/24, 127.0.0.0/8&lt;br /&gt;
 transport_maps = hash:/etc/postfix/transport&lt;br /&gt;
 relay_domains = $transport_maps&lt;br /&gt;
 smtpd_helo_required = yes&lt;br /&gt;
 &#039;&#039;&#039;disable_vrfy_command = yes&#039;&#039;&#039;&lt;br /&gt;
 #relay_recipient_maps = hash:/etc/postfix/exchange_receipients&lt;br /&gt;
&lt;br /&gt;
 smtpd_recipient_restrictions =&lt;br /&gt;
     reject_invalid_hostname,&lt;br /&gt;
     reject_non_fqdn_hostname,&lt;br /&gt;
     reject_non_fqdn_sender,&lt;br /&gt;
     reject_non_fqdn_recipient,&lt;br /&gt;
     reject_unknown_sender_domain,&lt;br /&gt;
     reject_unknown_recipient_domain,&lt;br /&gt;
     permit_mynetworks,&lt;br /&gt;
     reject_unauth_destination,&lt;br /&gt;
     #check_policy_service inet:127.0.0.1:5525,&lt;br /&gt;
     #&lt;br /&gt;
     # in case you want reject DNS blacklists rather than greylist them&lt;br /&gt;
     # with gross, uncomment the lines below&lt;br /&gt;
     #&lt;br /&gt;
     #  reject_rbl_client cbl.abuseat.org,&lt;br /&gt;
     #  reject_rbl_client sbl.spamhaus.org,&lt;br /&gt;
     #  reject_rbl_client pbl.spamhaus.org,&lt;br /&gt;
     #  reject_rbl_client bl.spamcop.net,&lt;br /&gt;
     #  reject_rbl_client list.dsbl.org,&lt;br /&gt;
     permit&lt;br /&gt;
&lt;br /&gt;
 smtpd_data_restrictions =&lt;br /&gt;
     reject_unauth_pipelining,&lt;br /&gt;
     permit&lt;br /&gt;
&lt;br /&gt;
 #content_filter = scan:[127.0.0.1]:10025&lt;br /&gt;
&lt;br /&gt;
{{Note|Don&#039;t forget to change &#039;&#039;&#039;lan-net&#039;&#039;&#039; to your lan subnet.}}&lt;br /&gt;
&lt;br /&gt;
These are the minimal settings I use to setup a postfix mail gateway. If you are looking for other settings please issue the following command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|postconf |more}}&lt;br /&gt;
&lt;br /&gt;
This will display your current default configuration. If you want to change any of these settings you can add them to main.cf and reload postfix. Looking at my main.cf file you will see the setting &amp;quot;transport_maps&amp;quot;. This setting refers to a file inside the postfix config directory which will hold information for postfix to which server it should forward email to. It should look similar like this:&lt;br /&gt;
&lt;br /&gt;
 domain-a.tld   smtp:[192.168.1.1]&lt;br /&gt;
 domain-b.tld   smtp:[192.168.1.2]&lt;br /&gt;
&lt;br /&gt;
When ever an email enters our mail gateway for a domain specified in our &amp;quot;transport_maps&amp;quot; file it will forward this email after processing to the IP address assigned. For complete documentation please refer to the postfix docs. When are ready editing this file, issue the following command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|postmap /etc/postfix/transport}}&lt;br /&gt;
&lt;br /&gt;
This will create a hash db of this file which will be easier/faster for postfix to read. The second setting we will look at is &#039;relay_domains&amp;quot;. This setting will tell postfix for which domains it will relay emails. Because this setting will most probably be the same as the domains we mention in &amp;quot;transport_maps&amp;quot; we can just link to it. Now your basic email gateway is ready and you can start it but remember there will be no virus or spam filtering.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service postfix start}}&lt;br /&gt;
&lt;br /&gt;
We can start it at boot:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add postfix}}&lt;br /&gt;
&lt;br /&gt;
== Setting up the Virus scanner ==&lt;br /&gt;
&lt;br /&gt;
To be able to filter out viruses from our emails we need a virus scanner. The only real open-source solution available is Clamav. Lets install it:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add clamav}}&lt;br /&gt;
&lt;br /&gt;
We will be using the daemonized version of Clamav &amp;quot;clamd&amp;quot;. There is nothing we need to change for Clamav, we can use the default settings and the virus definitions are automatically updated with freshclam. Lets start it:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service clamd start}}&lt;br /&gt;
&lt;br /&gt;
Lets start it at boot:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add clamd}}&lt;br /&gt;
&lt;br /&gt;
{{Note|I have had memory issues with clamd on Alpine. I am still looking for an solution regarding this. For now I advise you to restart clamd with cron everyday.}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UPDATE:&#039;&#039;&#039; See https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1028 this should be fixed in clamav 0.93.1&lt;br /&gt;
&lt;br /&gt;
== Setting up the SMTP filter ==&lt;br /&gt;
&lt;br /&gt;
Ok so now we got a mail daemon and a virus daemon installed and setup ready. Now we need the two daemons to talk to each other. The most popular tool to do so is amavisd-new but it is based on Perl and I don&#039;t like it because Perl can be a resource hog and I&#039;m not planning to install it on my Alpine install. Another lighter C-based solution is Clamsmtp. It is a SMTP filter which listens for incoming connections and scans the emails with clamd and forwards it back again to the MTA. It doesn&#039;t come with a lot of features like amavisd-new does but its enough for me. Lets install it:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add clamsmtp}}&lt;br /&gt;
&lt;br /&gt;
Here is my clamsmtp.conf configuration file:&lt;br /&gt;
&lt;br /&gt;
 OutAddress: 127.0.0.1:10026&lt;br /&gt;
 Listen: 127.0.0.1:10025&lt;br /&gt;
 ClamAddress: /var/run/clamav/clamd.sock&lt;br /&gt;
 TempDirectory: /tmp&lt;br /&gt;
 Action: drop&lt;br /&gt;
 Quarantine: on&lt;br /&gt;
 User: clamav&lt;br /&gt;
 VirusAction: /etc/postfix/scripts/virus_action.sh&lt;br /&gt;
&lt;br /&gt;
Clamsmtp has support for a virus action script which will be run each time clamd returns a positive detection. I have included my virus action script here but it has not been tested enough so use it at your own risk! Make sure you set the correct permissions on the /etc/postfix/scripts/ directory because clamsmtp will run as user clamav. Monitor the log file in your /tmp directory.&lt;br /&gt;
&lt;br /&gt;
[[virus_action.sh]]&lt;br /&gt;
&lt;br /&gt;
{{Note|Here in our organization we are running Exchange 2003. Exchange has support for public folders which is a good way of storing the files we filter with Clamsmtp. Make sure you have proper permissions and size limitations for the public folder so it doesn&#039;t get to big and other people cannot access the folder, remember it will contain viruses!}}&lt;br /&gt;
&lt;br /&gt;
Ok lets configure postfix for clamsmtp by editing our master.cf and adding the following lines to the end of the file:&lt;br /&gt;
&lt;br /&gt;
 # AV scan filter (used by content_filter)&lt;br /&gt;
 scan      unix  -       -       n       -       16      smtp&lt;br /&gt;
         -o smtp_send_xforward_command=yes&lt;br /&gt;
         -o smtp_enforce_tls=no&lt;br /&gt;
 # For injecting mail back into postfix from the filter&lt;br /&gt;
 127.0.0.1:10026 inet  n -       n       -       16      smtpd&lt;br /&gt;
         -o content_filter=&lt;br /&gt;
         -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks&lt;br /&gt;
         -o smtpd_helo_restrictions=&lt;br /&gt;
         -o smtpd_client_restrictions=&lt;br /&gt;
         -o smtpd_sender_restrictions=&lt;br /&gt;
         -o smtpd_recipient_restrictions=permit_mynetworks,reject&lt;br /&gt;
         -o mynetworks_style=host&lt;br /&gt;
         -o smtpd_authorized_xforward_hosts=127.0.0.0/8&lt;br /&gt;
&lt;br /&gt;
Lets start Clamsmtp:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service clamstmp start}}&lt;br /&gt;
&lt;br /&gt;
And add it to our system start:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add clamsmtp}}&lt;br /&gt;
&lt;br /&gt;
If you are sure all your settings are correct we can uncomment the &amp;quot;content_filter&amp;quot; line in our main.cf which will enable Clamsmtp for Postfix and run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|postfix reload}}&lt;br /&gt;
&lt;br /&gt;
== Setting up the Greylisting Server ==&lt;br /&gt;
&lt;br /&gt;
I have used greylisting for several months now and while it has it positive affects it also has its negative. One of the positive affects is that you will get almost no spam/virus emails into your system anymore but it will introduce a delay to a part of you email traffic. If your organization is big enough you will start to notice people complain about delayed emails, this is where Gross will jump in. It still uses greylisting but it will not do so for all hosts but only the ones that are matched to the specified DNSBL databases. If you want to find out more regarding gross please go to their website:&lt;br /&gt;
&lt;br /&gt;
https://code.google.com/p/gross/&lt;br /&gt;
&lt;br /&gt;
Lets install gross:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add gross}}&lt;br /&gt;
&lt;br /&gt;
Here is my grossd.conf file:&lt;br /&gt;
&lt;br /&gt;
 protocol = postfix&lt;br /&gt;
 statefile = /var/db/gross/state&lt;br /&gt;
 check = dnsbl&lt;br /&gt;
 check = rhsbl&lt;br /&gt;
 dnsbl = zen.spamhaus.org&lt;br /&gt;
 dnsbl = list.dsbl.org&lt;br /&gt;
 dnsbl = bl.spamcop.net&lt;br /&gt;
 dnsbl = combined.njabl.org&lt;br /&gt;
 dnsbl = cbl.abuseat.org&lt;br /&gt;
 dnsbl = dnsbl.sorbs.net&lt;br /&gt;
 rhsbl = rhsbl.sorbs.net&lt;br /&gt;
&lt;br /&gt;
Lets start grossd:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service grossd start}}&lt;br /&gt;
&lt;br /&gt;
{{Note| The init file for gross will automatically generate the grossd state file in the directory specified in its config file. Because we are running Alpine from memory the state file is not saved to disk so we need to add it to our backup with lbu_commit. The safest way to do this is the first stop grossd before committing the changes to our backup.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu_include /var/db/gross/state}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service grossd stop}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu_commit}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service grossd start}}&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start it at boot:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add grossd}}&lt;br /&gt;
&lt;br /&gt;
Now we need to make Postfix use our greylisting service by uncommenting the &amp;quot;check_policy_service&amp;quot; line in our main.cf and run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|postfix reload}}&lt;br /&gt;
&lt;br /&gt;
== Setting up SaneSecurity &amp;amp; MSRBL extra definitions ==&lt;br /&gt;
Another good way of catching SPAM is Sanesecurity and MSRBL definitions. You can find more information regarding these definitions here:&lt;br /&gt;
&lt;br /&gt;
https://www.sanesecurity.co.uk/ &lt;br /&gt;
&lt;br /&gt;
To use the following script you will need to install the following packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add curl rsync}}&lt;br /&gt;
&lt;br /&gt;
[[up_clam_ex.sh]]&lt;br /&gt;
&lt;br /&gt;
Add this script to this /etc/postfix/scripts/ directory&lt;br /&gt;
&lt;br /&gt;
And add this script to cron:&lt;br /&gt;
 echo &amp;quot;37 03 * * * /etc/postfix/scripts/up_clam_ex.sh &amp;amp;&amp;gt; /dev/nul&amp;quot; &amp;gt;&amp;gt; /etc/crontabs/root&lt;br /&gt;
&lt;br /&gt;
{{Note|Please adjust the time so not everybody runs it at the same time.}}&lt;br /&gt;
&lt;br /&gt;
And make sure cron is running at boot:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add cron}}&lt;br /&gt;
&lt;br /&gt;
== Exchange 2003 &amp;amp; relay_recipient_maps ==&lt;br /&gt;
Postfix will process mail for every email address which are specified in &amp;quot;relay_domains&amp;quot;. Because we want to prevent Postfix to process emails for destinations which do not exist, we add the relay_recipient_maps option to our main.cf file. I&#039;ve already added it so it only needs to be uncommented. I have included a Visual Basic script here which will extract all valid email addresses of users and groups in exchange 2003 and put them in a text file inside the root of our IIS server. I&#039;ve also included a script which will download this file and process it to a db which can be read by Postfix. Put the following file somewhere on your exchange server and make it run every so much time with a windows task:&lt;br /&gt;
&lt;br /&gt;
[[export_receipts.vbs]]&lt;br /&gt;
&lt;br /&gt;
Download the following file and move it to:&lt;br /&gt;
&lt;br /&gt;
[[exchange_receipients.sh]]&lt;br /&gt;
&lt;br /&gt;
 /etc/postfix/scripts/&lt;br /&gt;
&lt;br /&gt;
And change it&#039;s settings and add it to cron. I&#039;ve setup a time 10 minutes after I run the vbs script on my exchange server:&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;10,40 * * * * /etc/postfix/scripts/exchange_receipients.sh &amp;amp;&amp;gt; /dev/nul&amp;quot; &amp;gt;&amp;gt; /etc/crontabs/root&lt;br /&gt;
&lt;br /&gt;
[[Category:Mail]]&lt;/div&gt;</summary>
		<author><name>Chocolatine31</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hosting_Web/Email_services_on_Alpine&amp;diff=30884</id>
		<title>Hosting Web/Email services on Alpine</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hosting_Web/Email_services_on_Alpine&amp;diff=30884"/>
		<updated>2025-09-08T20:47:18Z</updated>

		<summary type="html">&lt;p&gt;Chocolatine31: typo in a package name (clamsmtpd instead of clamsmtp)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Merge|Hosting services on Alpine}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This information was pulled from a few other pages on the Alpine Wiki website, see links, along with the websites for the particular packages. It is a suggestion/step by step instruction guide. &lt;br /&gt;
&lt;br /&gt;
You might be wondering, why would anyone want to run Web and Email services off a Linux install that runs in ram? Good question. With Vservers we can run the host in Memory and do all sorts of things with the guests. Put the guests on DAS in the host machine or do raided iSCSI for the guest. This way if your disks start going bad or drop off entirely you most likely will be able to get at the data from a running system. &lt;br /&gt;
   &lt;br /&gt;
                     Guest OS here or&lt;br /&gt;
 [Host Alpine Box] --------------------- [DAS]&lt;br /&gt;
     |    |&lt;br /&gt;
     |    |Guest OS here&lt;br /&gt;
     |    |&lt;br /&gt;
   iSCSI  iSCSI &lt;br /&gt;
&lt;br /&gt;
== Web Services ==&lt;br /&gt;
There are many http servers out there. Alpine comes with a few different ones. For this guide we installed lighttpd. &lt;br /&gt;
&lt;br /&gt;
 apk update&lt;br /&gt;
 apk add lighttpd openssl php&lt;br /&gt;
&lt;br /&gt;
Most everything is already taken care of with lighttpd. Make sure to uncomment the ssl options&lt;br /&gt;
 ssl.engine = &amp;quot;enable&amp;quot;&lt;br /&gt;
 ssl.pemfile = &amp;quot;/etc/lighttpd/server.pem&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 rc-service lighttpd start&lt;br /&gt;
See below for generating the server.pem&lt;br /&gt;
&lt;br /&gt;
Now you can start using lighttpd and start making your own website. Alpine come with phpBB and mediawiki if you want to use those. You may have to use a sql database. The place to put your pages is &lt;br /&gt;
 /var/www/localhost/htdocs/&lt;br /&gt;
By default lighttpd uses symlinks and does so correctly. So you can just symlink to directories when your pages may be also&lt;br /&gt;
 ln -s /home/user/htdocs /var/www/localhost/htdocs/user&lt;br /&gt;
&lt;br /&gt;
===Generating the Server.pem===&lt;br /&gt;
For other services we are also going to be using ssl. An easy way to just start using it is generating your own self sign cert. Script and Configuration file taken from setup-webconf script on Alpine.&lt;br /&gt;
&lt;br /&gt;
ssl.cnf&lt;br /&gt;
 [ req ]&lt;br /&gt;
 default_bits = 1024&lt;br /&gt;
 encrypt_key = yes&lt;br /&gt;
 distinguished_name = req_dn&lt;br /&gt;
 x509_extensions = cert_type&lt;br /&gt;
 prompt = no&lt;br /&gt;
 [ req_dn ]&lt;br /&gt;
 OU=HTTPS server&lt;br /&gt;
 CN=example.net&lt;br /&gt;
 emailAddress=postmaster@example.net&lt;br /&gt;
 [ cert_type ]&lt;br /&gt;
 nsCertType = server&lt;br /&gt;
&lt;br /&gt;
ssl.sh&lt;br /&gt;
 #/bin/sh&lt;br /&gt;
 openssl genrsa 512/1024 &amp;gt;server.pem&lt;br /&gt;
 openssl req -new -key server.pem -days 365 -out request.pem&lt;br /&gt;
 openssl genrsa 2048 &amp;gt; keyfile.pem&lt;br /&gt;
 openssl req -new -x509 -nodes -sha1 -days 3650 -key keyfile.pem \&lt;br /&gt;
 -config ssl.cnf &amp;gt; server.pem&lt;br /&gt;
 cat keyfile.pem &amp;gt;&amp;gt; server.pem&lt;br /&gt;
&lt;br /&gt;
If you use this to generate the ssl certs for other services you may just change the req_dn information.&lt;br /&gt;
&lt;br /&gt;
==Mail Services==&lt;br /&gt;
&lt;br /&gt;
Some of the information presented can be found here also. This though is for a email gateway.&lt;br /&gt;
[[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 apk add postfix dovecot clamav clamsmtp gross&lt;br /&gt;
&lt;br /&gt;
===Postfix===&lt;br /&gt;
Postfix has a few things that need to be added to its configuration so that it can send email through clamav and also so it will accept mail for domains and users.&lt;br /&gt;
&lt;br /&gt;
====Main.cf====&lt;br /&gt;
vi /etc/postfix/main.cf&lt;br /&gt;
 #/etc/postfix/main.cf&lt;br /&gt;
 myhostname = mx.example.net&lt;br /&gt;
 mydomain = example.net&lt;br /&gt;
 relayhost = #blank will do dns lookups for destinations&lt;br /&gt;
 home_maildir = Maildir/&lt;br /&gt;
 smtpd_banner = $myhostname ESMTP #The way postfix answers. &lt;br /&gt;
 transport_maps = hash:/etc/postfix/transport #Place to add how you want to route domains. See example below. Show how to host more than one domain.&lt;br /&gt;
 local_transport = virtual&lt;br /&gt;
 virtual_mailbox_domains = example.net, bobo.net #list of hosted domains&lt;br /&gt;
 virtual_mailbox_base = /var/spool/vhosts&lt;br /&gt;
 virtual_uid_maps = static:1004 # uid of user to be used to read/write mail  &lt;br /&gt;
 virtual_gid_maps = static:1004 # gid of user to be used to read/write mail &lt;br /&gt;
 virtual_alias_maps = hash:/etc/postfix/valias #alias for each different hosted domain. See below.&lt;br /&gt;
 virtual_mailbox_maps = hash:/etc/postfix/vmap #where and what mailbox to drop the mail to. See below.&lt;br /&gt;
 smtpd_helo_required = yes&lt;br /&gt;
 disable_vrfy_command = yes&lt;br /&gt;
 content_filter = scan:[127.0.0.1]:10025 # clamscan to be configured later&lt;br /&gt;
 smtpd_recipient_restrictions = reject_unauth_pipelining, permit_sasl_authenticated,permit_mynetworks,reject_invalid_hostname, reject_non_fqdn_hostname,reject_non_fqdn_sender, reject_non_fqdn_recipient,reject_unknown_sender_domain, reject_unknown_recipient_domain,reject_unauth_destination, check_policy_service inet:127.0.0.1:5525,permit&lt;br /&gt;
 smtpd_data_restrictions = reject_unauth_pipelining, permit&lt;br /&gt;
 smtpd_sasl_auth_enable = yes&lt;br /&gt;
 broken_sasl_auth_clients = yes&lt;br /&gt;
 smtpd_sasl_type = dovecot&lt;br /&gt;
 smtpd_sasl_path = private/auth&lt;br /&gt;
 smtpd_tls_cert_file = /etc/ssl/postfix/server.pem&lt;br /&gt;
 smtpd_tls_key_file = $smtpd_tls_cert_file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Master.cf====&lt;br /&gt;
Settings in the master.cf for virus/spam scanning. Add these to the end of the file. Similar to those found [[Protecting your email server with Alpine]].&lt;br /&gt;
&lt;br /&gt;
 scan    unix    -       -       n       -       16      smtp&lt;br /&gt;
        -o smtp_send_xforward_command=yes&lt;br /&gt;
        -o smtp_enforce_tsl=no&lt;br /&gt;
 127.0.0.1:10026 inet    n       -       n       -       16      smtpd&lt;br /&gt;
        -o content_filter=&lt;br /&gt;
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks&lt;br /&gt;
        -o smtpd_helo_restrictions=&lt;br /&gt;
        -o smtpd_client_restrictions=&lt;br /&gt;
        -o smtpd_sender_restrictions=&lt;br /&gt;
        -o smtpd_recipient_restrictions=permit_mynetworks,reject&lt;br /&gt;
        -o mynetworks_style=host&lt;br /&gt;
        -o smtpd_authorized_xforward_host=127.0.0.1/8&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Valias==== &lt;br /&gt;
 #etc/postfix/valias&lt;br /&gt;
 postmaster@example.net user1@example.net&lt;br /&gt;
 hostmaster@example.net user2@example.net&lt;br /&gt;
 hostmaster@bobo.net    user1@example.net&lt;br /&gt;
 postmaster@bobo.net    user2@bobo.net&lt;br /&gt;
&lt;br /&gt;
====Vmap====&lt;br /&gt;
 #/etc/postfix/vmap&lt;br /&gt;
 user1@example.net      example.net/user1&lt;br /&gt;
 user2@example.net      example.net/user2&lt;br /&gt;
 @example.net           example.net/catchall #everyone else doesn&#039;t match rule above&lt;br /&gt;
&lt;br /&gt;
====Transport====&lt;br /&gt;
 #/etc/postfix/transport&lt;br /&gt;
 example.net      virtual:&lt;br /&gt;
 bobo.net         virtual:&lt;br /&gt;
 foo.net          smtp:1.2.3.4 #send foo.net through this smtp server&lt;br /&gt;
 *                :   #everything else go through relayhost rule&lt;br /&gt;
&lt;br /&gt;
Once these files are created you will need to make them into .db files&lt;br /&gt;
 postmap valias&lt;br /&gt;
 postmap transport&lt;br /&gt;
 postmap vmap&lt;br /&gt;
&lt;br /&gt;
===Dovecot===&lt;br /&gt;
Dovecot on Alpine will only do imap and imaps services for now. &lt;br /&gt;
&lt;br /&gt;
Most of dovecot is configured already for imap. You may have to gen the key as shown above. Just change the cnf file a little to say something about mail.domainname. &lt;br /&gt;
 &lt;br /&gt;
 ssl_cert_file = /etc/ssl/dovecot/server.pem&lt;br /&gt;
 ssl_key_file = /etc/ssl/dovecot/keyfile.pem&lt;br /&gt;
 mail_location = maildir:/var/spool/vhosts/&amp;amp;d/%n&lt;br /&gt;
 valid_chroot_dirs = /var/spool/vhosts&lt;br /&gt;
 passdb passwd-file {&lt;br /&gt;
 args = /etc/dovecot/passwd&lt;br /&gt;
 }&lt;br /&gt;
 userdb passwd-file {&lt;br /&gt;
 args = /etc/dovecot/users&lt;br /&gt;
 }&lt;br /&gt;
 #section for postfix sasl auth&lt;br /&gt;
 socket listen {&lt;br /&gt;
 client {&lt;br /&gt;
 path = /var/spool/postfix/private/auth&lt;br /&gt;
 user = postfix&lt;br /&gt;
 group = postfix &lt;br /&gt;
 mode = 0660&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
To generate the passwords you can use the dovecotpw command.&lt;br /&gt;
 dovecotpw -s MD5-CRYPT &lt;br /&gt;
&lt;br /&gt;
The hash below can be used for the password test123&lt;br /&gt;
&lt;br /&gt;
The /etc/dovecot/passwd file should look like this:&lt;br /&gt;
 user1@example.net:$1$tz5sbjAD$Wq9.NkSyNo/oElzFgI68.0&lt;br /&gt;
 user2@example.net:$1$tz5sbjAD$Wq9.NkSyNo/oElzFgI68.0&lt;br /&gt;
&lt;br /&gt;
THe /etc/dovecot/userdb file should look like this:&lt;br /&gt;
 user1@example.net::1004:1004::/var/spool/vhosts/example.net/:/bin/false::&lt;br /&gt;
 user2@example.net::1004:1004::/var/spool/vhosts/example.net/:/bin/false::&lt;br /&gt;
 user@domain::uid : gid of found in virtual_uid_maps::location of maildir:shell::&lt;br /&gt;
&lt;br /&gt;
===Clamsmtpd===&lt;br /&gt;
Configure according to instructions [[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
===Gross===&lt;br /&gt;
Configure according to instructions [[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
===Final Steps ===&lt;br /&gt;
Start the services and make sure to rc-update them&lt;br /&gt;
 rc-service postfix start&lt;br /&gt;
 rc-update add postfix default&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Mail]]&lt;/div&gt;</summary>
		<author><name>Chocolatine31</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hosting_Web/Email_services_on_Alpine&amp;diff=30883</id>
		<title>Hosting Web/Email services on Alpine</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hosting_Web/Email_services_on_Alpine&amp;diff=30883"/>
		<updated>2025-09-08T20:39:41Z</updated>

		<summary type="html">&lt;p&gt;Chocolatine31: Update some &amp;#039;apk&amp;#039; and &amp;#039;rc-update&amp;#039; command to match their current state (wasn&amp;#039;t updated since 2008)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Merge|Hosting services on Alpine}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This information was pulled from a few other pages on the Alpine Wiki website, see links, along with the websites for the particular packages. It is a suggestion/step by step instruction guide. &lt;br /&gt;
&lt;br /&gt;
You might be wondering, why would anyone want to run Web and Email services off a Linux install that runs in ram? Good question. With Vservers we can run the host in Memory and do all sorts of things with the guests. Put the guests on DAS in the host machine or do raided iSCSI for the guest. This way if your disks start going bad or drop off entirely you most likely will be able to get at the data from a running system. &lt;br /&gt;
   &lt;br /&gt;
                     Guest OS here or&lt;br /&gt;
 [Host Alpine Box] --------------------- [DAS]&lt;br /&gt;
     |    |&lt;br /&gt;
     |    |Guest OS here&lt;br /&gt;
     |    |&lt;br /&gt;
   iSCSI  iSCSI &lt;br /&gt;
&lt;br /&gt;
== Web Services ==&lt;br /&gt;
There are many http servers out there. Alpine comes with a few different ones. For this guide we installed lighttpd. &lt;br /&gt;
&lt;br /&gt;
 apk update&lt;br /&gt;
 apk add lighttpd openssl php&lt;br /&gt;
&lt;br /&gt;
Most everything is already taken care of with lighttpd. Make sure to uncomment the ssl options&lt;br /&gt;
 ssl.engine = &amp;quot;enable&amp;quot;&lt;br /&gt;
 ssl.pemfile = &amp;quot;/etc/lighttpd/server.pem&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 rc-service lighttpd start&lt;br /&gt;
See below for generating the server.pem&lt;br /&gt;
&lt;br /&gt;
Now you can start using lighttpd and start making your own website. Alpine come with phpBB and mediawiki if you want to use those. You may have to use a sql database. The place to put your pages is &lt;br /&gt;
 /var/www/localhost/htdocs/&lt;br /&gt;
By default lighttpd uses symlinks and does so correctly. So you can just symlink to directories when your pages may be also&lt;br /&gt;
 ln -s /home/user/htdocs /var/www/localhost/htdocs/user&lt;br /&gt;
&lt;br /&gt;
===Generating the Server.pem===&lt;br /&gt;
For other services we are also going to be using ssl. An easy way to just start using it is generating your own self sign cert. Script and Configuration file taken from setup-webconf script on Alpine.&lt;br /&gt;
&lt;br /&gt;
ssl.cnf&lt;br /&gt;
 [ req ]&lt;br /&gt;
 default_bits = 1024&lt;br /&gt;
 encrypt_key = yes&lt;br /&gt;
 distinguished_name = req_dn&lt;br /&gt;
 x509_extensions = cert_type&lt;br /&gt;
 prompt = no&lt;br /&gt;
 [ req_dn ]&lt;br /&gt;
 OU=HTTPS server&lt;br /&gt;
 CN=example.net&lt;br /&gt;
 emailAddress=postmaster@example.net&lt;br /&gt;
 [ cert_type ]&lt;br /&gt;
 nsCertType = server&lt;br /&gt;
&lt;br /&gt;
ssl.sh&lt;br /&gt;
 #/bin/sh&lt;br /&gt;
 openssl genrsa 512/1024 &amp;gt;server.pem&lt;br /&gt;
 openssl req -new -key server.pem -days 365 -out request.pem&lt;br /&gt;
 openssl genrsa 2048 &amp;gt; keyfile.pem&lt;br /&gt;
 openssl req -new -x509 -nodes -sha1 -days 3650 -key keyfile.pem \&lt;br /&gt;
 -config ssl.cnf &amp;gt; server.pem&lt;br /&gt;
 cat keyfile.pem &amp;gt;&amp;gt; server.pem&lt;br /&gt;
&lt;br /&gt;
If you use this to generate the ssl certs for other services you may just change the req_dn information.&lt;br /&gt;
&lt;br /&gt;
==Mail Services==&lt;br /&gt;
&lt;br /&gt;
Some of the information presented can be found here also. This though is for a email gateway.&lt;br /&gt;
[[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 apk add postfix dovecot clamav clamsmtpd gross&lt;br /&gt;
&lt;br /&gt;
===Postfix===&lt;br /&gt;
Postfix has a few things that need to be added to its configuration so that it can send email through clamav and also so it will accept mail for domains and users.&lt;br /&gt;
&lt;br /&gt;
====Main.cf====&lt;br /&gt;
vi /etc/postfix/main.cf&lt;br /&gt;
 #/etc/postfix/main.cf&lt;br /&gt;
 myhostname = mx.example.net&lt;br /&gt;
 mydomain = example.net&lt;br /&gt;
 relayhost = #blank will do dns lookups for destinations&lt;br /&gt;
 home_maildir = Maildir/&lt;br /&gt;
 smtpd_banner = $myhostname ESMTP #The way postfix answers. &lt;br /&gt;
 transport_maps = hash:/etc/postfix/transport #Place to add how you want to route domains. See example below. Show how to host more than one domain.&lt;br /&gt;
 local_transport = virtual&lt;br /&gt;
 virtual_mailbox_domains = example.net, bobo.net #list of hosted domains&lt;br /&gt;
 virtual_mailbox_base = /var/spool/vhosts&lt;br /&gt;
 virtual_uid_maps = static:1004 # uid of user to be used to read/write mail  &lt;br /&gt;
 virtual_gid_maps = static:1004 # gid of user to be used to read/write mail &lt;br /&gt;
 virtual_alias_maps = hash:/etc/postfix/valias #alias for each different hosted domain. See below.&lt;br /&gt;
 virtual_mailbox_maps = hash:/etc/postfix/vmap #where and what mailbox to drop the mail to. See below.&lt;br /&gt;
 smtpd_helo_required = yes&lt;br /&gt;
 disable_vrfy_command = yes&lt;br /&gt;
 content_filter = scan:[127.0.0.1]:10025 # clamscan to be configured later&lt;br /&gt;
 smtpd_recipient_restrictions = reject_unauth_pipelining, permit_sasl_authenticated,permit_mynetworks,reject_invalid_hostname, reject_non_fqdn_hostname,reject_non_fqdn_sender, reject_non_fqdn_recipient,reject_unknown_sender_domain, reject_unknown_recipient_domain,reject_unauth_destination, check_policy_service inet:127.0.0.1:5525,permit&lt;br /&gt;
 smtpd_data_restrictions = reject_unauth_pipelining, permit&lt;br /&gt;
 smtpd_sasl_auth_enable = yes&lt;br /&gt;
 broken_sasl_auth_clients = yes&lt;br /&gt;
 smtpd_sasl_type = dovecot&lt;br /&gt;
 smtpd_sasl_path = private/auth&lt;br /&gt;
 smtpd_tls_cert_file = /etc/ssl/postfix/server.pem&lt;br /&gt;
 smtpd_tls_key_file = $smtpd_tls_cert_file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Master.cf====&lt;br /&gt;
Settings in the master.cf for virus/spam scanning. Add these to the end of the file. Similar to those found [[Protecting your email server with Alpine]].&lt;br /&gt;
&lt;br /&gt;
 scan    unix    -       -       n       -       16      smtp&lt;br /&gt;
        -o smtp_send_xforward_command=yes&lt;br /&gt;
        -o smtp_enforce_tsl=no&lt;br /&gt;
 127.0.0.1:10026 inet    n       -       n       -       16      smtpd&lt;br /&gt;
        -o content_filter=&lt;br /&gt;
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks&lt;br /&gt;
        -o smtpd_helo_restrictions=&lt;br /&gt;
        -o smtpd_client_restrictions=&lt;br /&gt;
        -o smtpd_sender_restrictions=&lt;br /&gt;
        -o smtpd_recipient_restrictions=permit_mynetworks,reject&lt;br /&gt;
        -o mynetworks_style=host&lt;br /&gt;
        -o smtpd_authorized_xforward_host=127.0.0.1/8&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Valias==== &lt;br /&gt;
 #etc/postfix/valias&lt;br /&gt;
 postmaster@example.net user1@example.net&lt;br /&gt;
 hostmaster@example.net user2@example.net&lt;br /&gt;
 hostmaster@bobo.net    user1@example.net&lt;br /&gt;
 postmaster@bobo.net    user2@bobo.net&lt;br /&gt;
&lt;br /&gt;
====Vmap====&lt;br /&gt;
 #/etc/postfix/vmap&lt;br /&gt;
 user1@example.net      example.net/user1&lt;br /&gt;
 user2@example.net      example.net/user2&lt;br /&gt;
 @example.net           example.net/catchall #everyone else doesn&#039;t match rule above&lt;br /&gt;
&lt;br /&gt;
====Transport====&lt;br /&gt;
 #/etc/postfix/transport&lt;br /&gt;
 example.net      virtual:&lt;br /&gt;
 bobo.net         virtual:&lt;br /&gt;
 foo.net          smtp:1.2.3.4 #send foo.net through this smtp server&lt;br /&gt;
 *                :   #everything else go through relayhost rule&lt;br /&gt;
&lt;br /&gt;
Once these files are created you will need to make them into .db files&lt;br /&gt;
 postmap valias&lt;br /&gt;
 postmap transport&lt;br /&gt;
 postmap vmap&lt;br /&gt;
&lt;br /&gt;
===Dovecot===&lt;br /&gt;
Dovecot on Alpine will only do imap and imaps services for now. &lt;br /&gt;
&lt;br /&gt;
Most of dovecot is configured already for imap. You may have to gen the key as shown above. Just change the cnf file a little to say something about mail.domainname. &lt;br /&gt;
 &lt;br /&gt;
 ssl_cert_file = /etc/ssl/dovecot/server.pem&lt;br /&gt;
 ssl_key_file = /etc/ssl/dovecot/keyfile.pem&lt;br /&gt;
 mail_location = maildir:/var/spool/vhosts/&amp;amp;d/%n&lt;br /&gt;
 valid_chroot_dirs = /var/spool/vhosts&lt;br /&gt;
 passdb passwd-file {&lt;br /&gt;
 args = /etc/dovecot/passwd&lt;br /&gt;
 }&lt;br /&gt;
 userdb passwd-file {&lt;br /&gt;
 args = /etc/dovecot/users&lt;br /&gt;
 }&lt;br /&gt;
 #section for postfix sasl auth&lt;br /&gt;
 socket listen {&lt;br /&gt;
 client {&lt;br /&gt;
 path = /var/spool/postfix/private/auth&lt;br /&gt;
 user = postfix&lt;br /&gt;
 group = postfix &lt;br /&gt;
 mode = 0660&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
To generate the passwords you can use the dovecotpw command.&lt;br /&gt;
 dovecotpw -s MD5-CRYPT &lt;br /&gt;
&lt;br /&gt;
The hash below can be used for the password test123&lt;br /&gt;
&lt;br /&gt;
The /etc/dovecot/passwd file should look like this:&lt;br /&gt;
 user1@example.net:$1$tz5sbjAD$Wq9.NkSyNo/oElzFgI68.0&lt;br /&gt;
 user2@example.net:$1$tz5sbjAD$Wq9.NkSyNo/oElzFgI68.0&lt;br /&gt;
&lt;br /&gt;
THe /etc/dovecot/userdb file should look like this:&lt;br /&gt;
 user1@example.net::1004:1004::/var/spool/vhosts/example.net/:/bin/false::&lt;br /&gt;
 user2@example.net::1004:1004::/var/spool/vhosts/example.net/:/bin/false::&lt;br /&gt;
 user@domain::uid : gid of found in virtual_uid_maps::location of maildir:shell::&lt;br /&gt;
&lt;br /&gt;
===Clamsmtpd===&lt;br /&gt;
Configure according to instructions [[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
===Gross===&lt;br /&gt;
Configure according to instructions [[Protecting your email server with Alpine]]&lt;br /&gt;
&lt;br /&gt;
===Final Steps ===&lt;br /&gt;
Start the services and make sure to rc-update them&lt;br /&gt;
 rc-service postfix start&lt;br /&gt;
 rc-update add postfix default&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Mail]]&lt;/div&gt;</summary>
		<author><name>Chocolatine31</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=MariaDB&amp;diff=30764</id>
		<title>MariaDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=MariaDB&amp;diff=30764"/>
		<updated>2025-08-20T22:04:52Z</updated>

		<summary type="html">&lt;p&gt;Chocolatine31: Updated names from mysql-named scripts to mariadb-named scripts, since the former will be deprecated in the future.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://mariadb.org/ MariaDB] is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. It is notable for being led by the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The Alpine Linux repositories no longer include the actual MySQL binaries, installing the &amp;lt;code&amp;gt;mysql-*&amp;lt;/code&amp;gt; packages will instead install MariaDB. &lt;br /&gt;
&lt;br /&gt;
Installing &amp;lt;code&amp;gt;mariadb&amp;lt;/code&amp;gt; will create the user &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt;. When the database is initialized, two users will be added to the database: &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt;. By default these users will only be accessible if you are logged in as the corresponding system user.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add {{pkg|mariadb|arch=}} {{pkg|mariadb-client|arch=}}}}&lt;br /&gt;
&lt;br /&gt;
Installing the above packages will add the main components of MariaDB to the system: &amp;lt;code&amp;gt;mariadb-cient&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mariadb-server&amp;lt;/code&amp;gt;. Other available packages are described in the table below, and are listed in order of relevance for a production server.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MySQL name package !! Since Alpine: !! Brief usage !! Related package&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mysql}} || v2 || a transitional package that installs mariadb || mariadb&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mysql-client}} || v2 || a transitional package that installs the mariadb client tools || mariadb-client&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb}} || v2 || server equivalent to mysql-server || mariadb-common&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-client}} || v2 || connection command line and tools || mariadb-common&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-doc}} || v3.0 || manpages for mariadb || man man-pages&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-connector-odbc}} || edge || coding or making OS level connections, to any DB without libs install || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-connector-c}} || v3.8 || coding connection on C sources || mariadb-connector-c-dev&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-backup}} || v3.8 || tool for physical online backups, no longer widely used || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-server-utils}} || v3.8 || server commands not widely used, in past was inside MariaDB package || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-dev}} || v3.1 || development files for MariaDB || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-test}} || v3.3 || testing suite from MariaDB tools || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-mytop}} || v3.9 || data performance monitoring || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-plugin-rocksdb}} || v3.9 || plain key-value event relational for data || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-static}} || v3.8 || static libs for static non depends linking in builds || .&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-embedded}} || v3.9 || the libmysqld identical interface as the C client || mariadb-embedded-dev&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-embedded-dev}} || v3.9 ||  use the normal mysql.h and link with libmysqld instead of libmysqlclient || mariadb-dev&lt;br /&gt;
|-&lt;br /&gt;
| {{Pkg|mariadb-openrc}} || v3.8 || separate scripts, in past was embebed on server package || .&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Initialization ==&lt;br /&gt;
&lt;br /&gt;
The version of MariaDB in the Alpine repositories behave like the MySQL tarball. No graphical tools are included.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;datadir&#039;&#039; located at {{Path|/var/lib/mysql}} must be owned by the mysql user and group. The location of the &#039;&#039;datadir&#039;&#039; can be changed by editing the &amp;lt;code&amp;gt;mariadb&amp;lt;/code&amp;gt; service file in {{Path|/etc/init.d}}. The new location will also need to be set by adding &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;datadir=&amp;lt;YOUR_DATADIR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;[mysqld]&amp;lt;/code&amp;gt; section in a mariadb configuration file.&lt;br /&gt;
&lt;br /&gt;
Normal initialization of mariadb can be done as follows:&lt;br /&gt;
&lt;br /&gt;
# Initialize MySQL Data Directory. &amp;lt;code&amp;gt;mariadb-install-db --user=mysql --datadir=/var/lib/mysql&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start the main service. At this point there will be no root password set. &amp;lt;code&amp;gt;rc-service mariadb start&amp;lt;/code&amp;gt;&lt;br /&gt;
# Secure the database by running &amp;lt;code&amp;gt;mariadb-secure-installation&amp;lt;/code&amp;gt;&lt;br /&gt;
# Setup permissions for managing others users and databases see: &#039;&#039;&#039;[[#Configuration|Configuration]]&#039;&#039;&#039;&lt;br /&gt;
# Add MariaDb to OpenRC. &amp;lt;code&amp;gt;rc-update add mariadb default&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
In order to help with the basic configuration of the database engine, MariaDB provides [https://mariadb.com/kb/en/mariadb-secure-installation/ mariadb-secure-installation]. &lt;br /&gt;
&lt;br /&gt;
Many of the reasons for running this script are no longer necessary, since MariaDB has defaulted to Unix socket authentication since MariaDB 10.4.&lt;br /&gt;
&lt;br /&gt;
This script walks you through the basics of securing the database. The options are explained below.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Enter current password for root (enter for none):&#039;&#039;&#039; If you have previously set up a root password, provide it here and press enter. If not, just press enter.&lt;br /&gt;
#  &#039;&#039;&#039;Switch to unix_socket authentication [Y/n]&#039;&#039;&#039; Setting the root password or using the Unix_socket ensures that only admins can log into engine database. For non-production servers just press &amp;quot;n&amp;quot; to setup a root password, which will give you the response &amp;lt;code&amp;gt;... skipping.&amp;lt;/code&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Change the root password? [Y/n]&#039;&#039;&#039; Here you can change the root password, or set one if needed. Press &amp;quot;Y&amp;quot; and enter the new password.&lt;br /&gt;
# &#039;&#039;&#039;Remove anonymous users? [Y/n]&#039;&#039;&#039; Remove anonymous users created to log in using socket authentication. Unless you&#039;re sure you need this, answer &amp;quot;Y&amp;quot; to remove them.&lt;br /&gt;
# &#039;&#039;&#039;Disallow root login remotely? [Y/n]&#039;&#039;&#039; Normally, root should only be allowed to connect from &#039;localhost&#039; in order to protect from password sniffing attempts over the network. Answer &amp;quot;Y&amp;quot;.&lt;br /&gt;
# &#039;&#039;&#039;Remove test database and access to it? [Y/n]&#039;&#039;&#039; By default, MariaDB comes with a database named &#039;test&#039; that anyone can access. If this is not needed, answer &amp;quot;Y&amp;quot;.&lt;br /&gt;
# &#039;&#039;&#039;Reload privilege tables now? [Y/n]&#039;&#039;&#039; Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Answer &amp;quot;Y&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
After the script exits, restart the service with &amp;lt;code&amp;gt;rc-service mariadb restart&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To start the database daemon on every boot, run &amp;lt;code&amp;gt;rc-update add mariadb default&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuration files and customization ===&lt;br /&gt;
&lt;br /&gt;
Rather than being stored in {{Path|my.cnf}}, configuration settings for MariaDB are now organized in separate files. The primary configuration is done by adding files to {{Path|/etc/my.cnf.d/}}. User-specific configuration files are stored in {{Path|~/.my.cnf}}. User-specific configuration files are loaded after the system-wide configuration. The locations of the various configuration files are listed below.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Config file !! Versions of Alpine !! Contents to configure&lt;br /&gt;
|-&lt;br /&gt;
| {{Path|/etc/mysql/my.cnf}} || v2 to v3.8 || All the directives, global config file&lt;br /&gt;
|-&lt;br /&gt;
| {{Path|/etc/my.cnf.d/mariadb-server.cnf}} || since 3.9 || First global config file, main directives&lt;br /&gt;
|-&lt;br /&gt;
| {{path|$HOME/.my.cnf}} || all || user name only config directives&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As previously mentioned, this page describes basic usage of MariaDB. For professional usage, [[MySQL]] should also be referenced.&lt;br /&gt;
&lt;br /&gt;
* The following command will configure the server to accept all incoming connections. This should only be done for development, or if the database is not exposed to the Internet or a sensitive network.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|.*bind-address\s*=.*|bind-address=0.0.0.0|g&amp;quot; /etc/mysql/my.cnf&lt;br /&gt;
sed -i &amp;quot;s|.*bind-address\s*=.*|bind-address=0.0.0.0|g&amp;quot; /etc/my.cnf.d/mariadb-server.cnf&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
* For simple installations, disabling hostname search can improve performance, but is only useful for local servers.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|.*skip-networking.*|skip-networking|g&amp;quot; /etc/mysql/my.cnf&lt;br /&gt;
sed -i &amp;quot;s|.*skip-networking.*|skip-networking|g&amp;quot; /etc/my.cnf.d/mariadb-server.cnf&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Updating or coming from upgrading ==&lt;br /&gt;
&lt;br /&gt;
When upgrading between Alpine Linux releases, MariaDB may also have a major version change, and the databases should be upgraded to match. The recommended steps in this process are detailed below.&lt;br /&gt;
&lt;br /&gt;
# While it may no longer be strictly necessary, it&#039;s useful to backup your databases before upgrading the database version.&lt;br /&gt;
# Update Alpine Linux and the MariaDB/MySQL packages.&lt;br /&gt;
# Install mariadb-server-utils by running &amp;lt;code&amp;gt;apk add {{pkg|mariadb-server-utils|arch=}}&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Run &amp;lt;code&amp;gt;mysql_upgrade -u root -p&amp;lt;/code&amp;gt; script, and provide the password for the root database user.&lt;br /&gt;
# Restart the service by running &amp;lt;code&amp;gt;rc-service mariadb restart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;mysql_upgrade&amp;lt;/code&amp;gt; fails because MySQL cannot start, try running MySQL in safemode with &amp;lt;code&amp;gt;mysqld_safe --datadir=/var/lib/mysql/&amp;lt;/code&amp;gt;, and then run &amp;lt;code&amp;gt;mysql_upgrade -u root -p&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
= Create a user =&lt;br /&gt;
You may want to create a user with remote access to the database.&lt;br /&gt;
&lt;br /&gt;
Open mariadb Client: &amp;lt;code&amp;gt;mariadb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add the user with associated host and password: &amp;lt;code&amp;gt; CREATE OR REPLACE USER admin@&#039;%&#039; IDENTIFIED BY &#039;ASecurePassword&#039;;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;NB: @&#039;%&#039; allow connection from any host&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This is insufficient to allow remote access. See [https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/ Configuring MariaDB for Remote Client Access].&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Database]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Production]]&lt;/div&gt;</summary>
		<author><name>Chocolatine31</name></author>
	</entry>
</feed>