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.

No comments: