Wednesday, November 06, 2019

6.5 amd64: Modify existing certbot certificates.

Hi,

It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to write another blog post. So, here I am.

My 6.5 server have Let's Encrypt certificate which I have multiple subdomains in it. This OpenBSD system have Nginx which act as a HTTPS reverse proxy to Docker host backend.

[Router] <--https--> [OpenBSD] <--http--> [Docker]

 For this example I'm replacing the subdomains with generic names. First, I check my existing SSL certificate.

$ doas certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: domain.my
    Domains: domain.my www.domain.my 123.domain.my 456.domain.my
    Expiry Date: 2019-12-11 09:35:47+00:00 (VALID: 34 days)
    Certificate Path: /etc/letsencrypt/live/domain.my/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/domain.my/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


Great. I still have a valid certificate. What I'm planning to do is to remove these subdomains:

1) 123.domain.my
2) 456.domain.my

Then add 2 new subdomains:

1) abc.domain.my
2) def.domain.my

As I'm using Nginx to serve the certificate, I stopped my Nginx, preparing for the certificate modification.

$ doas rcctl stop nginx

Then I proceed to request for certificate modification using certbot. Take note the value of the previous "Certificate Name" as it's needed to properly modify existing cert.

$ doas certbot certonly --cert-name domain.my -d domain.my,www.domain.my,abd.domain.my,def.domain.my

After I run the command, the prompt to select the option I can use to authenticate my server. For this one, I opted to spin up temporary standalone webserver (option 1)

Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Plugins selected: Authenticator standalone, Installer None


Next certbot is showing me the changes that will be made. I then choose "U" to update the cert.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You are updating certificate domain.my to include new domain(s):
+ abc.domain.my
+ def.domain.my

You are also removing previously included domain(s):
- 123.domain.my
- 456.domain.my

Did you intend to make this change?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(U)pdate cert/(C)ancel: u

Renewing an existing certificate

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/domain.my/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/domain.my/privkey.pem
   Your cert will expire on 2020-02-04. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le


And it's done! So easy. Take note that I did not use " --expand " on the command.

If you did not include " --cert-name CERT_NAME" in your command, certbot will create another certificate and you might get additional certificate name with "-0001". Such as "domain.my-0001" and you will end up with 2 separate certificate instead.

That's all. Until next post!

Ref: https://certbot.eff.org/docs/using.html#renewing-certificates

Monday, October 09, 2017

6.1 amd64: Python 3 - ebaysdk UnicodeDecodeError.

Hey,

Currently I'm testing Odoo 11, which now have moved from Python 2.7 support to Python > 3.5. For OpenBSD 6.1, the Python is already 3.6 so it should be of no issue.

However, this one particular package is currently uninstallable.

ebaysdk

I tried using pip but I got errors. Take note the "requiremens.txt" only have ebaysdk in it.

$ doas pip install -r requirements.txt
The directory '/home/karl/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that
directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/karl/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directo
ry. If executing pip with sudo, you may want sudo's -H flag.
Collecting ebaysdk==2.1.4 (from -r requirements.txt (line 1))
  Downloading ebaysdk-2.1.4.tar.gz (40kB)
    100% |################################| 51kB 148kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in
      File "/tmp/pip-build-dvars6pw/ebaysdk/setup.py", line 26, in
        open(VERSIONFILE, "rt").read(), re.M).group(1)
      File "/usr/local/lib/python3.6/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dvars6pw/ebaysdk/


All the other dependencies can be installed correctly except for this one. I try setting up the LC_CTYPE, LC_ALL, even LANG and LANGUAGE to en_US.UTF-8 but still unsuccessful.

I'm checking for workaround on this. Later.


Thursday, October 05, 2017

6.1 DL160 Gen9: Bought myself a domain, now to configure Nginx + acme-client.

Hi,

Except the fact that the server's Smart Array Battery failing, my ProLiant DL160 Gen9 is doing great. I've long changed to running ESXi 6.0 and now it's VMware ESXi 6.5. Last time I wrote that I'm using XenServer but it's just a brief encounter. Having to install additional program for a web management feature is one of the negative point for me. So that's why I went back to VMware ESXi. Been learning a lot from this machine so I'm very excited and grateful.

What else is new? Ah. Got a very crazy deal for a domain registration which is buy 2 years and get 2 more years free for RM160! So I went for it and bought meself a domain. I should've bought more but I have no more budget. And before that I registered for a bargain 10Mbps Unifi plan for RM129/mth. Oh yeah and I moved to a new place.

As now I have my internet line at home, I can properly play around with the server and OpenBSD. My plan is to bring up my Odoo web online and *finally* start my small business.

So far, I have 2 OpenBSD vm. 1 vm is basically serving the local DNS (in progress), web (using Nginx), PostgreSQL, Fossil SCM and the other vm is doing nothing important (yet). In details:

serv1.mydomain.my (also known as www.mydomain.my):
- Unbound (not done).
- Nginx (serving Odoo through reverse proxy, Fossil SCM through SCGI, proxy pass to ESXi all in HTTPS).
- PostgreSQL.
- acme-client for SSL Certs (This particular post).

I learned acme-client quite a hard way. I configured the acme-client related files (/etc/acme-client.conf & /etc/nginx/nginx.conf) but every time I run the "acme-client -vAD mydomain.my" I received errors:

# acme-client: bad exit: netproc(xxxx): 1

Thinking that I can do trial/error as much as I wanted, I kept reconfiguring the files until I reached the limit of registration tries. Is it then that I read about it at https://letsencrypt.org/docs/rate-limits/. Then I read about the "Staging" function (acme-client --staging) which I tried but not in the installed version in OpenBSD. I checked the /etc/acme-client.conf and found the staging block. So I altered it as:

===== /etc/acme-client.conf =====
#authority letsencrypt {
#    *snipped
#}

#authority letsencrypt-staging {
authority letsencrypt {
    agreement url "bla bla
    bla bla bla
    account key "bla bla
}
===== /etc/acme-client.conf =====

Basically I commented the production block and "authority letsencrypt-staging" line. Using the same "acme-client -vAD mydomain.my" now will basically use the Staging URL instead of the production one so the limit is much higher which is useful for testing/debugging. I wish I knew this earlier. Because of the production limit, now I have to wait for a full 7 days before I can try and register again. Ah well, I can do more testing in the mean time.

After much re-configuration / testing cycle, I found that this configuration managed to successfully register my domain. Here's the additional block in /etc/acme-client.conf:

===== /etc/acme-client.conf =====
* snipped

domain mydomain.my {
    alternative names { www.mydomain.my esx.mydomain.my fossil.mydomain.my }
    domain key "/etc/ssl/private/mydomain.my.key"
    domain certificate "/etc/ssl/mydomain.my.crt"
    domain full chain certificate "/etc/ssl/mydomain.my.fullchain.pem"
    sign with letsencrypt
    challengedir "/var/www/acme/.well-known/acme-challenge"
}
===== /etc/acme-client.conf =====

And to compliment the above configuration, here's the /etc/nginx/nginx.conf configuration.

===== /etc/nginx/nginx.conf =====
# Default server
server {
    listen 80;
    server_name mydomain.my www.mydomain.my;

    location ^~ /.well-known/acme-challenge {
        default_type "text/plain";
        root /var/www/acme;
    }

    location / {
        return 307 https://www.mydomain.my$request_uri;
    }
}

# ESXi
server {
    listen 80;
    server_name esx.mydomain,my;

    location ^~ /.well-known/acme-challenge {
        default_type "text/plain";
        root /var/www/acme;
    }

    location / {
        return 307 https://$host$request_uri;
    }
}

server {
    listen 443;
    ssl on;
    ssl_certificate    /etc/ssl/mydomain.my.fullchain.pem;
    ssl_certificate_key    /etc/ssl/private/mydomain.my.key;

    *snipped
}
===== /etc/nginx/nginx.conf =====

Do take note that the "default_type "text/plain";" line is optional. I tried registering without it and it's fine. The "ESX" block is also not completed yet as virtual console have "Failed to connect" error which is for another post. After reconfiguration then I restarted Nginx then run acme-client again.

# rcctl restart nginx
# acme-client -vAD mydomain.my
* snipped
acme-client: /etc/ssl/mydomain.my.crt: created
acme-client: /etc/ssl//mydomain.my.fullchain.pem: created

Noted the the double-slash "//" on the fullchain.pem. Although it seems like something not working, I can still find the fullchain.pem file in /etc/ssl folder. And when I checked the SSL Certificate, the issuer > Common Name (CN) is stated as "Fake LE Intermediate X1" which is as what Let's Encrypt documented.

So far I've done a few test and it's ok. I need to wait until this Sunday (or next Monday) before I can try and register again. Later.

Wednesday, December 14, 2016

-c X200 amd64: New bind-key for cwm.

Hey,

Updated my -CURRENT today and found that my key bindings in cwm no longer working. Done a man cwmrc and found that binding has changed.

Previous ~/.cwmrc
=====
#bind key binding
bind 4-l    lock
=====

Now:
=====
bind-key 4-l    lock
=====


Working now like a charm. cwm rocks!

Saturday, September 17, 2016

Welcoming HPE ProLiant DL160 Gen9 as my another machine.

Hi,

Been quite some time. Been busy with work and all. And this few days I've been busy with new weapons in my IT arsenal.

I've acquired, or more correctly salvaged a HPE ProLiant DL160 Gen9 server. It's from a burnt server room which was destined to be disposed. When I got it, the server fans (3 units) was not working thus it can't boot so the company who owns it doesn't want it in production anymore. There was tar built up inside the server, so I cleaned the fans until I can make it turn so I try to boot it up and it works. The fire doesn't go anywhere near the server, it just heavy smoke was covering the server room. I cleaned the internal a bit more but need to get myself an isopropyl alcohol soon to thoroughly clean the interior.

The first OS I installed to test this system is, well, OpenBSD 6.0 amd64. As I thought, this Generation 9 system is new and there's many devices which prompted "not configured". The Matrox 200eH display has not device driver for it yet. Sorry but I forgot to get the dmesg after bare-metal install.

This DL160 Gen9 configuration is:
1x Intel E5-2623 v3 @ 3.00Ghz (4 cores)
4x 4Gb ECC RAM (I set it up to RAID 5)
4x 1Tb 2.5" SAS Drive
HPE P440 SAS Controller PCIe
1x 550w non-hotswap PSU
HPE 82Q 8Gb 2-Port PCIe Fibre Channel Host Adapter (not installed)

That's what I can remember. So after the brief test of OpenBSD, I installed Windows Server 2012 R2 trial. Figuring that as HPE should have provided all the device drivers needed for Windows (which is true), I might as well use the Hyper-V for OpenBSD, which I did. And didn't quite like it. Partly because I'm not delving deeper on how to configure the Hyper-V. Also that I keep staring at the Win Server 2012 R2 desktop, not knowing on what else to do with it. Yeah sure my company uses it in production, also I set up a few of my company's backup server with it, so I somehow need to learn it but it's not the only virtualization solution.

So I check the server's compatible OS list, got meself 2 candidate.

VMware ESXi vSphere 6.0 Update 2
XenServer 6.5

For ESXi, 6.0 is the latest version. Also HPE provided downloadable custom ISO for it. Nice. I downloaded the goodies and installed the HPE custom ISO version. My verdict:

I'm still new to this vm thingy. My DL160 have 64Gb miniSD included, so ESXi can be installed in it. As I was told that vSphere is free now, so I got meself the Free License Key. Keyed it in, just to feel what the free version can do as I know I can't afford to buy myself the Essentials or more. Installation was easy, post installation's configuration too. Web interface readily available. Then I installed OpenBSD. Didn't manage to get the network to work. Even with HPE custom ISO, which included all the necessary drivers, I somewhat feel the console respond in OpenBSD a bit sluggish. But hey, it's my first try so what do I know? My company also utilise ESXi so it's good to know there's latest ISO provided by HPE for this server.

Then for XenServer 6.5. Not the latest version. Latest is version 7 but HPE stated that they officially supporting version 6.5 as compatible. No custom ISO by HPE so I went to xenserver.org to download it. But never did install it as it needs MBR booting only. No UEFI. Which somehow I do mind.

So I went back xenserver.org and get meself XenServer 7. I read that there's no web client included so I also download Xen Orchestra, which adds nearly 500Mb additional download from XenServer's 600Mb+-. ESXi have vSphere client, so do XenServer with its XenCenter. Both both are Windows only. Which is a bummer. But ESXi's built in web interface is good and progressing. Unlike XenServer which relies on 3rd party web interface like Xen Orchestra.

Installation-wise, XenServer can be installed in UEFI which is great. But there's strong suggestion to avoid installing it to SD or USB and proceed with the local disk instead so ESXi wins this part. Getting Xen Orchestra to run also pose a problem for newbie like me. My bad. I'm using an old Innacom's Streamyx ADSL Router Modem as my home-lab router for this exciting project so I'm learning quite a few things at once.

To my surprise, Xen Orchestra runs as a vm inside XenServer. Which I thought will just add the web interface inside XenServer instead of doing that. Also to my surprise, the web interface is much better than ESXi's. Maybe because I keyed in the free license in ESXi and many feature is disabled? I'm not quite sure. Many feature are also disabled in Xen Orchestra (oh, this one is also a free version) but I read that XenServer have all the feature enabled and I can just fall back to the trusty SHH/console if I need to use it. Honestly, although the Xen Orchestra's interface is nice, I found myself lost in it quite a few times. Anyway getting a vm installed using it is not that hard. But...

But ESXi made it easy to get guest OS's ISO uploaded to host server. This is also the thing that I like about ESXi. Basically storage manipulation in ESXi is easier for me, although I don't have enough experience with this VM thingy. I can just create a directory, then upload ISO into it and install my guest OS using it. In XenServer, I have to take note of the directory's limitation (storage is in XenServer's partition etc), mkdir the directory in somewhat standard place (/var/opt/xen/ISO_Store) and then register that directory to XenServer's Storage. And to note that I already gained a bit of experience in XenServer rather than the truly trial-and-error approached in ESXi earlier, these points really shows how well, hmm can I say "user friendly" ESXi is.

Putting that aside, I made that /var/opt/xen/ISO_Store thingy happened, push my install60.iso in it then install it. Easy-peasy-lemon-squeasy. Tried UEFI installation for it but didn't manage to boot OpenBSD after installation. I'm lazy to find the solution right now so I rushed for MBR installation. Hey I need to know how good XenServer will host my OpenBSD. And it doesn't dissappoint. I'm smiling to see that the xnf0 network interface was up in dhcp. The console respond in Xen Orchestra is also fluid. Nice. Getting OpenBSD up is the most important thing. And I know for now, XenServer is the suitable place for it in my DL160 Gen9. Until OpenBSD support all those hardware in bare-metal that is. Or who knows, maybe I'll stick with vm path as this is also a great knowledge to learn.

XenServer 7 it is then. Seeing more feature enabled in free version than ESXi, I made my choice already. Will I return to ESXi? I will for learning purpose. As I'm new on these (I think I state this too many now) vm thingy, the limitation in free ESXi might not make too much impact. Or if I was given an Essentials license for free. Hah! Oh also Microsoft have a free Windows Hyper-V 2012 R2 server for download, and done downloading I am.

That's it for now. I'll write up the details of installation and configuration next when I'm not too lazy to write as I'm currently playing around with the server. Just exploring the iLO4 alone is exciting! Later!

Friday, July 15, 2016

-c X200 amd64: Odoo 9, node.js npm "Abort Trap" error.

Hi,

Updated my OBSD today and git-pulled my Odoo 9 too. So I noticed 2 things, #1, kern.usermount's setting denied. #2, pledge() enforced on node (node.js). So my Odoo's Homepage is now messed up and informing a "Could not execute commend 'lessc'" info on the top part of the Homepage. This messed the Homepage only as other page (Discuss, Calendar etc) pages are ok. When I tried running npm, I get an error.

$ npm
Abort trap (core dumped)

Also dmesg is showing W^X violation.

node(12345): mmap W^X violation

So I'm unable to update less and so on. The truth is that I'm very new to the pledge(2) thingy and I need to find informations regarding this. If you have any info, do share with me. Later.

Update:
Bah! The info regarding this was already posted looooong ago. Ouch. Sorry for this.

https://www.openbsd.org/faq/current.html#r20160527

Wednesday, June 15, 2016

-c X200 amd64: Nginx + PHP5 + PostgreSQL + Drupal 8. Headaches and joy. Finally working.

Hi,

In short, I'm happy my 3 days of headache are over. And Drupal 8 is working now (from my 2 days test.). Hey it's just an updated version from Drupal 7 (which is in package), how hard can the installation be? Yeah I thought the same, but Drupal 8 requires additional package to work properly. I'll tell you about it.

There's no Drupal 8 package available yet. But it's just a web app. Just download the tar file from official Drupal site, and extract it in /var/www/htdocs and it should be ok as I've installed Drupal 7 before.

Take note that the web server I'm using is Nginx. It's in package so I can install it.

# pkg_add nginx

Then I can start to disable httpd and enable Nginx.

# /etc/rc.d/httpd stop

Edit /etc/rc.conf.local

===== /etc/rc.conf.local starts =====
#httpd_flags=
pkg_scripts=nginx
===== /etc/rc.conf.local end =====

Then start Nginx.

# /etc/rc.d/nginx start

Drupal version is 8.1.2 now. So I download that version and extract the tar.gz file.

# tar zxvf drupal-8.1.2.tar.gz
# mv drupal-8.1.2 /var/www/htdocs/drupal8

Then I chown the folder and contents to www:daemon. Before this I just leave all website inside /var/www/htdocs to root:daemon.

# cd /var/www/htdocs
# chown -R www:daemon

Now, for the /etc/nginx/nginx.conf, I follow the nginx.conf available in Nginx Recipe site.

https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/#

Take note to change the details inside. Then I copied the default.settings.php in drupal8, for the installation.

# cd drupal8
# cp sites/default/default.settings.php sites/default/settings.php

I don't need to change anything in settings.php as the installation will take care of it. And then I open up firefox and type "drupal.example.com" to open up the drupal installation. Do make sure the PostgreSQL part of the installation is ready (user and database for Drupal 8).

The installation went through. Then I was brought the Drupal 8's front page. Nice. I try clicking on the Content link.

The website encountered an unexpected error

What the.. This error took me 3 days to figure out the solution. I uncommented error log in nginx.conf, then check the log at /var/www/logs/error.log.

2016/06/14 16:02:13 [error] 48552#0: *89 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception RuntimeException: "GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler." at /htdocs/drupal8/vendor/guzzlehttp/guzzle/src/functions.php line 116" while reading response header from upstream, client: 127.0.0.1, server: drupal.example.com, request: "GET /node/add HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "drupal.example.com", referrer: "http://drupal.example.com/"


This is what I got. What GuzzleHttp? What? Searching around I found that I need to install curl. Fortunately it's in package.

# pkg_add php-curl

I choose the version similar to PHP5 version. Installed. Good. Opened drupal.example.com again. Click Content. Got the same error. What? Curl already installed!.

Doing more search and found that I need to define that curl library in /etc/php-5.6.ini. I put the details at the extension part.

===== /etc/php-5.6.ini start =====
* skipped *

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

extension=/usr/local/lib/php-5.6/modules/curl.so

* skipped *
===== / etc/php-5.6.ini end =====

Restarted both nginx & php-fpm.

# /etc/rc.d/nginx restart
# /etc/rc.d/php-fpm restart

Then check the website again. Wallah! It's working now. Yes! Ok I didn't put more info regarding PostgreSQL as I think I've already written something about it in the previous post. Somewhere.

Now the Drupal 8 is working, I can start learning the new app and do some little project that I've delayed sooooooooo long. Later.

Thursday, May 12, 2016

-c amd64 X200: Installation for Drupal 8.

Hi,

It's been quite some time. I'm busy with day's work. Ah and also my X200's battery just died. So it's immobile. It's just docked and that's it. Replacement battery or "new" thinkpad (I always buy used anyway.), I'm not sure. But not now.

Ok back to the latest project/test I'm going to do. Drupal 8 has been released, I know I'm a bit late, and it's an interesting update. So I really want to install it. Take note that I'm installing this, after I installed Drupal 7. So nearly all of the dependencies are already there. You might want to (re)visit my previous post on this at http://karlbsd.blogspot.my/2015/08/openbsd-58-c-amd64-httpd-postgresql.html.

Recap, this is httpd + Drupal 8 + PostgreSQL.

1) Download Drupal 8.
I head over to http://www.drupal.org and download the latest stable version 8.1.1 which is drupal-8.1.1.tar.gz.

2) Extract file and move to htdocs.
I tar the downloaded drupal-8.1.1.tar.gz and rename the directory to drupal8 while moving it to /var/www/htdocs.

$ tar zxvf drupal-8.1.1.tar.gz
$ mv drupal-8.1.1 /var/www/htdocs/drupal8

3) Prepare the local hostname.
This Drupal, like the previous version, will only be a local testing environment. I also have a few *.example.com sites here, a plain php site, some drupal 7 site so I need to have another local hostname. I'm choosing drupal.example.com as my Drupal 7 site will now have drupal7.example.com instead. For that, I edited 2 files, /etc/hosts and /etc/httpd.conf.

$ vi /etc/hosts

===== /etc/hosts starts =====
127.0.0.1    drupal.example.com
===== /etc/hosts ends =====

$ vi /etc/httpd.conf

===== /etc/httpd.conf starts =====
server "drupal.example.com" {
    listen on $ext_addr port 80

    directory {
        index "index.php"
    }

    location "*.php*" {
        fastcgi socket "/run/php-fpm.sock"
    }

    root "/htdocs/drupal8"
}
===== /etc/httpd.conf ends =====

4) Drupal 8 installation.
Now is the good stuff. After I restart (restarting httpd is also ok), I fire up my browser and type "drupal.example.org" and Drupal 8 installation page is displayed. Nice!.


At the Choose language page, I just choose the default English and click Save and continue.

Choose profile, I choose Standard and click Save and continue.

Verify requirements, I was shown a warning and 2 errors. I'll show what I've done to resolve the warning/errors.

PHP OPcode cachingNot enabled
PHP OPcode caching can improve your site's performance considerably. It ishighly recommended to haveOPcache installed on your server.

In OpenBSD 5.8 and newer, and -Current, the opcache.so is readily available. It's just that it's not included in /etc/php-5.6.ini. So I edited /etc/php-5.6.ini. My changes is in bold.

===== /etc/php-5.6.ini starts =====
* other sections skipped *

engine = On

* other sections skipped *

; zend.script_encoding =

; This is for Drupal 8
zend_extension=/usr/local/lib/php-5.6/modules/opcache.so

===== /etc/php-5.6.ini ends =====

And after restarting, the warning is gone.


File systemWritable (public download method)
The directory sites/default/files does not exist. An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the online handbook.
For this one, it's just that I create a files directory inside /sites/default. Then I chown the directory to www:www.

$ cd /var/www/htdocs/drupal8/sites/default
$ mkdir files
$ chown www:www files


Settings fileThe Settings file does not exist.
The Drupal installer requires that you create a ./sites/default/settings.php as part of the installation process. Copy the./sites/default/default.settings.php file to./sites/default/settings.php. More details about installing Drupal are available inINSTALL.txt.
This error is telling me that I haven't edited a settings.php file yet. So I need to copy the default.settings.php file to settings.php file.

$ cd /var/www/htdocs/drupal8/sites/default
$ cp default.settings.php settings.php
$ vi settings.php

===== settings.php starts =====
* other sections skipped *

/ **
* Database settings
* bla bla bla
*/
$database['default']['default'] = array(
    'driver' => 'pgsql',
    'database' => 'drupal',
    'username' => 'drupal',
    'password' => 'mypassword',
    'host' => 'localhost',
    'prefix' => '',
);

* other sections skipped *
===== settings.php ends =====

Take note that I have an existing Drupal 7 installation using the same database information. Exactly the same setting.

Then I click "try again" link at the bottom of the page.

Then the Database configuration page opens up.

Database configuration

Database type
 
 


I key in my Database password, then click Save and continue. Then I received an error stating that Drupal already been installed. Sheesh.

I dropped the previous drupal database in PostgreSQL, keeping the drupal username. Then I createdb a new drupal database. Please check your INSTALL.pgsql.txt file for details. Also I deleted the settings.php and copy default.settings.php to settings.php without changing anything. Just making sure the file is read/writable.

Then I restarted the Drupal installation again, and the installation went through.


On the configuration page, I just put the needed info and click Save and continue.

Drupal proceed to install. And after installing I can see the main page. Yeah!. Being amazed, I clicked on Content to start exploring and.. Error 404, Page not found. Ouch. Every other links gave the same error.

So I search the trusty-ol-internet, and found that this is related to Clean URL and mod_rewrite which unfortunately, users of OpenBSD's httpd can't use right now. Ouch. Again. I'm searching for anything relevant, maybe I'll try to disable the Clean URL thingy. But for now, I do know that Drupal 8 installation can go through. Later.

Saturday, November 21, 2015

-C amd64 X200: Installing Odoo 8/9 using git.

Hi,

Personally, I've been waiting for this little project. Remember my post earlier regarding tryton? Well, here comes the good stuff. Odoo.

I used this info to install Odoo 9, the newest version but then after opening the web, the display is all over the places. Text overlapping and the sections not displayed correctly. So I used this same method and install Odoo 8, which only shown a one-time "JQuery outdated" version warning but doesn't ruin the experience.

What I'm trying to do is:
-Install Odoo 8 (Odoo 9 should be no different) - done
-Use Httpd to serve the web - not yet
-Autostart Odoo 8 after boot - not yet

I'm using this sites for references, which is great help.
https://www.odoo.com/documentation/8.0/setup/install.html
http://www.dvatp.com/tech/odoo_on_freebsd

Take note that this installation is supposed to be for Odoo 9, but after few showstopper, I downloaded Odoo 8 and run on-top of this method, which has no bad effect. Yet.

First, install all required programs.
Install git
$ su root -c 'pkg_add git'

Install Python 2.7

Install py-pip, then use pip to install setuptools and then upgrade it. It's because I had "egg_info" error in Odoo 9 if I didn't upgrade it. Then install python-ldap, as the python-ldap listed in Odoo's requirement.txt cannot be installed (more on this later). Then also I need to install py-psutil using pkg_add, instead of pip because I got "platform openbsd5 not supported" when installing. Then I upgrade psutil using pip.
$ su root -c 'pkg_add py-pip'
$ doas pip install --upgrade pip
$ doas pip install setuptools
$ doad pip install --upgrade setuptools
$ doas pip install python-ldap
$ su root -c 'pkg_add psutil'
$ pip install --upgrade psutil

Install NodeJS. In OpenBSD it's called node. First install node using pkg_add, then upgrade it using npm, then using npm to install less and less-plugin-clean-css and upgrading 'em.
$ su root -c 'pkg_add node'
$ doas npm install -g npm
$ doas npm install less
$ doas npm install -g less
$ doas npm install less-plugin-clean-css
$ doas npm install -g less-plugin-clean-css

Install PostgreSQL

Install this optional programs, in my system half of it has already been installed.:
graphviz
ghostscript
poppler
antiword
curl
wkhtmltopdf
LibreOffice

Setting up Odoo 8 and PostgreSQL database for it.

Ok, for PostgreSQL, I just create a superuser named "odoo" which will require password.
$ createuser -U postgres -P -s odoo

Then I need to insert password for that new user.

Using Git, I download the latest Odoo 8.0 branch. I'm putting this in my home directory.
$ cd ~
$ git clone --depth 1 --branch 8.0 https://www.github.com/odoo/odoo

Yes, it's 2 "odoo" folder. Wait for it to finish downloading. After that you can see an "odoo" directory inside. Then go inside that directory.
$ cd odoo

Then I need to use pip to install the dependencies needed for Odoo 8.
$ doas pip install -r requirements.txt

This is when I have problem on psutil which gave "platform openbsd5 not supported" error, that's the reason I installed it above via pkg_add (not sure if odoo will use this other version.)

Then also I got an error about python-ldap cannot be installed. That's also the reason I installed python-ldap using pip manually. So, to make sure that the installation advances, I deleted those 2 requirement from the.. err.. requirement.txt.

In Odoo 9's requirement.txt:
psutil==2.2.0
python-ldap==2.4.19

In Odoo 8's requirement.txt:
psutil==2.1.1
python-ldap==2.4.15

Then run again the pip installer:
$ doas pip install -r requirement.txt

It's done! Now to create the configuration file. I created ".openerp-serverrc" file inside my home directory.
$ vi ~/.openerp-serverrc

--------- ~/.openerp-serverrc start ---------
[option]
db_host = 127.0.0.1
db_port = 5432
db_user = odoo
db_password = mypass
addons_path = /home/myhome/odoo/addons
--------- ~/.openerp-serverrc ends ---------

Done. Now I need to run the server and then configure Odoo via web.
$ cd ~/odoo
$ ./odoo.py &

In that same terminal, I can see all the info on what Odoo is currently doing. Then, in browser, open http://127.0.0.1:8069 or http://localhost:8069.


This screenshot is for Odoo 9. For Odoo 8, the page is different but the input required is the same. In Odoo 9, after database creation, my Odoo homepage is chaos. Like I've said earlier, text overlapping, display corruption etc. And then there's 'Could not execute command 'lessc' on the top-left side.  I read that I need to update less and less-plugin-clean-css via npm.

$ doas npm install -g less
$ doas npm install -g less-plugin-clean-css

Then I drop the database by using this page:
http://localhost:8069/web/database/manager

Delete the database, then go to the start page to create new. Still the same issue. So then I download Odoo 8.0 branch instead (this method above is for Odoo 8.0 branch).

In Odoo 8, when I open the start page for the first time, there's error about JQuery version being old version, but still can load Database Manager page. After creating database, the page doesn't refresh to load the main page. I need to see the term I run ./openerp-server and see if it's idling. After that I open up the home page.


As you can see, there's the warning message. It doesn't cripple the site, AFAIK but I'm looking into this later. Currently I've installed the accounting module and all seems to be working fine.

Update 26/11/2015:
Good news. Odoo 9.0 is working now. The "lessc" issue has been resolved. What I did was update the NodeJs's npm and then less and less-plugin-clean-css

$ doas npm install -g npm
$ doas npm install -g less less-plugin-clean-css

Then I started my Odoo 9. It's working! I'm not sure why the initial npm update above is not working. Anyway, it's good to know that it's working now.

ToDo: Set up httpd for Odoo 8
ToDo: Set up Odoo 8 in rc.d for automatic boot and shutdown.

p/s: I changed the Administrator's profile and when I tried to open back the home page, I was asked to enter email and password. I tried everything and can't log in. But then I didn't try this:

Email: admin
Password: my_odoo's_PgSQL's_password

And then only I can log in. Later.

Thursday, November 12, 2015

-C amd64 X200: Using xdimmer to dim the laptop monitor.

Hi,

Great news. I've been using this since I updated my snapshot a few days ago now. This is the utility that I've been waiting for!

xdimmer

http://openports.se/x11/xdimmer

"xdimmer is a small utility to automatically dim the screen when
no keyboard or mouse input has been detected in the configured
number of seconds, and brighten it once input is detected."

What a great battery saver! So, as I'm using ~/.xsession, I just add this line before the execution of my window manager (cwm, what else!):

xdimmer -t 360 &

So, after 360 seconds of keyboard/mouse inactivity, xdimmer will dim my laptop's monitor to the default percentage (which is 5 percent).

Thanks to the contributor! Later.

-C amd64 X200: LibreOffice 5 is here!

Hey,

Updated my lappy to the new snapshots a few days ago and now it's LibreOffice 5 time! Yeah!. Nice OpenBSD, nice.

Later.

Wednesday, September 30, 2015

5.8-C amd64 X200: Lock X after suspend.

Hi,

Got a good tips from OpenBSD.newbies mailing list. How to lock the machine after suspend. Ok, normally, if I didn't xlock my X session and put the machine under suspend mode (eg: close the lid), my session will be restored when the machine wakes. My session is exposed. So here's how to automatically lock the session when the machine goes into suspend mode.

1) Create a suspend file inside /etc/apm.
In my machine, there's no /etc/apm folder. So I need to create it first. Then create a suspend file inside it.

$ doas mkdir /etc/apm
$ doas vi /etc/apm/suspend

----- /etc/apm/suspend starts -----
#!/bin/sh
pkill -USR1 xidle
----- /etc/apm/suspend ends -----

Then I need to make this suspend executable.

$ doas chmod 744 /etc/apm/suspend

2) Get xidle running on start.
I edited my
.xsession file and add this text:
----- ~/.xsession starts -----
xidle &
----- ~/.xsession ends -----

Then I run the xidle program.

$ xidle &

So basically when I close my machine's lid, suspend will trigger xidle to lock the machine. Nice stuff.

Reference:
http://www.mail-archive.com/openbsd-newbies@sfobug.theapt.org/msg00043.html

5.8-C amd64 X200: Bye sudo, hi doas.

Hey,

Done updating, rebuilding the userland and following the.. err.. "Following -current" guide, now to reboot.

$ sudo reboot
ksh: sudo: not found

Oh. Yeah. I forgot. sudo is old news. Now it's doas time.

man doas
man doas.conf

Now, after all the setups, all I have to do to reboot is:

$ doas reboot

http://www.tedunangst.com/flak/post/out-with-the-old-in-with-the-less

http://www.tedunangst.com/flak/post/doas

Now it's just a matter of learning new habit. Later.

Tuesday, September 29, 2015

5.8-C amd64 X200: httpd error after upgrading snapshot.

Hi,

I downloaded the 29th September's SNAPSHOT and installed it successfully. But, after I rebooted, this error greeted me:

httpd(xxxx): syscall 5

The "xxxx" is replaced by bunch of numbers. Ouch. Searching the net about this but found no answer so far. I'm guessing that this is related to php, php-fpm or something. But I'm not sure.

UPDATE 30/09/2015:
Ok I asked misc regarding this and Ted Unangst has given the answer:

"The latest snapshots include a bunch of tame() calls in userland programs, but some of them were added optimistically. httpd is trying to do something it's not yet permitted to do.

For now, please report such errors.

If you need a working version, the diffs aren't committed yet, so you can rebuild httpd from source and it should work fine."


http://www.mail-archive.com/misc@openbsd.org/msg141426.html

Now, who said that the devs are bunch of man-eating-flame-throwing monster? As long as we search for answer first before asking (to see if it's already been asked and/or solved), and provide sufficient details (dmesg, related .conf files etc) when asking, you will get informative answers.

Ok. So it's basically new stuff in the httpd's snapshot. And to get a working httpd, I need to rebuild it. I've done port installation stuff but rebuilding a base program? I've never done this. But this is a good learning process. So I use the official guide:

http://www.openbsd.org/faq/faq5.html#Bld

I follow the "Following -current" guide. Then build the userland (I didn't build the kernel). It took some time. When it's done, I rebooted and httpd is working again! Yeah!

I noticed there's changes about php-fpm so I go through the Following -current page:

http://www.openbsd.org/faq/current.html#20150918

The previously named php_fpm rc script has been renamed according to PHP's version installed. So I edited my /etc/rc.conf.local.

----- /etc/rc.conf.local starts -----
pkg_scripts=php56_fpm
----- /etc/rc.conf.local ends -----

Just to be sure, I pkg_delete php-fpm then reinstall it. Reboot.

All is ok now. Thanks to Ted Unangst and all the people in misc@OpenBSD.

I think there's a way to just rebuild httpd, without rebuilding all userland. I'm searching for info on this.

Update 1st October 2015:

Stuart Henderson @misc has given a tip on how to update just the httpd.

$ cd /usr/src/usr.sbin/httpd
$ cvs up -PdA
$ make obj && make depend && make
$ su root -c 'make install'

 http://article.gmane.org/gmane.os.openbsd.misc/225370

Nice!. Learning something new everyday. Later.

Saturday, September 26, 2015

5.8-C amd64 X200: Drupal 7 Multisite.

Hey,

Why multisite? I read quite a bit of discouragement about this topic. Well, this is a local installation and it is a development (or hope to be) machine so I will (or might) be doing multiple sites. Hence the need.

My reference will be this site:

https://www.drupal.org/documentation/install/multi-site

You might need to refer to my previous posts as I might not be duplicating what is unnecessary here.

1) Preparing the site.
My default drupal site is drupal.example.com. So, I think I want to create another site called drupal2.example.com. I create a folder inside Drupal's sites folder.

$ cd /var/www/htdocs/drupal7/sites/
$ sudo mkdir drupal2.example.com

Along with that, I need to create a files folder inside my new drupal2's folder.

$ sudo mkdir -pm 777 drupal2.example.com/files

The files will need to be fully writeable as installation will gave error or not able to write inside that folder.

Folder creation done, now to set up appropriate files. Inside sites folder, there a file named example.sites.php. For a single-site.. err.. site, no need to touch this file but as I'm trying to create a multisite.. err.. site now, I need to edit this file. First I need to copy this file as sites.php file.

$ sudo cp example.sites.php sites.php

Now to edit this, adding this text at the bottom (bolded):

----- sites.php starts -----
<?php
* text snipped *

$sites['drupal2.example.com'] = 'example.com';
?>
----- sites.php ends -----

Yeah you read it right, I also included the closing tag for php as there's none there. Then I need to copy default.settings.php and put it as settings.php inside drupal2.example.com folder.

$ sudo cp sites/default/default.settings.php sites/drupal2.example.com/settings.php

Now to edit this file. I need to find and edit the $databases = array () occurances and change it to this.

----- drupal2 settings.php starts -----
$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal2',
      'username' => 'drupal',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'pgsql',
      'prefix' => '',
    ),
  ),
);
----- drupal2 settings.php ends -----

Remember this. I'm using PostgreSQL. This file is to set up my currently-non-existant new drupal2.example.com site's database. This part of the setup is complete.

2) Set up the database.
The command for PostgreSQL is:

$ createdb -U drupal -E UTF8 drupal2

For clarification, refer to my previous post about Drupal 7's installation. Basically I'm creating a black database using the "drupal" username with UTF8 encoding (needed!) and the name of that database is "drupal2". Make sure that the previous settings.php is configured according to this informations.

3) Set up the (local) domain.
I edited the /etc/hosts file.

----- /etc/hosts starts -----
127.0.0.1 drupal2.example.com
----- /etc/hosts ends -----

There's also other entries inside that file but I'm just showing the changes.

4) Configure HTTPd.
I edited the /etc/httpd.conf and inserted these text.

----- /etc/httpd.conf starts -----
server "juadah.example.com" {
        listen on $ext_addr port 80

        directory {
                index "index.php"
        }

        location "*.php*" {
                fastcgi socket "/run/php-fpm.sock"
        }

        root "/htdocs/drupal7"
}
----- /etc/https.conf ends -----

This is just a basic configuration. This should be it. Now to install the new site. I open up my browser, and type the new URL drupal2.example.com.

PDOException: SQLSTATE[42P01]:

Wha..?. I received errors instead talking about some PDO stuff. Ouch. After searching for a while, I found the answer. Wrong URL. The correct one for installation is:

drupal2.example.com/install.php

Then the installation went through. I got 2 warning when installing. 1 is for the files directory not writeable (hence the steps above) and the other one is about the unicode issue, refer my previous post as I need to patch the Drupal installation again because, hey, I'm following -CURRENT. Later.

Saturday, September 12, 2015

5.8-C X200 amd64: lib.c.81 not found after upgrading -current, and bunch of others.

Okay, so here I was, updating my -current system. Because, yeah, it's been a while. Fired up my ftp, grab the bsd*, *tgz and all, the usual stuff. Upgraded my system, done changing timezone and sysmerge. All is good. So I upgraded my packages. This is what happened.

Update candidates: xz-5.2.1 -> xz-5.2.1
Can't install xz-5.2.1 because of libraries
|library c.81.0 not found
| /usr/lib/libc.so.78.1 (system): bad major
| /usr/lib/libc.so.79.0 (system): bad major
| /usr/lib/libc.so.80.0 (system): bad major
| /usr/lib/libc.so.80.1 (system): bad major
| /usr/lib/libc.so.82.0 (system): bad major

Ack!. Then I this bunch of warnings like:

Can't install pkg_name because of libraries

Ok. Not bunch. But a lot. I'm guessing that this is about new version of libraries. So, after searching for answers, I found this:

http://comments.gmane.org/gmane.os.openbsd.misc/224817

Whew I'm grateful this is not because of some mistakes I made while upgrading. I even did another upgrade just to make sure. Yeah, so I need to wait for a few days before upgrading my packages. Later.

Wednesday, September 02, 2015

5.8-S amd64 X200: httpd Virtual Host.

Hi,

I've been having headache trying to solve the Virtual Hosting issue when using OpenBSD's new httpd (starting from 5.7) included in the base. After fairly quite a lot a trial and errors (mostly errors) and nearly downloading nginx today, I finally got the Virtual Host working now.

I really like the concept of OpenBSD's new httpd. Simple configuration, the devs are keeping the code simple and it's in the base. I also got Drupal 7 working fine (except for clean url, which is minor as this is for developing, not production) and I'm having fun learning Drupal here. But so far, I only managed to get 1 site working at a time. That means, I need to reconfigure my /etc/httpd.conf every time I want to change the website I want to work on. If I only want to work on a single site, this would not pose a problem. But I have more than 1 website I want to work on, so this is tiring me down.

I know that the httpd is chrooted by default, but I didn't know how to configure it properly until now. Well "properly" is not as "perfect" but more to "got it to work" kind of saying. So please correct me if you find anything that's wrong here. So here it goes.

My scenario, I'm working in 1 Drupal 7 site, then 1 another html/php site. The directory is as below:

/var/www/htdocs (the /var/www is the chroot directory)
/var/www/htdocs/drupal7 (my drupal dev directory, the default as installed)
/var/www/htdocs/karl (my html/php dev site)

For Drupal 7 installations and configurations, you can check my previous post. Now here's my /etc/httpd.conf.

---- /etc/httpd.conf start ----

# Macros
ext_addr="*"

# Server
server "default" {
    listen on $ext_addr port 80

    directory {
        auto index
    }

    location "*.php*" {
        fastcgi socket "/run/php-fpm.sock"
    }

    location "/cgi-bin/*" {
        fastcgi
        root "/"
    }

}

---- /etc/httpd.conf end ----

Now that's for the default site. I noticed that if I change the upper part to:

server "www.example.com" {
    listen on $ext_addr port 80
    alias "example.com"


Then if I just type "example.com" in my browser, it will display my local site's main page instead of the internet's site. Take note that it's easier to use "Private Window" (Firefox) or "Incognito Window" (Chrome) for testing purpose. I also set the index to be created automatically because I don't want to create any site inside the root "/htdocs" directory and this is just a local development machine. Now for the Virtual Host setting inside /etc/httpd.conf.

---- /etc/httpd.conf continues ----

# virtual server for Drupal
server "drupal.example.com" {
    listen on $ext_addr port 80

    directory {
        index "index.php"
    }

    location "*.php*" {
        fastcgi socket "/run/php-fpm.sock"
    }

    root "/htdocs/drupal7"

}

# virtual server for Karl
server "karl.example.com" {
    listen on $ext_addr port 80

    location "*.php*" {
        fastcgi socket "/run/php-fpm.sock"
    }

    root "/htdocs/karl"

}

types {
    includes "/usr/share/misc/mime.types"
}


---- /etc/httpd.conf ends ----

Now this is the simplest working form of my /etc/httpd.conf. On httpd side, this should be ok. Now for the important part, making the Virtual Host part work. As httpd works in chroot by default, it will only access files inside /var/www for safety reason. So I need to create an etc directory inside /var/www.

# mkdir /var/www/etc

Then I need to copy /etc/hosts and /etc/resolv.conf into /var/www/etcb.

# cp /etc/hosts /var/www/etc
# cp /etc/resolv.conf /var/www/etc

This is the content of both files:

---- /var/www/etc/hosts start ----

127.0.0.1    localhost    www.example.com
::1    localhost    www.example.com

---- /var/www/etc/hosts end ----

---- /var/www/etc/resolv.conf start ----

# Generated by em0 dhclient
search Home
nameserver 127.0.0.1
lookup file bind

---- /var/www/etc/resolv.conf end ----

Ok. I was thinking that to make Virtual Host using httpd works, I need to edit that /var/www/etc/hosts file, as that is the chroot directory. I was wrong. I didn't manage to get the Virtual Host working by editing that file. It was the /etc/hosts file that needs editing. Here's mine.

---- /etc/hosts start ----

127.0.0.1    localhost    www.example.com
127.0.0.1    drupal.example.com
127.0.0.1    karl.example.com
::1    localhost    www.example.com

---- /etc/hosts end ----

I only use 2 Virtual Hosts as of now, but I'm guessing that more can be set up with appropriate configuration changes. So now I restarted the httpd.

# sudo /etc/rc.d/httpd restart

Open up my browser, typed all 3 urls:

www.example.com
drupal.example.com
karl.example.com

and all open up the appropriate pages. I'm loving this! Now this leave only 1 more minor thing to be done, the Clean URL. But like I've said, it's only a minor thing. Later.

Wednesday, August 19, 2015

-SNAPSHOT amd64 X200: Drupal 7 module installation error.

Hi,

So far I'm still learning about Drupal. I have a project in mind using this. So I wanted to install a module into this Drupal-o-mine.

First, I need to enable FTPd. I edited /etc/rc.conf.local file and add this:

ftpd_flags=

Then I start the daemon by using:

# sudo /etc/rc.d/ftpd start

I open Drupal's page using web browser. In Drupal's Home page, I click on "Modules" link on the top bar and then click on "+ Install new module" link on the Module's page. I've already downloaded the module's tar.gz file so choose that file and then click "Install".

The "Update Manager" page appears. The "Connection method" only have "FTP" so nothing to change there. The "User" is my login's user name. Then the password is my login pass. I leave the "ADVANCE SETTINGS" as it is then click on "Continue" button.

Error message

Installation failed! See the log below for more information.

recipe

  • Error installing / updating
  • File Transfer failed, reason: Cannot create directory /htdocs/drupal7/sites/all/modules

Next steps



This is the error I received. Yeah I know it's permission issue (and might even be the current Drupal's bug) and I tried everything below without success:

-Change "htdocs/drupal7/sites/all/modules" owner and permission.
-Change the tar.gz file permission.

I will search for answer and if this is the current Drupal's bug (https://www.drupal.org/node/842620), I might try manual module installation. Later

Friday, August 07, 2015

SNAPSHOT amd64 X200: httpd + PostgreSQL + Drupal 7.

Hey,

Starting with 5.7, OpenBSD have their own httpd replacing nginx in base. This httpd is fairly new and un/fortunately I'm trying to learn Drupal nowadays. Sure I can install Apache or nginx from port but I want to test the new httpd.

Take note!
1) I'm currently on -CURRENT using snapshot.
2) I never installed drupal or any web app before.
3) This is a Work In Progress and will be updated until it's done.

So I guess that's quite a warning for you guys. My installation might not be the correct one or might not even install correctly but I will try to make sure I find out how to make this work. Googling for info on the new httpd with Drupal only return less than handful of info. But as always, web searching is needed. So without any delays, here I go.


SETTING UP HTTPD.
As I'm going Openbsd's own (and new) httpd, the program has been already installed. To enable it, I just need to edit /etc/httpd.conf. I commented all the entries in that file except for this few lines (mostly the "A minimal default server" entries).

---- /etc/httpd.conf start ----
# Macros
ext_addr="*"

# A minimal default server
server "default" {
listen on $ext_addr port 80

location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
root "/htdocs"

}

# Include MIME types instead of the built-in ones
types {
include "/usr/share/misc/mime.types"
}
---- /etc/httpd.conf end ----

As a simple rule-of-a-thumb, start with the minimum configuration then adjust from there. It's easier to check for error/mistakes. As Drupal is a PHP program, I need to install PHP. I also will be using PostgreSQL for the database. What I've installed is:

php-5.6.11
php-fpm.5.6.11p0
php-gd-5.6.11 (this might be dependency, I can't recall right now)
php-pdo_pgsql-5.6.11 (I'll be using PostgreSQL instead of MySQL)
postgresql-client-9.4.4
postgresql-contrib-9.4.4
postgresql-docs-9.4.4 (optional, but I want it)
postgresql-server-9.4.4

As we can see in the /etc/httpd.conf, there's "php-fpm" entry. As the package has been installed, I need to make it start at boot along with httpd by editing /etc/rc.conf.local.

---- /etc/rc.conf.local start ----
httpd_flags=
slowcgi=
pkg_scripts=php_fpm postgresql

---- /etc/rc.conf.local end ----

The "slowcgi" came with httpd, so I add it in /etc/rc.conf.local. Now we can either start httpd, slowcgi & php-fpm manually now or reboot. Unlike Apache, there's no template webpage that you can see after your httpd has started. So I created a Hello World-like index.html file inside the webserver's root directory which is /var/www/htdocs/. So now I open up my web browser and insert the URL as either "localhost" or "127.0.0.1" (without quotes), I can see the Hello World page. Httpd is running fine. To test the PHP function, I created a phpinfo.php file inside the same directory with this value:

---- /var/www/htdocs/phpinfo.php start ----
<?php phpinfo(); ?>
---- /var/www/htdocs/phpinfo.php end ----

I open the URL "localhost/phpinfo.php" in my browser, the PHP Version page is displayed and I know PHP is working fine.


INSTALLING DRUPAL.
I just pkg_add drupal-7.32.p1. Then I read the info in /usr/local/share/doc/pkg-readmes/drupal-7.32p1 telling me to symlink (symbolic link) the drupal7.conf and follow the database setup for PostgreSQL which is:

ln -sf /var/www/conf/modules.sample/drupal7.conf /var/www/conf/modules

createuser -U postgres --pwprompt --no-superuser --createdb --no-createrole drupal
createdb -U drupal -E UTF8 drupal

The "postgres" name is my PostgreSQL's admin name. There will be input request for password so I create a password, verify it and make sure I don't forget it. For drupal7.conf, I haven't touch anything, yet.


SETTING UP DRUPAL.
Webserver running? Check. PostgreSQL running? Check. Drupal running? Not yet. I tried putting "localhost/drupal7" and "127.0.0.1/drupal7" in the browser but both didn't work. I got Error 403 Forbidden. Ouch. I'm seriously lack of experience for this httpd and drupal stuff so I thought that maybe I need to install either Apache or Nginx (assuming that nobody done drupal with httpd yet). That's until I read a hint in www.drupal.org. So, I insert this in my browser:

http://localhost/drupal7/install.php

And wallah!, the Drupal installation page appears!. Yes! It's making progress. So I proceed with the installation as below:

Choose profile = Standard > Save and continue
Choose language = English (built-in) > Sane and continue
Verify requirements = all is ok except for "Unicode library = Error"

7th August: Ok. The error is about a deprecated function in PHP which must be disabled for Drupal's installation to continue. Yeah quite confusing. The exact error is:

Unicode libraryError
Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentationfor more information.

I opened the PHP mbstring documentation but nothing can help me on this. So I google for tips and found that there's 2 ways to resolve this.

1) Add this lines in .htaccess in Drupal's web root (/var/www/htdocs/drupal7)

---- .htacces start ----
php_value mbstring.http_input pass
php_value mbstring.http_output pass
---- .htaccess end ----

I checked the Drupal's web root, but there's no .htacces file inside. I think this is related to Apache but just to make sure, I downloaded a sample .htacces file from www.drupal.org . Restarted the httpd, open the installation page and still have that error. So this is not working for me.

2) Add this line in ../drupal7/sites/default/setting.php

---- setting.php start ----
ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

---- setting.php end ----

Restarted the httpd. And open the installation page and greeted by this warning message:

  • Deprecated function: ini_set(): Use of mbstring.http_input is deprecated in include_once() (line 318 of /htdocs/drupal7/sites/default/settings.php).
  • Deprecated function: ini_set(): Use of mbstring.http_output is deprecated in include_once() (line 319 of /htdocs/drupal7/sites/default/settings.php).

When I click Save and continue, this message appears in every page. But then the Verify requirement page passed successfully (although the warning is still there). So I'm now at the Set up database page.

Set up database:
Database = PostgreSQL
Database name* = drupal (the one I set before in PostgreSQL)
Database username* = drupal
Database password* = (the password I entered back then in PostgreSQL)

But now I'm in dilemma. I don't know if that "Deprecated function:" warning is harmless or not. I think I will search for more clue before I click on that "Save and continue" button.

Update 9th August: Searching on the net point me out to the most relevant issue stated in drupal's site at:

https://www.drupal.org/node/2332295

There's patch files listed on the top of that page and the most relevant one is the file:

drupal7-unicode_requirements-2332295-23.patch

That file will be patching /includes/unicode.inc file in the root Drupal's folder. I read the patch file, and compared with the current unicode.inc file and found that this is the correct patch. Now to patch it.


PATCHING DRUPAL
I downloaded the patch file, and move it to Drupal's root folder at /var/www/htdocs/drupal7 . Patching is something I rarely do so I refresh what I can by using man patch.

I need to test the patch first, to see if it's working as it's supposed to be. So I proceed with the testing command:

# sudo patch -C includes/unicode.inc drupal7-unicode_requirements-2332295-23.patch

Then the result came:

---- message snipped ----
Patching file includes/unicode.inc using Plan A...
Hunk #1 succeeded at 116.
done

Looks fine to me. So then I proceed with the actual patching:

# sudo patch includes/unicode.inc drupal7-unicode_requirements-2332295-23.patch

Done. Now to test the Drupal's installation. Just remember to delete/comment back both the "ini_set" lines I added in sites/default/settings.php. Restarted httpd and proceed with installation again.

INSTALLATION.
- Get browser to open http://127.0.0.1/drupal7/install.php
- Choose profile > Standard > Save and continue = passed
- Choose language > English (built-in) > Save and continue = passed
- Verify requirements = passed
- Set up database
 > Database name = drupal
 > Database username = drupal
 > Database password = (same as when I set in PostgreSQL)
 > Save and continue

Got this error:

In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.
Failed to connect to your database server. The server reports the following message: SQLSTATE[08006] [7] could not translate host name "localhost" to address: no address associated with name.
  • Is the database server running?
  • Does the database exist, and have you entered the correct database name?
  • Have you entered the correct username and password?
  • Have you entered the correct database hostname?

Ok. I read that because httpd in OpenBSD is chrooted, I need to copy /etc/hosts and put it in /var/www/etc/. By default there's no etc/ folder in www so I need to mkdir it. Make sure that "hosts" file at least have this line:

127.0.0.1   localhost www.example.com

Now that should be it. Restarted httpd again and run throught the installation again.

- Set up database
 > blablabla
 > Save and continue = passed
- Install profile (it will take a moment = passed
- Configure site
 > Site name* = default
 > Site e-mail address* = noreply@example.com (can be changed)
 > Username = karl
 > E-mail address = (real email address)
 > Password* = *********
 > Confirm password* = *********
 > Default country = Malaysia
 > Default time zone = Asia/Kuala Lumpur
 > Check for updates automatically = checked
 > Received e-mail notifications = checked
 > Save and continue = FINISHED!

Congratulations, I installed Drupal. Now to visit my local site.

Unfortunately, currently I can't use http://127.0.0.1/drupal7/ to visit my site (which if my httpd configured correctly, should be the correct address) but I can visit the site by using complete URL instead.

http://127.0.0.1/drupal7/index.html

For Drupal, all seems ok. I need to further test out and start exploring. For httpd issue above, I will also do the same. I will update on these issues when I found any tips. Enjoy the screenshot. Later.


UPDATE!: Bah although Drupal has been installed successfully, it's not functioning as it should. I have a feeling it's related to OpenBSD's httpd's setting. I would be grateful if someone can point me to relevant setting for this issue. Thanks in advance.

Update 10th August: Ok I have configured the /etc/httpd.conf file and now Drupal is working fine. Here's my configuration:

---- /etc/httpd.conf start ----
ext_addr="*"

server "default" {
    listen on $ext_addr port 80

    directory {
        index "index.php"
    }

    location "*.php" {
        fastcgi socket "/run/php-fpm.sock"
    }

    location "/cgi-bin/*" {
        fastcgi
        root "/"
    }

    root "/htdocs/drupal7"
}
---- /etc/httpd.conf end ----

Restarted the httpd server. Now when I type www.example.com or 127.0.0.1 or localhost in my browser, I can see the Drupal start page. I typed my Username and Password then I can see the site correctly. No more errors.


I've also posted a Hello World! entry to test it out. Enjoy the screenshot. Later.

6.5 amd64: Modify existing certbot certificates.

Hi, It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to ...