= OpenBSD = The OpenBSD project produces a FREE, multi-platform 4.4BSD-based UNIX-like operating system. {{attachment:slackers.jpg}} * http://www.openbsd.org * https://www.openbsd.org/art2.html {{{#!highlight sh wget http://ftp.fr.openbsd.org/pub/OpenBSD/6.0/amd64/install60.iso wget https://cdn.openbsd.org/pub/OpenBSD/6.5/amd64/install65.iso wget https://cdn.openbsd.org/pub/OpenBSD/7.3/amd64/install73.iso }}} == VirtualBox installation == * new * name: OpenBSD6 * type: bsd * version: openbsd 64 bit * next * 512 MB * next * create disk * create * vdi * next * fixed size * next * 8GB * Create * Settings * Network card Intel PRO/1000 MT Desktop * Start * install60.iso * Start * (I)nstall * ? choose keyboard * pt * System hostname: openbsd * card: em0 * IP v4 address: dhcp * IP v6: none * done * password for root: ******* * start sshd yes * expect X11 yes * X11 started by xdm: no * setup a user: vitor * Password for vitor ******** * Allow root ssh login no * root disk wd0 * use whole disk * Auto layout * set location cd0 * pathname 6.0/amd64 * all * done * continue without verification yes * done * Timezone Portugal # Europe/Lisbon * yes * reboot * Unmount ISO * Login as vitor * VM settings, network, adapter 1, NAT, port forwarding, * add rule, protocol tcp, host port 2222, guest port 22 * add rule, protocol tcp, host port 8080, guest port 80 {{{#!highlight bash df -h startx # fvwm window manager setxkbmap pt # default shell ksh perl -v # 5.20 du -hs . #edit /root/.profile PKG_PATH=http://ftp.fr.openbsd.org/pub/OpenBSD/6.0/packages/amd64/ export PKG_PATH exit login env pkg_info python pkg_add python-2.7.12 # pkg_add python-2.7.16 pkg_info -Q jdk pkg_add jdk-1.8.0.72p0v0 # pkg_add jdk-11.0.2.9.3p0v0 # You may wish to add /usr/local/jdk-11/man to /etc/man.conf cd /usr/local/jdk-1.8.0/bin # cd /usr/local/jdk-11/bin ./java -version python2.7 --version pkg_info #list installed packages #https://www.openbsd.org/faq/faq15.html#PkgMgmt #install ntpd pkg_add ntp ntpdate pt.pool.ntp.org #update datetime }}} == httpd service == In '''/etc/rc.conf ''' remove the value NO for httpd_flags {{{ httpd_flags= }}} In '''/etc/httpd.conf''' {{{ server "localhost"{ listen on 0.0.0.0 port 80 root "/htdocs/localhost" } }}} * In the configuration file root points to /var/www * The logs are in /var/ww/logs {{{#!highlight sh /etc/rc.d/httpd start /etc/rc.d/httpd check pkg_info -Q wget pkg_add wget-1.20.2 wget http://localhost/ mkdir -p /var/www/htdocs/localhost echo -e "Hello" > /var/www/htdocs/localhost/index.html /etc/rc.d/httpd restart pkg_add fcgi-2.4.0p16 pkg_add spawn-fcgi-1.6.3p0 # https://web.archive.org/web/20160122022029/http://www.fastcgi.com/drupal/node/6?q=node/21 }}} === fcgi.c === {{{#!highlight c #include "fcgi_stdio.h" #include void main(void) { int count = 0; while(FCGI_Accept() >= 0) printf("Content-type: text/html\r\n" "\r\n" "FastCGI Hello!" "

FastCGI Hello!

" "Request number %d running on host %s\n", ++count, getenv("SERVER_NAME")); } }}} {{{#!highlight sh cd /var/www/htdocs/localhost cc fcgi.c -o fcgi -lfcgi -I /usr/local/include -L /usr/local/lib mkdir -p /var/www/usr/bin mkdir -p /var/www/usr/lib mkdir -p /var/www/usr/libexec cp /usr/lib/libc.so.95.0 /var/www/usr/lib/libc.so.95.0 cp /usr/libexec/ld.so /var/www/usr/libexec/ld.so cp ./usr/local/lib/libfcgi.so.0.0 /var/www/usr/lib mkdir -p /var/www/htdocs/localhost/usr/bin mkdir -p /var/www/htdocs/localhost/usr/lib mkdir -p /var/www/htdocs/localhost/usr/libexec cp /usr/lib/libc.so.95.0 /var/www/htdocs/localhost/usr/lib/libc.so.95.0 cp /usr/libexec/ld.so /var/www/htdocs/localhost/usr/libexec/ld.so cp /usr/local/lib/libfcgi.so.0.0 /var/www/htdocs/localhost/usr/lib pkg_add apache-httpd-2.4.39p1 /etc/rc.d/apache2 start # http://localhost:8080/ pkg_add gtar-1.32 wget http://mirrors.up.pt/pub/apache//httpd/mod_fcgid/mod_fcgid-2.3.9.tar.bz2 bunzip2 mod_fcgid-2.3.9.tar.bz2| tar xvf - tar xvf mod_fcgid-2.3.9.tar cd mod_fcgid-2.3.9 ./configure.apxs make make install # /usr/local/lib/apache2/mod_fcgid.so vi /etc/apache2/httpd2.conf # LoadModule /usr/local/lib/apache2/mod_fcgid.so # Virtual hosts Include /etc/apache2/extra/httpd-vhosts.conf /var/www/htdocs/localhost/cgi-bin fcgi.c fcgi.fcgi /etc/apache2/extra/httpd-vhosts.conf ServerName localhost FcgidInitialEnv name value DocumentRoot "/var/www/htdocs/localhost" ScriptAlias / /var/www/htdocs/localhost/ SetHandler fcgid-script Options +ExecCGI Allow from all # install pip pkg_add py-pip-9.0.3 ln -sf /usr/local/bin/pip2.7 /usr/local/bin/pip pip install flup pkg_add py3-pip-9.0.3 pip3.6 install flup }}} == Custom service == === /usr/local/sbin/beat.py === {{{#!highlight python #!/usr/bin/python import threading import time import os import syslog import datetime import sys import signal def termHandler(signal,frame): print('Signal term caught') sys.exit(0) if __name__=="__main__": f=open('/var/run/beat.pid','wa') f.write('%d'%(os.getpid())) f.close() signal.signal(signal.SIGTERM,termHandler) while True: syslog.syslog(syslog.LOG_INFO, "Beat %s"%(datetime.datetime.now()) ) time.sleep(5) }}} === /etc/rc.d/beat === {{{ #!/bin/sh daemon="/usr/local/bin/python2.7 /usr/local/sbin/beat.py" rc_bg=YES . /etc/rc.d/rc.subr rc_cmd $1 }}} {{{#!highlight sh /etc/rc.d/beat start /etc/rc.d/beat check tail -f /var/log/messages /etc/rc.d/beat stop # add in /etc/rc.conf to start service after boot pkg_scripts=beat beat_flags= }}}