{"id":3443,"date":"2023-03-05T15:23:39","date_gmt":"2023-03-05T20:23:39","guid":{"rendered":"https:\/\/dft.wiki\/?p=3443"},"modified":"2026-06-08T16:56:35","modified_gmt":"2026-06-08T20:56:35","slug":"alpine-cheat-sheet","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=3443","title":{"rendered":"Alpine Cheat Sheet"},"content":{"rendered":"<p><strong>Alpine Linux<\/strong> is a powerful, ultra-lightweight distro popular for microservices such as Kubernetes and Docker.<\/p>\n<p>It contains only the bare minimum to work. What you mostly need to know is its package manager (APK) and init system (OpenRC).<\/p>\n<p>Most basic commands:<\/p>\n<pre>apk update &amp;&amp; apk upgrade\r\napk info\r\napk update\r\napk upgrade\r\napk search nano\r\napk add nano\r\napk del nano\r\napk add --no-cache aws-cli\r\napk add mysql-client\r\napk add openssh-server\r\nrc-service sshd start\r\nrc-service sshd restart\r\nrc-service sshd status\r\nrc-update add sshd\r\nrc-update -v show\r\nnetstat -tulpn\r\nreboot\r\nhalt<\/pre>\n<p>The following tips work well on Alpine v3.17.<\/p>\n<p><strong>NGINX + PHP8<\/strong><\/p>\n<pre>apk add nginx php php-fpm php-opcache php-gd php-mysqli php-zlib php-curl\r\nphp -v\r\nnginx -v\r\nrc-update add nginx default\r\nrc-update add php-fpm81 default\r\nnano \/etc\/nginx\/http.d\/default.conf<\/pre>\n<pre>server {\r\n        listen 80 default_server;\r\n        listen [::]:80 default_server;\r\n\r\n        root    <strong>\/var\/www\/default<\/strong>;\r\n\r\n        index   index.html index.htm <strong>index.php;\r\n\r\n        location ~ \\.php$ {\r\n                fastcgi_pass      127.0.0.1:9000;\r\n                fastcgi_index     index.php;\r\n                include           fastcgi.conf;\r\n        }<\/strong>\r\n}<\/pre>\n<pre>service php-fpm81 restart\r\nservice nginx restart\r\necho \"&lt;?php echo 'PHP works!'; ?&gt;\" &gt; \/var\/www\/default\/index.php\r\nchown nginx: -R \/var\/www\/*<\/pre>\n<p><strong>CLOUDFLARE TUNNEL<\/strong><\/p>\n<p>For <strong>AMD<\/strong>:<\/p>\n<pre>curl -L https:\/\/github.com\/cloudflare\/cloudflared\/releases\/latest\/download\/cloudflared-linux-<strong>amd<\/strong>64 -o \/usr\/bin\/cloudflared<\/pre>\n<p>For <strong>ARM<\/strong>:<\/p>\n<pre>curl -L https:\/\/github.com\/cloudflare\/cloudflared\/releases\/latest\/download\/cloudflared-linux-<strong>arm<\/strong>64 -o \/usr\/bin\/cloudflared<\/pre>\n<p>Then:<\/p>\n<pre>cloudflared service install ****************\r\nservice cloudflared start\r\nrc-update add cloudflared default<\/pre>\n<p>To uninstall:<\/p>\n<pre>cloudflared service uninstall<\/pre>\n<p><strong>EXECUTING COMMANDS AFTER BOOT<\/strong><\/p>\n<pre>nano \/etc\/local.d\/rc.local.start<\/pre>\n<pre>#!\/bin\/sh\r\necho \"execute this after boot\"\r\nexit 0<\/pre>\n<pre>chmod +x \/etc\/local.d\/rc.local.start\r\nrc-update add local<\/pre>\n<p><strong>INSTALL MYSQL (MARIADB)<\/strong><\/p>\n<pre>apk add mysql mysql-client\r\n\/etc\/init.d\/mariadb setup\r\n\/etc\/init.d\/mariadb start\r\nmysql_secure_installation\r\nrc-update add mariadb default<\/pre>\n<p><strong>MSMTP WITH GMAIL + PHP CONFIG<\/strong><\/p>\n<pre>apk add msmtp\r\nnano \/etc\/msmtprc<\/pre>\n<pre>defaults\r\nauth on\r\ntls on\r\ntls_trust_file \/etc\/ssl\/certs\/ca-certificates.crt\r\nlogfile ~\/.msmtp.log\r\naccount gmail\r\nhost smtp.gmail.com\r\nport 587\r\nfrom &lt;USERNAME&gt;@gmail.com\r\nuser &lt;USERNAME&gt;@gmail.com\r\npassword &lt;PASSWORD&gt;\r\naccount default : gmail<\/pre>\n<pre>nano \/etc\/php81\/php.ini<\/pre>\n<pre>...\r\n;SMTP = localhost\r\n;smtp_port = 25\r\nsendmail_path = \"\/usr\/bin\/msmtp -t\"\r\n...<\/pre>\n<p><strong>OPENVPN SERVER IN LXC<\/strong><\/p>\n<p>On the Proxmox host (if applicable):<\/p>\n<pre>modprobe tun\r\nchown 100000:100000 \/dev\/net\/tun\r\nnano \/etc\/pve\/lxc\/<strong>100<\/strong>.conf<\/pre>\n<p>The CT number is 100 in this example. Append the following lines:<\/p>\n<pre>lxc.cgroup2.devices.allow: c 10:200 rwm\r\nlxc.mount.entry: \/dev\/net dev\/net none bind,create=dir<\/pre>\n<p>On the guest CT:<\/p>\n<pre>apk add openvpn\r\nrc-update add openvpn default<\/pre>\n<p><strong>CRONTAB<\/strong><\/p>\n<p>Install, start, and enable on boot:<\/p>\n<pre>apk add cronie\r\nrc-service cronie start\r\nrc-update add cronie<\/pre>\n<p>Edit the crontab file:<\/p>\n<pre>\/etc\/crontabs\/root<\/pre>\n<p>Force a reload by creating the following file:<\/p>\n<pre>touch \/etc\/crontabs\/cron.update<\/pre>\n<p>Confirm the file has been automatically deleted (this confirms cron reloaded its table):<\/p>\n<pre>ls -la \/etc\/crontabs\/cron.update<\/pre>\n<p>Show the list of loaded cronjobs:<\/p>\n<pre>crontab -l<\/pre>\n<p>You can also add scripts to one of the following directories based on how often they should run:<\/p>\n<ul>\n<li>\/etc\/periodic\/\n<ul>\n<li>15min\/<\/li>\n<li>daily\/<\/li>\n<li>hourly\/<\/li>\n<li>monthly\/<\/li>\n<li>weekly\/<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Scripts must have no extension (e.g. <code>\/etc\/periodic\/monthly\/backup<\/code>). See template:<\/p>\n<pre>#!\/bin\/sh\r\necho `date`\r\n# BACKUP COMMANDS\r\nexit 0<\/pre>\n<p>Remember to mark the file as executable:<\/p>\n<pre>chmod +x \/etc\/periodic\/monthly\/backup<\/pre>\n<p><strong>Note:<\/strong> the first line of the script must be <code>#!\/bin\/sh<\/code> and the filename must <strong>NOT<\/strong> contain a period (<code>.<\/code>).<\/p>\n<p><strong>SETTING TIMEZONE<\/strong><\/p>\n<pre>apk add tzdata\r\ncp \/usr\/share\/zoneinfo\/America\/Toronto \/etc\/localtime\r\ndate<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Alpine Linux is a powerful, ultra-lightweight distro popular for microservices such as Kubernetes and Docker. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-3443","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3443"}],"version-history":[{"count":18,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3443\/revisions"}],"predecessor-version":[{"id":5647,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3443\/revisions\/5647"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}