| Size: 3177 Comment:  | Size: 5168 Comment:  | 
| Deletions are marked like this. | Additions are marked like this. | 
| Line 57: | Line 57: | 
| * VM settings, network, adapter 1, NAT, port forwarding, add rule, protocol tcp, host port 2222, guest port 22 | * 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 | 
| Line 97: | Line 99: | 
| server "default"{ | server "localhost"{ | 
| Line 99: | Line 101: | 
| root "/htdocs/localhost" | |
| Line 101: | Line 105: | 
| * In the configuration file root points to /var/www * The logs are in /var/ww/logs | |
| Line 104: | Line 109: | 
| * pkg_info -Q wget * pkg_add wget-1.20.2 * wget http://localhost/ * mkdir -p /var/www/htdocs/localhost * echo -e "<html><body>Hello</body></html>" > /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 {{{#!highlight c #include "fcgi_stdio.h" #include <stdlib.h> void main(void) { int count = 0; while(FCGI_Accept() >= 0) printf("Content-type: text/html\r\n" "\r\n" "<title>FastCGI Hello!</title>" "<h1>FastCGI Hello!</h1>" "Request number %d running on host <i>%s</i>\n", ++count, getenv("SERVER_NAME")); } }}} 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 }}} | 
OpenBSD
The OpenBSD project produces a FREE, multi-platform 4.4BSD-based UNIX-like operating system. http://www.openbsd.org
- 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 
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
 
   1 df -h 
   2 startx # fvwm window manager 
   3 setxkbmap pt
   4 # default shell ksh 
   5 perl -v # 5.20 
   6 du -hs .
   7 
   8 #edit /root/.profile
   9 PKG_PATH=http://ftp.fr.openbsd.org/pub/OpenBSD/6.0/packages/amd64/
  10 export PKG_PATH
  11 exit
  12 login 
  13 env 
  14 pkg_info python
  15 pkg_add python-2.7.12 # pkg_add python-2.7.16 
  16 pkg_info -Q jdk
  17 pkg_add jdk-1.8.0.72p0v0 # pkg_add jdk-11.0.2.9.3p0v0
  18 # You may wish to add /usr/local/jdk-11/man to /etc/man.conf
  19 cd /usr/local/jdk-1.8.0/bin # cd /usr/local/jdk-11/bin
  20 ./java -version 
  21 python2.7 --version 
  22 pkg_info #list installed packages 
  23 #https://www.openbsd.org/faq/faq15.html#PkgMgmt
  24 
  25 #install ntpd
  26 pkg_add ntp
  27 ntpdate pt.pool.ntp.org #update datetime
  28 
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
- /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 "<html><body>Hello</body></html>" > /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 
   1 #include "fcgi_stdio.h"
   2 #include <stdlib.h>
   3 
   4 void main(void)
   5 {
   6     int count = 0;
   7     while(FCGI_Accept() >= 0)
   8         printf("Content-type: text/html\r\n"
   9               "\r\n"
  10               "<title>FastCGI Hello!</title>"
  11               "<h1>FastCGI Hello!</h1>"
  12               "Request number %d running on host <i>%s</i>\n",
  13                 ++count, getenv("SERVER_NAME"));
  14 }
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
Custom service
/usr/local/sbin/beat.py
   1 #!/usr/bin/python
   2 import threading
   3 import time
   4 import os
   5 import syslog
   6 import datetime
   7 import sys 
   8 import signal
   9 
  10 def termHandler(signal,frame):
  11     print('Signal term caught')
  12     sys.exit(0)
  13     
  14 if __name__=="__main__":
  15     f=open('/var/run/beat.pid','wa')
  16     f.write('%d'%(os.getpid()))
  17     f.close()
  18     signal.signal(signal.SIGTERM,termHandler)    
  19     
  20     while True:
  21         syslog.syslog(syslog.LOG_INFO, "Beat %s"%(datetime.datetime.now()) )
  22         time.sleep(5)
/etc/rc.d/beat
daemon="/usr/local/bin/python2.7 /usr/local/sbin/beat.py" rc_bg=YES . /etc/rc.d/rc.subr rc_cmd $1
- /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=
